From 2499fdfeb1c42bed97c19deb55bbebb438628399 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 May 2024 18:06:35 +0000 Subject: [PATCH 001/532] feat(api): OpenAPI spec update via Stainless API (#481) --- .stats.yml | 2 +- api.md | 56 +- src/cloudflare/resources/bot_management.py | 4 +- src/cloudflare/resources/cache/cache.py | 4 +- src/cloudflare/resources/calls.py | 13 +- .../cloudforce_one/requests/message.py | 76 +- .../cloudforce_one/requests/priority.py | 88 +- .../cloudforce_one/requests/requests.py | 112 +- src/cloudflare/resources/dns/records.py | 96 - .../intel/indicator_feeds/indicator_feeds.py | 12 +- src/cloudflare/resources/intel/whois.py | 14 +- src/cloudflare/resources/r2/sippy.py | 4 +- .../resources/radar/http/ases/ases.py | 8 + .../resources/radar/http/ases/bot_class.py | 8 + .../resources/radar/http/ases/device_type.py | 8 + .../resources/radar/http/ases/http_method.py | 8 + .../radar/http/ases/http_protocol.py | 8 + .../resources/radar/http/ases/ip_version.py | 8 + .../resources/radar/http/ases/os.py | 8 + .../resources/radar/http/ases/tls_version.py | 8 + .../radar/http/locations/bot_class.py | 8 + .../radar/http/locations/device_type.py | 8 + .../radar/http/locations/http_method.py | 8 + .../radar/http/locations/http_protocol.py | 8 + .../radar/http/locations/ip_version.py | 8 + .../radar/http/locations/locations.py | 8 + .../resources/radar/http/locations/os.py | 8 + .../radar/http/locations/tls_version.py | 8 + src/cloudflare/resources/radar/http/top.py | 16 + src/cloudflare/resources/rulesets/rules.py | 286 +- src/cloudflare/resources/workers/ai.py | 6 - .../resources/workers/scripts/scripts.py | 4 +- .../dispatch/namespaces/scripts/scripts.py | 4 +- .../access/applications/applications.py | 277 +- .../access/applications/policies.py | 123 +- .../zero_trust/identity_providers.py | 68 +- src/cloudflare/types/calls/__init__.py | 1 + .../types/calls/call_list_response.py | 6 + .../types/calls/calls_app_with_secret.py | 2 +- .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- .../intel/indicator_feed_update_params.py | 2 +- .../types/radar/http/ase_get_params.py | 3 + .../radar/http/ases/bot_class_get_params.py | 3 + .../radar/http/ases/device_type_get_params.py | 3 + .../radar/http/ases/http_method_get_params.py | 3 + .../http/ases/http_protocol_get_params.py | 3 + .../radar/http/ases/ip_version_get_params.py | 3 + .../types/radar/http/ases/os_get_params.py | 3 + .../radar/http/ases/tls_version_get_params.py | 3 + .../types/radar/http/location_get_params.py | 3 + .../http/locations/bot_class_get_params.py | 3 + .../http/locations/device_type_get_params.py | 3 + .../http/locations/http_method_get_params.py | 3 + .../locations/http_protocol_get_params.py | 3 + .../http/locations/ip_version_get_params.py | 3 + .../radar/http/locations/os_get_params.py | 3 + .../http/locations/tls_version_get_params.py | 3 + .../radar/http/top_browser_families_params.py | 3 + .../types/radar/http/top_browsers_params.py | 3 + .../types/rulesets/phase_get_response.py | 75 +- .../types/rulesets/phase_update_params.py | 66 +- .../types/rulesets/phase_update_response.py | 75 +- .../rulesets/phases/version_get_response.py | 75 +- .../types/rulesets/rule_create_params.py | 74 +- .../types/rulesets/rule_create_response.py | 75 +- .../types/rulesets/rule_delete_response.py | 75 +- .../types/rulesets/rule_edit_params.py | 77 +- .../types/rulesets/rule_edit_response.py | 75 +- .../types/rulesets/ruleset_create_params.py | 66 +- .../types/rulesets/ruleset_create_response.py | 75 +- .../types/rulesets/ruleset_get_response.py | 75 +- .../types/rulesets/ruleset_update_params.py | 66 +- .../types/rulesets/ruleset_update_response.py | 75 +- .../types/rulesets/set_config_rule.py | 10 +- .../types/rulesets/set_config_rule_param.py | 10 +- .../types/rulesets/version_get_response.py | 75 +- .../rulesets/versions/by_tag_get_response.py | 75 +- .../types/zero_trust/access/__init__.py | 5 +- .../types/zero_trust/access/application.py | 709 ----- .../access/application_create_params.py | 666 ++++- .../access/application_create_response.py | 2304 +++++++++++++++++ .../access/application_get_response.py | 2304 +++++++++++++++++ .../access/application_list_response.py | 2304 +++++++++++++++++ .../access/application_update_params.py | 666 ++++- .../access/application_update_response.py | 2304 +++++++++++++++++ .../access/applications/__init__.py | 5 +- .../applications/policy_create_params.py | 5 +- .../{policy.py => policy_create_response.py} | 9 +- .../applications/policy_get_response.py | 73 + .../applications/policy_list_response.py | 73 + .../applications/policy_update_params.py | 5 +- .../applications/policy_update_response.py | 73 + .../cloudforce_one/requests/test_message.py | 50 +- .../cloudforce_one/requests/test_priority.py | 50 +- .../cloudforce_one/test_requests.py | 82 +- .../intel/test_indicator_feeds.py | 4 +- tests/api_resources/intel/test_whois.py | 18 +- .../radar/http/ases/test_bot_class.py | 2 + .../radar/http/ases/test_device_type.py | 2 + .../radar/http/ases/test_http_method.py | 2 + .../radar/http/ases/test_http_protocol.py | 2 + .../radar/http/ases/test_ip_version.py | 2 + .../api_resources/radar/http/ases/test_os.py | 2 + .../radar/http/ases/test_tls_version.py | 2 + .../radar/http/locations/test_bot_class.py | 2 + .../radar/http/locations/test_device_type.py | 2 + .../radar/http/locations/test_http_method.py | 2 + .../http/locations/test_http_protocol.py | 2 + .../radar/http/locations/test_ip_version.py | 2 + .../radar/http/locations/test_os.py | 2 + .../radar/http/locations/test_tls_version.py | 2 + tests/api_resources/radar/http/test_ases.py | 2 + .../radar/http/test_locations.py | 2 + tests/api_resources/radar/http/test_top.py | 4 + tests/api_resources/rulesets/test_rules.py | 360 ++- tests/api_resources/test_calls.py | 18 +- .../access/applications/test_policies.py | 69 +- .../zero_trust/access/test_applications.py | 685 +++-- 120 files changed, 14011 insertions(+), 1563 deletions(-) create mode 100644 src/cloudflare/types/calls/call_list_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/application.py create mode 100644 src/cloudflare/types/zero_trust/access/application_create_response.py create mode 100644 src/cloudflare/types/zero_trust/access/application_get_response.py create mode 100644 src/cloudflare/types/zero_trust/access/application_list_response.py create mode 100644 src/cloudflare/types/zero_trust/access/application_update_response.py rename src/cloudflare/types/zero_trust/access/applications/{policy.py => policy_create_response.py} (92%) create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_get_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_list_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_update_response.py diff --git a/.stats.yml b/.stats.yml index b162e099397..9dfc386c5ae 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1274 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-07ec76fab00de3d6227209faf0af1ed586cde9e2f243c13d3db555da20f13d99.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88d076c2683d7002e7743172b9488fb67d1a07b61995921f27209e01b224af60.yml diff --git a/api.md b/api.md index 5fca9d1aeaa..2d967bec1d7 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -5095,18 +5095,22 @@ from cloudflare.types.zero_trust.access import ( SaaSAppSource, SAMLSaaSApp, SelfHostedDomains, + ApplicationCreateResponse, + ApplicationUpdateResponse, + ApplicationListResponse, ApplicationDeleteResponse, + ApplicationGetResponse, ApplicationRevokeTokensResponse, ) ``` Methods: -- client.zero_trust.access.applications.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.update(app_id, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.list(\*, account_id, zone_id) -> SyncSinglePage[Application] +- client.zero_trust.access.applications.create(\*, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.applications.update(app_id, \*, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.applications.list(\*, account_id, zone_id) -> SyncSinglePage[ApplicationListResponse] - client.zero_trust.access.applications.delete(app_id, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.get(app_id, \*, account_id, zone_id) -> Optional +- client.zero_trust.access.applications.get(app_id, \*, account_id, zone_id) -> Optional - client.zero_trust.access.applications.revoke_tokens(app_id, \*, account_id, zone_id) -> object #### CAs @@ -5152,17 +5156,21 @@ Types: from cloudflare.types.zero_trust.access.applications import ( ApprovalGroup, Policy, + PolicyCreateResponse, + PolicyUpdateResponse, + PolicyListResponse, PolicyDeleteResponse, + PolicyGetResponse, ) ``` Methods: -- client.zero_trust.access.applications.policies.create(uuid, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.policies.update(uuid, \*, uuid1, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.policies.list(uuid, \*, account_id, zone_id) -> SyncSinglePage[Policy] +- client.zero_trust.access.applications.policies.create(uuid, \*, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.applications.policies.update(uuid, \*, uuid1, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.applications.policies.list(uuid, \*, account_id, zone_id) -> SyncSinglePage[PolicyListResponse] - client.zero_trust.access.applications.policies.delete(uuid, \*, uuid1, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.policies.get(uuid, \*, uuid1, account_id, zone_id) -> Optional +- client.zero_trust.access.applications.policies.get(uuid, \*, uuid1, account_id, zone_id) -> Optional ### Certificates @@ -7346,14 +7354,14 @@ Methods: Types: ```python -from cloudflare.types.calls import CallsApp, CallsAppWithSecret +from cloudflare.types.calls import CallsApp, CallsAppWithSecret, CallListResponse ``` Methods: - client.calls.create(\*, account_id, \*\*params) -> Optional - client.calls.update(app_id, \*, account_id, \*\*params) -> Optional -- client.calls.list(\*, account_id) -> SyncSinglePage[CallsApp] +- client.calls.list(\*, account_id) -> SyncSinglePage[CallListResponse] - client.calls.delete(app_id, \*, account_id) -> Optional - client.calls.get(app_id, \*, account_id) -> Optional @@ -7376,14 +7384,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7399,10 +7407,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7419,11 +7427,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/bot_management.py b/src/cloudflare/resources/bot_management.py index e53c10a35f6..d1ee986475a 100644 --- a/src/cloudflare/resources/bot_management.py +++ b/src/cloudflare/resources/bot_management.py @@ -248,7 +248,7 @@ def update( """ ... - @required_args(["zone_id"], ["zone_id"], ["zone_id"], ["zone_id"]) + @required_args(["zone_id"]) def update( self, *, @@ -563,7 +563,7 @@ async def update( """ ... - @required_args(["zone_id"], ["zone_id"], ["zone_id"], ["zone_id"]) + @required_args(["zone_id"]) async def update( self, *, diff --git a/src/cloudflare/resources/cache/cache.py b/src/cloudflare/resources/cache/cache.py index c46d707bd24..29104a62b96 100644 --- a/src/cloudflare/resources/cache/cache.py +++ b/src/cloudflare/resources/cache/cache.py @@ -372,7 +372,7 @@ def purge( """ ... - @required_args(["zone_id"], ["zone_id"], ["zone_id"], ["zone_id"], ["zone_id"]) + @required_args(["zone_id"]) def purge( self, *, @@ -724,7 +724,7 @@ async def purge( """ ... - @required_args(["zone_id"], ["zone_id"], ["zone_id"], ["zone_id"], ["zone_id"]) + @required_args(["zone_id"]) async def purge( self, *, diff --git a/src/cloudflare/resources/calls.py b/src/cloudflare/resources/calls.py index 71d97f590e8..d2865c1352e 100644 --- a/src/cloudflare/resources/calls.py +++ b/src/cloudflare/resources/calls.py @@ -27,6 +27,7 @@ make_request_options, ) from ..types.calls.calls_app import CallsApp +from ..types.calls.call_list_response import CallListResponse from ..types.calls.calls_app_with_secret import CallsAppWithSecret __all__ = ["CallsResource", "AsyncCallsResource"] @@ -144,7 +145,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[CallsApp]: + ) -> SyncSinglePage[CallListResponse]: """ Lists all apps in the Cloudflare account @@ -163,11 +164,11 @@ def list( 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}/calls/apps", - page=SyncSinglePage[CallsApp], + page=SyncSinglePage[CallListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=CallsApp, + model=str, ) def delete( @@ -371,7 +372,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[CallsApp, AsyncSinglePage[CallsApp]]: + ) -> AsyncPaginator[CallListResponse, AsyncSinglePage[CallListResponse]]: """ Lists all apps in the Cloudflare account @@ -390,11 +391,11 @@ def list( 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}/calls/apps", - page=AsyncSinglePage[CallsApp], + page=AsyncSinglePage[CallListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=CallsApp, + model=str, ) async def delete( diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/dns/records.py b/src/cloudflare/resources/dns/records.py index a3fc72a9354..b5142133fe4 100644 --- a/src/cloudflare/resources/dns/records.py +++ b/src/cloudflare/resources/dns/records.py @@ -1199,24 +1199,8 @@ def create( @required_args( ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], ["zone_id", "data", "name", "type"], ["zone_id", "content", "name", "priority", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], ["zone_id", "data", "name", "priority", "type"], ) def create( @@ -2486,24 +2470,8 @@ def update( @required_args( ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], ["zone_id", "data", "name", "type"], ["zone_id", "content", "name", "priority", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], ["zone_id", "data", "name", "priority", "type"], ) def update( @@ -3944,25 +3912,9 @@ def edit( ... @required_args( - ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], ["zone_id", "content", "name", "type"], ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], ["zone_id", "content", "name", "priority", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], ["zone_id", "data", "name", "priority", "type"], ) def edit( @@ -5403,24 +5355,8 @@ async def create( @required_args( ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], ["zone_id", "data", "name", "type"], ["zone_id", "content", "name", "priority", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], ["zone_id", "data", "name", "priority", "type"], ) async def create( @@ -6690,24 +6626,8 @@ async def update( @required_args( ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], ["zone_id", "data", "name", "type"], ["zone_id", "content", "name", "priority", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], ["zone_id", "data", "name", "priority", "type"], ) async def update( @@ -8148,25 +8068,9 @@ async def edit( ... @required_args( - ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], ["zone_id", "content", "name", "type"], ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], ["zone_id", "content", "name", "priority", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "content", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "data", "name", "type"], - ["zone_id", "content", "name", "type"], ["zone_id", "data", "name", "priority", "type"], ) async def edit( diff --git a/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py b/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py index 721bab7afab..89be9cf8218 100644 --- a/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py +++ b/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py @@ -124,7 +124,7 @@ def update( feed_id: int, *, account_id: str, - feed_description: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, is_attributable: bool | NotGiven = NOT_GIVEN, is_public: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -142,7 +142,7 @@ def update( feed_id: Indicator feed ID - feed_description: The new description of the feed + description: The new description of the feed is_attributable: The new is_attributable value of the feed @@ -162,7 +162,7 @@ def update( f"/accounts/{account_id}/intel/indicator-feeds/{feed_id}", body=maybe_transform( { - "feed_description": feed_description, + "description": description, "is_attributable": is_attributable, "is_public": is_public, }, @@ -370,7 +370,7 @@ async def update( feed_id: int, *, account_id: str, - feed_description: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, is_attributable: bool | NotGiven = NOT_GIVEN, is_public: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -388,7 +388,7 @@ async def update( feed_id: Indicator feed ID - feed_description: The new description of the feed + description: The new description of the feed is_attributable: The new is_attributable value of the feed @@ -408,7 +408,7 @@ async def update( f"/accounts/{account_id}/intel/indicator-feeds/{feed_id}", body=await async_maybe_transform( { - "feed_description": feed_description, + "description": description, "is_attributable": is_attributable, "is_public": is_public, }, diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/r2/sippy.py b/src/cloudflare/resources/r2/sippy.py index e245dda32a2..7f134a5e730 100644 --- a/src/cloudflare/resources/r2/sippy.py +++ b/src/cloudflare/resources/r2/sippy.py @@ -114,7 +114,7 @@ def update( """ ... - @required_args(["account_id"], ["account_id"]) + @required_args(["account_id"]) def update( self, bucket_name: str, @@ -326,7 +326,7 @@ async def update( """ ... - @required_args(["account_id"], ["account_id"]) + @required_args(["account_id"]) async def update( self, bucket_name: str, diff --git a/src/cloudflare/resources/radar/http/ases/ases.py b/src/cloudflare/resources/radar/http/ases/ases.py index 5802bbf3b71..ccb97e7c87c 100644 --- a/src/cloudflare/resources/radar/http/ases/ases.py +++ b/src/cloudflare/resources/radar/http/ases/ases.py @@ -129,6 +129,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -183,6 +184,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -236,6 +239,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -301,6 +305,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -355,6 +360,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -408,6 +415,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/ases/bot_class.py b/src/cloudflare/resources/radar/http/ases/bot_class.py index 809ae7ff1de..d9665ba21c1 100644 --- a/src/cloudflare/resources/radar/http/ases/bot_class.py +++ b/src/cloudflare/resources/radar/http/ases/bot_class.py @@ -45,6 +45,7 @@ def get( bot_class: Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"], *, asn: List[str] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( For example, `-174, 3356` excludes results from AS174, but includes results from AS3356. + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -154,6 +157,7 @@ def get( query=maybe_transform( { "asn": asn, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -191,6 +195,7 @@ async def get( bot_class: Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"], *, asn: List[str] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -246,6 +251,8 @@ async def get( For example, `-174, 3356` excludes results from AS174, but includes results from AS3356. + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -300,6 +307,7 @@ async def get( query=await async_maybe_transform( { "asn": asn, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/ases/device_type.py b/src/cloudflare/resources/radar/http/ases/device_type.py index 6bad8da2bc3..3c74d3c5e77 100644 --- a/src/cloudflare/resources/radar/http/ases/device_type.py +++ b/src/cloudflare/resources/radar/http/ases/device_type.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -153,6 +156,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -190,6 +194,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -244,6 +249,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -297,6 +304,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/ases/http_method.py b/src/cloudflare/resources/radar/http/ases/http_method.py index 9d6f41fb2b9..bbf7d121de4 100644 --- a/src/cloudflare/resources/radar/http/ases/http_method.py +++ b/src/cloudflare/resources/radar/http/ases/http_method.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -153,6 +156,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -190,6 +194,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -244,6 +249,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -297,6 +304,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/ases/http_protocol.py b/src/cloudflare/resources/radar/http/ases/http_protocol.py index b3ef2da221b..980a72d60c2 100644 --- a/src/cloudflare/resources/radar/http/ases/http_protocol.py +++ b/src/cloudflare/resources/radar/http/ases/http_protocol.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -99,6 +100,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -150,6 +153,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -186,6 +190,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -239,6 +244,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -290,6 +297,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/ases/ip_version.py b/src/cloudflare/resources/radar/http/ases/ip_version.py index b62867a8aa9..13d9e9d31a5 100644 --- a/src/cloudflare/resources/radar/http/ases/ip_version.py +++ b/src/cloudflare/resources/radar/http/ases/ip_version.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -153,6 +156,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -190,6 +194,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -244,6 +249,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -297,6 +304,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/ases/os.py b/src/cloudflare/resources/radar/http/ases/os.py index 4b9be3919f3..70dcdf4f079 100644 --- a/src/cloudflare/resources/radar/http/ases/os.py +++ b/src/cloudflare/resources/radar/http/ases/os.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -99,6 +100,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -152,6 +155,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -189,6 +193,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -242,6 +247,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -295,6 +302,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/ases/tls_version.py b/src/cloudflare/resources/radar/http/ases/tls_version.py index 10cd0b988e2..8b002599f70 100644 --- a/src/cloudflare/resources/radar/http/ases/tls_version.py +++ b/src/cloudflare/resources/radar/http/ases/tls_version.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -153,6 +156,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -190,6 +194,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -244,6 +249,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -297,6 +304,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/locations/bot_class.py b/src/cloudflare/resources/radar/http/locations/bot_class.py index 6507e30fff9..e19b3d4ee2e 100644 --- a/src/cloudflare/resources/radar/http/locations/bot_class.py +++ b/src/cloudflare/resources/radar/http/locations/bot_class.py @@ -45,6 +45,7 @@ def get( bot_class: Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"], *, asn: List[str] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( For example, `-174, 3356` excludes results from AS174, but includes results from AS3356. + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -154,6 +157,7 @@ def get( query=maybe_transform( { "asn": asn, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -191,6 +195,7 @@ async def get( bot_class: Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"], *, asn: List[str] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -246,6 +251,8 @@ async def get( For example, `-174, 3356` excludes results from AS174, but includes results from AS3356. + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -300,6 +307,7 @@ async def get( query=await async_maybe_transform( { "asn": asn, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/locations/device_type.py b/src/cloudflare/resources/radar/http/locations/device_type.py index cb9ae569c73..db12278738c 100644 --- a/src/cloudflare/resources/radar/http/locations/device_type.py +++ b/src/cloudflare/resources/radar/http/locations/device_type.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -101,6 +102,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -154,6 +157,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -191,6 +195,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -246,6 +251,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -299,6 +306,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/locations/http_method.py b/src/cloudflare/resources/radar/http/locations/http_method.py index fd17679a21b..c524a57a4dc 100644 --- a/src/cloudflare/resources/radar/http/locations/http_method.py +++ b/src/cloudflare/resources/radar/http/locations/http_method.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -101,6 +102,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -154,6 +157,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -191,6 +195,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -246,6 +251,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -299,6 +306,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/locations/http_protocol.py b/src/cloudflare/resources/radar/http/locations/http_protocol.py index 68bc53b8b5f..76b7013a00d 100644 --- a/src/cloudflare/resources/radar/http/locations/http_protocol.py +++ b/src/cloudflare/resources/radar/http/locations/http_protocol.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -151,6 +154,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -187,6 +191,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -241,6 +246,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -292,6 +299,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/locations/ip_version.py b/src/cloudflare/resources/radar/http/locations/ip_version.py index 26d202727d4..2eba4d7db23 100644 --- a/src/cloudflare/resources/radar/http/locations/ip_version.py +++ b/src/cloudflare/resources/radar/http/locations/ip_version.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -153,6 +156,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -190,6 +194,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -244,6 +249,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -297,6 +304,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/locations/locations.py b/src/cloudflare/resources/radar/http/locations/locations.py index 63301a082cc..5d89799c3ee 100644 --- a/src/cloudflare/resources/radar/http/locations/locations.py +++ b/src/cloudflare/resources/radar/http/locations/locations.py @@ -129,6 +129,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -183,6 +184,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -236,6 +239,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -301,6 +305,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -355,6 +360,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -408,6 +415,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/locations/os.py b/src/cloudflare/resources/radar/http/locations/os.py index 6564789c347..12e9f4512d0 100644 --- a/src/cloudflare/resources/radar/http/locations/os.py +++ b/src/cloudflare/resources/radar/http/locations/os.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -99,6 +100,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -152,6 +155,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -189,6 +193,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -242,6 +247,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -295,6 +302,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/locations/tls_version.py b/src/cloudflare/resources/radar/http/locations/tls_version.py index 9a43d75f252..c1fd6d54336 100644 --- a/src/cloudflare/resources/radar/http/locations/tls_version.py +++ b/src/cloudflare/resources/radar/http/locations/tls_version.py @@ -46,6 +46,7 @@ def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -153,6 +156,7 @@ def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -190,6 +194,7 @@ async def get( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -244,6 +249,8 @@ async def get( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -297,6 +304,7 @@ async def get( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/radar/http/top.py b/src/cloudflare/resources/radar/http/top.py index b96c3aa3671..7cd13feaadd 100644 --- a/src/cloudflare/resources/radar/http/top.py +++ b/src/cloudflare/resources/radar/http/top.py @@ -46,6 +46,7 @@ def browser_families( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -100,6 +101,8 @@ def browser_families( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -153,6 +156,7 @@ def browser_families( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -180,6 +184,7 @@ def browsers( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -234,6 +239,8 @@ def browsers( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -287,6 +294,7 @@ def browsers( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -324,6 +332,7 @@ async def browser_families( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -378,6 +387,8 @@ async def browser_families( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -431,6 +442,7 @@ async def browser_families( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, @@ -458,6 +470,7 @@ async def browsers( *, asn: List[str] | NotGiven = NOT_GIVEN, bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + browser_family: List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]] | NotGiven = NOT_GIVEN, continent: List[str] | NotGiven = NOT_GIVEN, date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, date_range: List[ @@ -512,6 +525,8 @@ async def browsers( bot_class: Filter for bot class. Refer to [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + browser_family: Filter for browser family. + continent: Array of comma separated list of continents (alpha-2 continent codes). Start with `-` to exclude from results. For example, `-EU,NA` excludes results from Europe, but includes results from North America. @@ -565,6 +580,7 @@ async def browsers( { "asn": asn, "bot_class": bot_class, + "browser_family": browser_family, "continent": continent, "date_end": date_end, "date_range": date_range, diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index 48621b0a6bf..bd7c415a47b 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -943,6 +943,66 @@ def create( """ ... + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["log_custom_field"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsLogCustomFieldRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + def create( self, ruleset_id: str, @@ -965,6 +1025,7 @@ def create( | Literal["set_config"] | Literal["skip"] | Literal["set_cache_settings"] + | Literal["log_custom_field"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -978,6 +1039,7 @@ def create( | rule_create_params.SetConfigRuleActionParameters | rule_create_params.SkipRuleActionParameters | rule_create_params.SetCacheSettingsRuleActionParameters + | rule_create_params.RulesetsLogCustomFieldRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, @@ -2007,23 +2069,68 @@ def edit( """ ... - @required_args( - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ) + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["log_custom_field"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsLogCustomFieldRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @required_args(["ruleset_id"]) def edit( self, rule_id: str, @@ -2047,6 +2154,7 @@ def edit( | Literal["set_config"] | Literal["skip"] | Literal["set_cache_settings"] + | Literal["log_custom_field"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object @@ -2060,6 +2168,7 @@ def edit( | rule_edit_params.SetConfigRuleActionParameters | rule_edit_params.SkipRuleActionParameters | rule_edit_params.SetCacheSettingsRuleActionParameters + | rule_edit_params.RulesetsLogCustomFieldRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, @@ -3024,6 +3133,66 @@ async def create( """ ... + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["log_custom_field"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsLogCustomFieldRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + async def create( self, ruleset_id: str, @@ -3046,6 +3215,7 @@ async def create( | Literal["set_config"] | Literal["skip"] | Literal["set_cache_settings"] + | Literal["log_custom_field"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -3059,6 +3229,7 @@ async def create( | rule_create_params.SetConfigRuleActionParameters | rule_create_params.SkipRuleActionParameters | rule_create_params.SetCacheSettingsRuleActionParameters + | rule_create_params.RulesetsLogCustomFieldRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, @@ -4088,23 +4259,68 @@ async def edit( """ ... - @required_args( - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ["ruleset_id"], - ) + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["log_custom_field"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsLogCustomFieldRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @required_args(["ruleset_id"]) async def edit( self, rule_id: str, @@ -4128,6 +4344,7 @@ async def edit( | Literal["set_config"] | Literal["skip"] | Literal["set_cache_settings"] + | Literal["log_custom_field"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object @@ -4141,6 +4358,7 @@ async def edit( | rule_edit_params.SetConfigRuleActionParameters | rule_edit_params.SkipRuleActionParameters | rule_edit_params.SetCacheSettingsRuleActionParameters + | rule_edit_params.RulesetsLogCustomFieldRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/resources/workers/ai.py b/src/cloudflare/resources/workers/ai.py index 56733d0cbfd..4c1f83aed9a 100644 --- a/src/cloudflare/resources/workers/ai.py +++ b/src/cloudflare/resources/workers/ai.py @@ -458,14 +458,11 @@ def run( ["account_id", "text"], ["account_id", "prompt"], ["account_id", "sentences", "source"], - ["account_id", "text"], ["account_id", "audio"], ["account_id", "image"], ["account_id"], - ["account_id"], ["account_id", "target_lang", "text"], ["account_id", "input_text"], - ["account_id", "image"], ) def run( self, @@ -974,14 +971,11 @@ async def run( ["account_id", "text"], ["account_id", "prompt"], ["account_id", "sentences", "source"], - ["account_id", "text"], ["account_id", "audio"], ["account_id", "image"], ["account_id"], - ["account_id"], ["account_id", "target_lang", "text"], ["account_id", "input_text"], - ["account_id", "image"], ) async def run( self, diff --git a/src/cloudflare/resources/workers/scripts/scripts.py b/src/cloudflare/resources/workers/scripts/scripts.py index 2ae2c62f3a7..4ad655e6f59 100644 --- a/src/cloudflare/resources/workers/scripts/scripts.py +++ b/src/cloudflare/resources/workers/scripts/scripts.py @@ -207,7 +207,7 @@ def update( """ ... - @required_args(["account_id"], ["account_id"]) + @required_args(["account_id"]) def update( self, script_name: str, @@ -499,7 +499,7 @@ async def update( """ ... - @required_args(["account_id"], ["account_id"]) + @required_args(["account_id"]) async def update( self, script_name: str, diff --git a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/scripts.py b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/scripts.py index eaaece76d7b..82979ddf8ce 100644 --- a/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/scripts.py +++ b/src/cloudflare/resources/workers_for_platforms/dispatch/namespaces/scripts/scripts.py @@ -188,7 +188,7 @@ def update( """ ... - @required_args(["account_id", "dispatch_namespace"], ["account_id", "dispatch_namespace"]) + @required_args(["account_id", "dispatch_namespace"]) def update( self, script_name: str, @@ -455,7 +455,7 @@ async def update( """ ... - @required_args(["account_id", "dispatch_namespace"], ["account_id", "dispatch_namespace"]) + @required_args(["account_id", "dispatch_namespace"]) async def update( self, script_name: str, diff --git a/src/cloudflare/resources/zero_trust/access/applications/applications.py b/src/cloudflare/resources/zero_trust/access/applications/applications.py index 3192d3b31f5..b2865d2bafb 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/applications.py +++ b/src/cloudflare/resources/zero_trust/access/applications/applications.py @@ -54,13 +54,16 @@ application_create_params, application_update_params, ) -from .....types.zero_trust.access.application import Application from .....types.zero_trust.access.allowed_idps import AllowedIdPs from .....types.zero_trust.access.app_id_param import AppIDParam from .....types.zero_trust.access.application_type import ApplicationType from .....types.zero_trust.access.cors_headers_param import CORSHeadersParam from .....types.zero_trust.access.self_hosted_domains import SelfHostedDomains +from .....types.zero_trust.access.application_get_response import ApplicationGetResponse +from .....types.zero_trust.access.application_list_response import ApplicationListResponse +from .....types.zero_trust.access.application_create_response import ApplicationCreateResponse from .....types.zero_trust.access.application_delete_response import ApplicationDeleteResponse +from .....types.zero_trust.access.application_update_response import ApplicationUpdateResponse __all__ = ["ApplicationsResource", "AsyncApplicationsResource"] @@ -109,6 +112,7 @@ def create( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -121,7 +125,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -175,6 +179,10 @@ def create( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -213,6 +221,7 @@ def create( custom_pages: List[str] | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, + policies: List[application_create_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_create_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, @@ -222,7 +231,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -245,6 +254,10 @@ def create( name: The name of the application. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -283,6 +296,7 @@ def create( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -295,7 +309,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -349,6 +363,10 @@ def create( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -398,6 +416,7 @@ def create( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -410,7 +429,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -464,6 +483,10 @@ def create( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -499,6 +522,7 @@ def create( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -506,7 +530,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -523,6 +547,10 @@ def create( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -546,6 +574,7 @@ def create( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -553,7 +582,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -570,6 +599,10 @@ def create( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -593,6 +626,7 @@ def create( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -600,7 +634,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -617,6 +651,10 @@ def create( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -649,7 +687,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -703,6 +741,7 @@ def create( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -716,7 +755,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -730,7 +769,7 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id return cast( - Optional[Application], + Optional[ApplicationCreateResponse], self._post( f"/{account_or_zone}/{account_or_zone_id}/access/apps", body=maybe_transform( @@ -752,6 +791,7 @@ def create( "name": name, "options_preflight_bypass": options_preflight_bypass, "path_cookie_attribute": path_cookie_attribute, + "policies": policies, "same_site_cookie_attribute": same_site_cookie_attribute, "self_hosted_domains": self_hosted_domains, "service_auth_401_redirect": service_auth_401_redirect, @@ -767,10 +807,10 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Application]]._unwrapper, + post_parser=ResultWrapper[Optional[ApplicationCreateResponse]]._unwrapper, ), cast_to=cast( - Any, ResultWrapper[Application] + Any, ResultWrapper[ApplicationCreateResponse] ), # Union types cannot be passed in as arguments in the type system ), ) @@ -799,6 +839,7 @@ def update( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -811,7 +852,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -867,6 +908,10 @@ def update( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -906,6 +951,7 @@ def update( custom_pages: List[str] | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, + policies: List[application_update_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_update_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, @@ -915,7 +961,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -940,6 +986,10 @@ def update( name: The name of the application. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -979,6 +1029,7 @@ def update( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -991,7 +1042,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -1047,6 +1098,10 @@ def update( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -1097,6 +1152,7 @@ def update( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -1109,7 +1165,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -1165,6 +1221,10 @@ def update( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -1201,6 +1261,7 @@ def update( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1208,7 +1269,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -1227,6 +1288,10 @@ def update( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -1251,6 +1316,7 @@ def update( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1258,7 +1324,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -1277,6 +1343,10 @@ def update( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -1301,6 +1371,7 @@ def update( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1308,7 +1379,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -1327,6 +1398,10 @@ def update( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -1360,7 +1435,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -1417,6 +1492,7 @@ def update( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -1430,7 +1506,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1444,7 +1520,7 @@ def update( account_or_zone = "zones" account_or_zone_id = zone_id return cast( - Optional[Application], + Optional[ApplicationUpdateResponse], self._put( f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", body=maybe_transform( @@ -1466,6 +1542,7 @@ def update( "name": name, "options_preflight_bypass": options_preflight_bypass, "path_cookie_attribute": path_cookie_attribute, + "policies": policies, "same_site_cookie_attribute": same_site_cookie_attribute, "self_hosted_domains": self_hosted_domains, "service_auth_401_redirect": service_auth_401_redirect, @@ -1481,10 +1558,10 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Application]]._unwrapper, + post_parser=ResultWrapper[Optional[ApplicationUpdateResponse]]._unwrapper, ), cast_to=cast( - Any, ResultWrapper[Application] + Any, ResultWrapper[ApplicationUpdateResponse] ), # Union types cannot be passed in as arguments in the type system ), ) @@ -1500,7 +1577,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Application]: + ) -> SyncSinglePage[ApplicationListResponse]: """ Lists all Access applications in an account or zone. @@ -1531,11 +1608,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/access/apps", - page=SyncSinglePage[Application], + page=SyncSinglePage[ApplicationListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=cast(Any, Application), # Union types cannot be passed in as arguments in the type system + model=cast(Any, ApplicationListResponse), # Union types cannot be passed in as arguments in the type system ) def delete( @@ -1605,7 +1682,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationGetResponse]: """ Fetches information about an Access application. @@ -1637,7 +1714,7 @@ def get( account_or_zone = "zones" account_or_zone_id = zone_id return cast( - Optional[Application], + Optional[ApplicationGetResponse], self._get( f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", options=make_request_options( @@ -1645,10 +1722,10 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Application]]._unwrapper, + post_parser=ResultWrapper[Optional[ApplicationGetResponse]]._unwrapper, ), cast_to=cast( - Any, ResultWrapper[Application] + Any, ResultWrapper[ApplicationGetResponse] ), # Union types cannot be passed in as arguments in the type system ), ) @@ -1753,6 +1830,7 @@ async def create( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -1765,7 +1843,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -1819,6 +1897,10 @@ async def create( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -1857,6 +1939,7 @@ async def create( custom_pages: List[str] | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, + policies: List[application_create_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_create_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, @@ -1866,7 +1949,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -1889,6 +1972,10 @@ async def create( name: The name of the application. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -1927,6 +2014,7 @@ async def create( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -1939,7 +2027,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -1993,6 +2081,10 @@ async def create( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -2042,6 +2134,7 @@ async def create( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -2054,7 +2147,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -2108,6 +2201,10 @@ async def create( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -2143,6 +2240,7 @@ async def create( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2150,7 +2248,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -2167,6 +2265,10 @@ async def create( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -2190,6 +2292,7 @@ async def create( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2197,7 +2300,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -2214,6 +2317,10 @@ async def create( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -2237,6 +2344,7 @@ async def create( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2244,7 +2352,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -2261,6 +2369,10 @@ async def create( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -2293,7 +2405,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: """ Adds a new application to Access. @@ -2347,6 +2459,7 @@ async def create( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -2360,7 +2473,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationCreateResponse]: if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -2374,7 +2487,7 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id return cast( - Optional[Application], + Optional[ApplicationCreateResponse], await self._post( f"/{account_or_zone}/{account_or_zone_id}/access/apps", body=await async_maybe_transform( @@ -2396,6 +2509,7 @@ async def create( "name": name, "options_preflight_bypass": options_preflight_bypass, "path_cookie_attribute": path_cookie_attribute, + "policies": policies, "same_site_cookie_attribute": same_site_cookie_attribute, "self_hosted_domains": self_hosted_domains, "service_auth_401_redirect": service_auth_401_redirect, @@ -2411,10 +2525,10 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Application]]._unwrapper, + post_parser=ResultWrapper[Optional[ApplicationCreateResponse]]._unwrapper, ), cast_to=cast( - Any, ResultWrapper[Application] + Any, ResultWrapper[ApplicationCreateResponse] ), # Union types cannot be passed in as arguments in the type system ), ) @@ -2443,6 +2557,7 @@ async def update( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -2455,7 +2570,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -2511,6 +2626,10 @@ async def update( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -2550,6 +2669,7 @@ async def update( custom_pages: List[str] | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, + policies: List[application_update_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_update_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, @@ -2559,7 +2679,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -2584,6 +2704,10 @@ async def update( name: The name of the application. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -2623,6 +2747,7 @@ async def update( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -2635,7 +2760,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -2691,6 +2816,10 @@ async def update( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -2741,6 +2870,7 @@ async def update( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -2753,7 +2883,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -2809,6 +2939,10 @@ async def update( path_cookie_attribute: Enables cookie paths to scope an application's JWT to the application path. If disabled, the JWT will scope to the hostname by default + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. @@ -2845,6 +2979,7 @@ async def update( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2852,7 +2987,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -2871,6 +3006,10 @@ async def update( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -2895,6 +3034,7 @@ async def update( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2902,7 +3042,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -2921,6 +3061,10 @@ async def update( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -2945,6 +3089,7 @@ async def update( zone_id: str | NotGiven = NOT_GIVEN, allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2952,7 +3097,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -2971,6 +3116,10 @@ async def update( auto_redirect_to_identity: When set to `true`, users skip the identity provider selection step during login. You must specify only one identity provider in allowed_idps. + policies: The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -3004,7 +3153,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: """ Updates an Access application. @@ -3061,6 +3210,7 @@ async def update( name: str | NotGiven = NOT_GIVEN, options_preflight_bypass: bool | NotGiven = NOT_GIVEN, path_cookie_attribute: bool | NotGiven = NOT_GIVEN, + policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, @@ -3074,7 +3224,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationUpdateResponse]: if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3088,7 +3238,7 @@ async def update( account_or_zone = "zones" account_or_zone_id = zone_id return cast( - Optional[Application], + Optional[ApplicationUpdateResponse], await self._put( f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", body=await async_maybe_transform( @@ -3110,6 +3260,7 @@ async def update( "name": name, "options_preflight_bypass": options_preflight_bypass, "path_cookie_attribute": path_cookie_attribute, + "policies": policies, "same_site_cookie_attribute": same_site_cookie_attribute, "self_hosted_domains": self_hosted_domains, "service_auth_401_redirect": service_auth_401_redirect, @@ -3125,10 +3276,10 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Application]]._unwrapper, + post_parser=ResultWrapper[Optional[ApplicationUpdateResponse]]._unwrapper, ), cast_to=cast( - Any, ResultWrapper[Application] + Any, ResultWrapper[ApplicationUpdateResponse] ), # Union types cannot be passed in as arguments in the type system ), ) @@ -3144,7 +3295,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Application, AsyncSinglePage[Application]]: + ) -> AsyncPaginator[ApplicationListResponse, AsyncSinglePage[ApplicationListResponse]]: """ Lists all Access applications in an account or zone. @@ -3175,11 +3326,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/access/apps", - page=AsyncSinglePage[Application], + page=AsyncSinglePage[ApplicationListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=cast(Any, Application), # Union types cannot be passed in as arguments in the type system + model=cast(Any, ApplicationListResponse), # Union types cannot be passed in as arguments in the type system ) async def delete( @@ -3249,7 +3400,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Application]: + ) -> Optional[ApplicationGetResponse]: """ Fetches information about an Access application. @@ -3281,7 +3432,7 @@ async def get( account_or_zone = "zones" account_or_zone_id = zone_id return cast( - Optional[Application], + Optional[ApplicationGetResponse], await self._get( f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}", options=make_request_options( @@ -3289,10 +3440,10 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Application]]._unwrapper, + post_parser=ResultWrapper[Optional[ApplicationGetResponse]]._unwrapper, ), cast_to=cast( - Any, ResultWrapper[Application] + Any, ResultWrapper[ApplicationGetResponse] ), # Union types cannot be passed in as arguments in the type system ), ) diff --git a/src/cloudflare/resources/zero_trust/access/applications/policies.py b/src/cloudflare/resources/zero_trust/access/applications/policies.py index 14423705cf1..9c7b8824bd3 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/policies.py +++ b/src/cloudflare/resources/zero_trust/access/applications/policies.py @@ -28,9 +28,12 @@ ) from .....types.zero_trust.access_rule_param import AccessRuleParam from .....types.zero_trust.access.applications import policy_create_params, policy_update_params -from .....types.zero_trust.access.applications.policy import Policy +from .....types.zero_trust.access.applications.policy_get_response import PolicyGetResponse from .....types.zero_trust.access.applications.approval_group_param import ApprovalGroupParam +from .....types.zero_trust.access.applications.policy_list_response import PolicyListResponse +from .....types.zero_trust.access.applications.policy_create_response import PolicyCreateResponse from .....types.zero_trust.access.applications.policy_delete_response import PolicyDeleteResponse +from .....types.zero_trust.access.applications.policy_update_response import PolicyUpdateResponse __all__ = ["PoliciesResource", "AsyncPoliciesResource"] @@ -68,9 +71,12 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Policy]: + ) -> Optional[PolicyCreateResponse]: """ - Create a new Access policy for an application. + Creates a policy applying exclusive to a single application that defines the + users or groups who can reach it. We recommend creating a reusable policy + instead and subsequently referencing its ID in the application's 'policies' + array. Args: uuid: UUID @@ -98,7 +104,8 @@ def create( this policy. 'Client Web Isolation' must be on for the account in order to use this feature. - precedence: The order of execution for this policy. Must be unique for each policy. + precedence: The order of execution for this policy. Must be unique for each policy within an + app. purpose_justification_prompt: A custom message that will appear on the purpose justification screen. @@ -157,9 +164,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Policy]]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyCreateResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[Policy]], ResultWrapper[Policy]), + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), ) def update( @@ -187,9 +194,11 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Policy]: - """ - Update a configured Access policy. + ) -> Optional[PolicyUpdateResponse]: + """Updates an Access policy specific to an application. + + To update a reusable + policy, use the /account or zones/{identifier}/policies/{uid} endpoint. Args: uuid1: UUID @@ -219,7 +228,8 @@ def update( this policy. 'Client Web Isolation' must be on for the account in order to use this feature. - precedence: The order of execution for this policy. Must be unique for each policy. + precedence: The order of execution for this policy. Must be unique for each policy within an + app. purpose_justification_prompt: A custom message that will appear on the purpose justification screen. @@ -280,9 +290,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Policy]]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[Policy]], ResultWrapper[Policy]), + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) def list( @@ -297,9 +307,11 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Policy]: - """ - Lists Access policies configured for an application. + ) -> SyncSinglePage[PolicyListResponse]: + """Lists Access policies configured for an application. + + Returns both exclusively + scoped and reusable policies used by the application. Args: uuid: UUID @@ -332,11 +344,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", - page=SyncSinglePage[Policy], + page=SyncSinglePage[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Policy, + model=PolicyListResponse, ) def delete( @@ -353,8 +365,10 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[PolicyDeleteResponse]: - """ - Delete an Access policy. + """Deletes an Access policy specific to an application. + + To delete a reusable + policy, use the /account or zones/{identifier}/policies/{uid} endpoint. Args: uuid1: UUID @@ -414,9 +428,11 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Policy]: - """ - Fetches a single Access policy. + ) -> Optional[PolicyGetResponse]: + """Fetches a single Access policy configured for an application. + + Returns both + exclusively owned and reusable policies used by the application. Args: uuid1: UUID @@ -458,9 +474,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Policy]]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[Policy]], ResultWrapper[Policy]), + cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), ) @@ -497,9 +513,12 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Policy]: + ) -> Optional[PolicyCreateResponse]: """ - Create a new Access policy for an application. + Creates a policy applying exclusive to a single application that defines the + users or groups who can reach it. We recommend creating a reusable policy + instead and subsequently referencing its ID in the application's 'policies' + array. Args: uuid: UUID @@ -527,7 +546,8 @@ async def create( this policy. 'Client Web Isolation' must be on for the account in order to use this feature. - precedence: The order of execution for this policy. Must be unique for each policy. + precedence: The order of execution for this policy. Must be unique for each policy within an + app. purpose_justification_prompt: A custom message that will appear on the purpose justification screen. @@ -586,9 +606,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Policy]]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyCreateResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[Policy]], ResultWrapper[Policy]), + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), ) async def update( @@ -616,9 +636,11 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Policy]: - """ - Update a configured Access policy. + ) -> Optional[PolicyUpdateResponse]: + """Updates an Access policy specific to an application. + + To update a reusable + policy, use the /account or zones/{identifier}/policies/{uid} endpoint. Args: uuid1: UUID @@ -648,7 +670,8 @@ async def update( this policy. 'Client Web Isolation' must be on for the account in order to use this feature. - precedence: The order of execution for this policy. Must be unique for each policy. + precedence: The order of execution for this policy. Must be unique for each policy within an + app. purpose_justification_prompt: A custom message that will appear on the purpose justification screen. @@ -709,9 +732,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Policy]]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[Policy]], ResultWrapper[Policy]), + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) def list( @@ -726,9 +749,11 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Policy, AsyncSinglePage[Policy]]: - """ - Lists Access policies configured for an application. + ) -> AsyncPaginator[PolicyListResponse, AsyncSinglePage[PolicyListResponse]]: + """Lists Access policies configured for an application. + + Returns both exclusively + scoped and reusable policies used by the application. Args: uuid: UUID @@ -761,11 +786,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", - page=AsyncSinglePage[Policy], + page=AsyncSinglePage[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Policy, + model=PolicyListResponse, ) async def delete( @@ -782,8 +807,10 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[PolicyDeleteResponse]: - """ - Delete an Access policy. + """Deletes an Access policy specific to an application. + + To delete a reusable + policy, use the /account or zones/{identifier}/policies/{uid} endpoint. Args: uuid1: UUID @@ -843,9 +870,11 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Policy]: - """ - Fetches a single Access policy. + ) -> Optional[PolicyGetResponse]: + """Fetches a single Access policy configured for an application. + + Returns both + exclusively owned and reusable policies used by the application. Args: uuid1: UUID @@ -887,9 +916,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Policy]]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[Policy]], ResultWrapper[Policy]), + cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), ) diff --git a/src/cloudflare/resources/zero_trust/identity_providers.py b/src/cloudflare/resources/zero_trust/identity_providers.py index 3e9508b349d..c07d0a4f1fb 100644 --- a/src/cloudflare/resources/zero_trust/identity_providers.py +++ b/src/cloudflare/resources/zero_trust/identity_providers.py @@ -722,22 +722,7 @@ def create( """ ... - @required_args( - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ) + @required_args(["config", "name", "type"]) def create( self, *, @@ -1516,22 +1501,7 @@ def update( """ ... - @required_args( - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ) + @required_args(["config", "name", "type"]) def update( self, uuid: str, @@ -2451,22 +2421,7 @@ async def create( """ ... - @required_args( - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ) + @required_args(["config", "name", "type"]) async def create( self, *, @@ -3245,22 +3200,7 @@ async def update( """ ... - @required_args( - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ["config", "name", "type"], - ) + @required_args(["config", "name", "type"]) async def update( self, uuid: str, diff --git a/src/cloudflare/types/calls/__init__.py b/src/cloudflare/types/calls/__init__.py index b3889df1cbc..df3d07db98d 100644 --- a/src/cloudflare/types/calls/__init__.py +++ b/src/cloudflare/types/calls/__init__.py @@ -4,5 +4,6 @@ from .calls_app import CallsApp as CallsApp from .call_create_params import CallCreateParams as CallCreateParams +from .call_list_response import CallListResponse as CallListResponse from .call_update_params import CallUpdateParams as CallUpdateParams from .calls_app_with_secret import CallsAppWithSecret as CallsAppWithSecret diff --git a/src/cloudflare/types/calls/call_list_response.py b/src/cloudflare/types/calls/call_list_response.py new file mode 100644 index 00000000000..ff6eaf3e99f --- /dev/null +++ b/src/cloudflare/types/calls/call_list_response.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +__all__ = ["CallListResponse"] + +CallListResponse = str diff --git a/src/cloudflare/types/calls/calls_app_with_secret.py b/src/cloudflare/types/calls/calls_app_with_secret.py index 820a8080f27..41adc52c1f5 100644 --- a/src/cloudflare/types/calls/calls_app_with_secret.py +++ b/src/cloudflare/types/calls/calls_app_with_secret.py @@ -19,7 +19,7 @@ class CallsAppWithSecret(BaseModel): """A short description of Calls app, not shown to end users.""" secret: Optional[str] = None - """Bearer token to use the Calls API.""" + """Bearer token""" uid: Optional[str] = None """A Cloudflare-generated unique identifier for a item.""" diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/intel/indicator_feed_update_params.py b/src/cloudflare/types/intel/indicator_feed_update_params.py index b7af16167f6..86c871309be 100644 --- a/src/cloudflare/types/intel/indicator_feed_update_params.py +++ b/src/cloudflare/types/intel/indicator_feed_update_params.py @@ -11,7 +11,7 @@ class IndicatorFeedUpdateParams(TypedDict, total=False): account_id: Required[str] """Identifier""" - feed_description: str + description: str """The new description of the feed""" is_attributable: bool diff --git a/src/cloudflare/types/radar/http/ase_get_params.py b/src/cloudflare/types/radar/http/ase_get_params.py index 3d3336e3f44..866834c70d7 100644 --- a/src/cloudflare/types/radar/http/ase_get_params.py +++ b/src/cloudflare/types/radar/http/ase_get_params.py @@ -26,6 +26,9 @@ class AseGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/ases/bot_class_get_params.py b/src/cloudflare/types/radar/http/ases/bot_class_get_params.py index aeac71c8dc0..cd99955cee5 100644 --- a/src/cloudflare/types/radar/http/ases/bot_class_get_params.py +++ b/src/cloudflare/types/radar/http/ases/bot_class_get_params.py @@ -19,6 +19,9 @@ class BotClassGetParams(TypedDict, total=False): AS3356. """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/ases/device_type_get_params.py b/src/cloudflare/types/radar/http/ases/device_type_get_params.py index afc057a5def..4e8a4f6eef2 100644 --- a/src/cloudflare/types/radar/http/ases/device_type_get_params.py +++ b/src/cloudflare/types/radar/http/ases/device_type_get_params.py @@ -26,6 +26,9 @@ class DeviceTypeGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/ases/http_method_get_params.py b/src/cloudflare/types/radar/http/ases/http_method_get_params.py index 11533af139e..d32a5407d1f 100644 --- a/src/cloudflare/types/radar/http/ases/http_method_get_params.py +++ b/src/cloudflare/types/radar/http/ases/http_method_get_params.py @@ -26,6 +26,9 @@ class HTTPMethodGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/ases/http_protocol_get_params.py b/src/cloudflare/types/radar/http/ases/http_protocol_get_params.py index 299452c2e2a..6286b675db5 100644 --- a/src/cloudflare/types/radar/http/ases/http_protocol_get_params.py +++ b/src/cloudflare/types/radar/http/ases/http_protocol_get_params.py @@ -26,6 +26,9 @@ class HTTPProtocolGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/ases/ip_version_get_params.py b/src/cloudflare/types/radar/http/ases/ip_version_get_params.py index 57b133433b6..c39d2467c67 100644 --- a/src/cloudflare/types/radar/http/ases/ip_version_get_params.py +++ b/src/cloudflare/types/radar/http/ases/ip_version_get_params.py @@ -26,6 +26,9 @@ class IPVersionGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/ases/os_get_params.py b/src/cloudflare/types/radar/http/ases/os_get_params.py index 4e61e3dec2c..300ebd78db8 100644 --- a/src/cloudflare/types/radar/http/ases/os_get_params.py +++ b/src/cloudflare/types/radar/http/ases/os_get_params.py @@ -26,6 +26,9 @@ class OSGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/ases/tls_version_get_params.py b/src/cloudflare/types/radar/http/ases/tls_version_get_params.py index 1dcba2abdec..f5bb8d7ce65 100644 --- a/src/cloudflare/types/radar/http/ases/tls_version_get_params.py +++ b/src/cloudflare/types/radar/http/ases/tls_version_get_params.py @@ -26,6 +26,9 @@ class TLSVersionGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/location_get_params.py b/src/cloudflare/types/radar/http/location_get_params.py index 14074793bb4..7f57f7d7d12 100644 --- a/src/cloudflare/types/radar/http/location_get_params.py +++ b/src/cloudflare/types/radar/http/location_get_params.py @@ -26,6 +26,9 @@ class LocationGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/locations/bot_class_get_params.py b/src/cloudflare/types/radar/http/locations/bot_class_get_params.py index aeac71c8dc0..cd99955cee5 100644 --- a/src/cloudflare/types/radar/http/locations/bot_class_get_params.py +++ b/src/cloudflare/types/radar/http/locations/bot_class_get_params.py @@ -19,6 +19,9 @@ class BotClassGetParams(TypedDict, total=False): AS3356. """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/locations/device_type_get_params.py b/src/cloudflare/types/radar/http/locations/device_type_get_params.py index afc057a5def..4e8a4f6eef2 100644 --- a/src/cloudflare/types/radar/http/locations/device_type_get_params.py +++ b/src/cloudflare/types/radar/http/locations/device_type_get_params.py @@ -26,6 +26,9 @@ class DeviceTypeGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/locations/http_method_get_params.py b/src/cloudflare/types/radar/http/locations/http_method_get_params.py index 11533af139e..d32a5407d1f 100644 --- a/src/cloudflare/types/radar/http/locations/http_method_get_params.py +++ b/src/cloudflare/types/radar/http/locations/http_method_get_params.py @@ -26,6 +26,9 @@ class HTTPMethodGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/locations/http_protocol_get_params.py b/src/cloudflare/types/radar/http/locations/http_protocol_get_params.py index 299452c2e2a..6286b675db5 100644 --- a/src/cloudflare/types/radar/http/locations/http_protocol_get_params.py +++ b/src/cloudflare/types/radar/http/locations/http_protocol_get_params.py @@ -26,6 +26,9 @@ class HTTPProtocolGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/locations/ip_version_get_params.py b/src/cloudflare/types/radar/http/locations/ip_version_get_params.py index 57b133433b6..c39d2467c67 100644 --- a/src/cloudflare/types/radar/http/locations/ip_version_get_params.py +++ b/src/cloudflare/types/radar/http/locations/ip_version_get_params.py @@ -26,6 +26,9 @@ class IPVersionGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/locations/os_get_params.py b/src/cloudflare/types/radar/http/locations/os_get_params.py index 4e61e3dec2c..300ebd78db8 100644 --- a/src/cloudflare/types/radar/http/locations/os_get_params.py +++ b/src/cloudflare/types/radar/http/locations/os_get_params.py @@ -26,6 +26,9 @@ class OSGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/locations/tls_version_get_params.py b/src/cloudflare/types/radar/http/locations/tls_version_get_params.py index 1dcba2abdec..f5bb8d7ce65 100644 --- a/src/cloudflare/types/radar/http/locations/tls_version_get_params.py +++ b/src/cloudflare/types/radar/http/locations/tls_version_get_params.py @@ -26,6 +26,9 @@ class TLSVersionGetParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/top_browser_families_params.py b/src/cloudflare/types/radar/http/top_browser_families_params.py index 36992c88360..53bf111abab 100644 --- a/src/cloudflare/types/radar/http/top_browser_families_params.py +++ b/src/cloudflare/types/radar/http/top_browser_families_params.py @@ -26,6 +26,9 @@ class TopBrowserFamiliesParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/radar/http/top_browsers_params.py b/src/cloudflare/types/radar/http/top_browsers_params.py index 189c2149d62..1454f2d68e7 100644 --- a/src/cloudflare/types/radar/http/top_browsers_params.py +++ b/src/cloudflare/types/radar/http/top_browsers_params.py @@ -26,6 +26,9 @@ class TopBrowsersParams(TypedDict, total=False): [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). """ + browser_family: Annotated[List[Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"]], PropertyInfo(alias="browserFamily")] + """Filter for browser family.""" + continent: List[str] """Array of comma separated list of continents (alpha-2 continent codes). diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index 659dae75d71..e3d6988d4f7 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["PhaseGetResponse", "Rule"] +__all__ = [ + "PhaseGetResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index fbee22cf279..d1e457901af 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -3,10 +3,11 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict from .kind import Kind from .phase import Phase +from .logging_param import LoggingParam from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam from .block_rule_param import BlockRuleParam @@ -23,7 +24,15 @@ from .managed_challenge_rule_param import ManagedChallengeRuleParam from .set_cache_settings_rule_param import SetCacheSettingsRuleParam -__all__ = ["PhaseUpdateParams", "Rule"] +__all__ = [ + "PhaseUpdateParams", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] class PhaseUpdateParams(TypedDict, total=False): @@ -49,6 +58,58 @@ class PhaseUpdateParams(TypedDict, total=False): """The phase of the ruleset.""" +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): + cookie_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersCookieField] + """The cookie fields to log.""" + + request_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersRequestField] + """The request fields to log.""" + + response_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersResponseField] + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["log_custom_field"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsLogCustomFieldRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -65,4 +126,5 @@ class PhaseUpdateParams(TypedDict, total=False): SetConfigRuleParam, SkipRuleParam, SetCacheSettingsRuleParam, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index 8d5b1b28eac..c1054efae2b 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["PhaseUpdateResponse", "Rule"] +__all__ = [ + "PhaseUpdateResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index e4a7e29890b..0a9474bba0a 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from ..kind import Kind from ..phase import Phase +from ..logging import Logging from ..log_rule import LogRule from ...._models import BaseModel from ..skip_rule import SkipRule @@ -22,7 +24,77 @@ from ..managed_challenge_rule import ManagedChallengeRule from ..set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["VersionGetResponse", "Rule"] +__all__ = [ + "VersionGetResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index 84c2f09d8b5..e08bad9f0e5 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -71,6 +71,11 @@ "SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", "SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", "SetCacheSettingsRuleActionParametersServeStale", + "RulesetsLogCustomFieldRule", + "RulesetsLogCustomFieldRuleActionParameters", + "RulesetsLogCustomFieldRuleActionParametersCookieField", + "RulesetsLogCustomFieldRuleActionParametersRequestField", + "RulesetsLogCustomFieldRuleActionParametersResponseField", ] @@ -741,15 +746,21 @@ class SetConfigRuleActionParameters(TypedDict, total=False): bic: bool """Turn on or off Browser Integrity Check.""" - disable_apps: bool + disable_apps: Literal[True] """Turn off all active Cloudflare Apps.""" - disable_zaraz: bool + disable_rum: Literal[True] + """Turn off Real User Monitoring (RUM).""" + + disable_zaraz: Literal[True] """Turn off Zaraz.""" email_obfuscation: bool """Turn on or off Email Obfuscation.""" + fonts: bool + """Turn on or off Cloudflare Fonts.""" + hotlink_protection: bool """Turn on or off the Hotlink Protection.""" @@ -1136,6 +1147,64 @@ class SetCacheSettingsRuleActionParameters(TypedDict, total=False): """ +class RulesetsLogCustomFieldRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["log_custom_field"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsLogCustomFieldRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsLogCustomFieldRuleActionParametersCookieField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RulesetsLogCustomFieldRuleActionParametersRequestField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RulesetsLogCustomFieldRuleActionParametersResponseField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): + cookie_fields: Iterable[RulesetsLogCustomFieldRuleActionParametersCookieField] + """The cookie fields to log.""" + + request_fields: Iterable[RulesetsLogCustomFieldRuleActionParametersRequestField] + """The request fields to log.""" + + response_fields: Iterable[RulesetsLogCustomFieldRuleActionParametersResponseField] + """The response fields to log.""" + + RuleCreateParams = Union[ BlockRule, ChallengeRule, @@ -1152,4 +1221,5 @@ class SetCacheSettingsRuleActionParameters(TypedDict, total=False): SetConfigRule, SkipRule, SetCacheSettingsRule, + RulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 7fdfe28ad63..c5256f8ae0b 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["RuleCreateResponse", "Rule"] +__all__ = [ + "RuleCreateResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index a199b17fd00..073fedab4b0 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["RuleDeleteResponse", "Rule"] +__all__ = [ + "RuleDeleteResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index 63f8b2a0b50..86c8418e7c8 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -71,6 +71,11 @@ "SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", "SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", "SetCacheSettingsRuleActionParametersServeStale", + "RulesetsLogCustomFieldRule", + "RulesetsLogCustomFieldRuleActionParameters", + "RulesetsLogCustomFieldRuleActionParametersCookieField", + "RulesetsLogCustomFieldRuleActionParametersRequestField", + "RulesetsLogCustomFieldRuleActionParametersResponseField", ] @@ -780,15 +785,21 @@ class SetConfigRuleActionParameters(TypedDict, total=False): bic: bool """Turn on or off Browser Integrity Check.""" - disable_apps: bool + disable_apps: Literal[True] """Turn off all active Cloudflare Apps.""" - disable_zaraz: bool + disable_rum: Literal[True] + """Turn off Real User Monitoring (RUM).""" + + disable_zaraz: Literal[True] """Turn off Zaraz.""" email_obfuscation: bool """Turn on or off Email Obfuscation.""" + fonts: bool + """Turn on or off Cloudflare Fonts.""" + hotlink_protection: bool """Turn on or off the Hotlink Protection.""" @@ -1181,6 +1192,67 @@ class SetCacheSettingsRuleActionParameters(TypedDict, total=False): """ +class RulesetsLogCustomFieldRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["log_custom_field"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsLogCustomFieldRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsLogCustomFieldRuleActionParametersCookieField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RulesetsLogCustomFieldRuleActionParametersRequestField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RulesetsLogCustomFieldRuleActionParametersResponseField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): + cookie_fields: Iterable[RulesetsLogCustomFieldRuleActionParametersCookieField] + """The cookie fields to log.""" + + request_fields: Iterable[RulesetsLogCustomFieldRuleActionParametersRequestField] + """The request fields to log.""" + + response_fields: Iterable[RulesetsLogCustomFieldRuleActionParametersResponseField] + """The response fields to log.""" + + RuleEditParams = Union[ BlockRule, ChallengeRule, @@ -1197,4 +1269,5 @@ class SetCacheSettingsRuleActionParameters(TypedDict, total=False): SetConfigRule, SkipRule, SetCacheSettingsRule, + RulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 38c4717f2f6..88169813921 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["RuleEditResponse", "Rule"] +__all__ = [ + "RuleEditResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py index db2759e933f..6d34a46fac5 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_params.py +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -3,10 +3,11 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict from .kind import Kind from .phase import Phase +from .logging_param import LoggingParam from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam from .block_rule_param import BlockRuleParam @@ -23,7 +24,15 @@ from .managed_challenge_rule_param import ManagedChallengeRuleParam from .set_cache_settings_rule_param import SetCacheSettingsRuleParam -__all__ = ["RulesetCreateParams", "Rule"] +__all__ = [ + "RulesetCreateParams", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] class RulesetCreateParams(TypedDict, total=False): @@ -49,6 +58,58 @@ class RulesetCreateParams(TypedDict, total=False): """An informative description of the ruleset.""" +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): + cookie_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersCookieField] + """The cookie fields to log.""" + + request_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersRequestField] + """The request fields to log.""" + + response_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersResponseField] + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["log_custom_field"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsLogCustomFieldRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -65,4 +126,5 @@ class RulesetCreateParams(TypedDict, total=False): SetConfigRuleParam, SkipRuleParam, SetCacheSettingsRuleParam, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index c14817bae8e..f3694cb0358 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["RulesetCreateResponse", "Rule"] +__all__ = [ + "RulesetCreateResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index 99506e58175..e83fd9354d0 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["RulesetGetResponse", "Rule"] +__all__ = [ + "RulesetGetResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py index 4e3b08a7640..ce723859ed9 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_params.py +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -3,10 +3,11 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict from .kind import Kind from .phase import Phase +from .logging_param import LoggingParam from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam from .block_rule_param import BlockRuleParam @@ -23,7 +24,15 @@ from .managed_challenge_rule_param import ManagedChallengeRuleParam from .set_cache_settings_rule_param import SetCacheSettingsRuleParam -__all__ = ["RulesetUpdateParams", "Rule"] +__all__ = [ + "RulesetUpdateParams", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] class RulesetUpdateParams(TypedDict, total=False): @@ -49,6 +58,58 @@ class RulesetUpdateParams(TypedDict, total=False): """The phase of the ruleset.""" +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(TypedDict, total=False): + name: Required[str] + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): + cookie_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersCookieField] + """The cookie fields to log.""" + + request_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersRequestField] + """The request fields to log.""" + + response_fields: Iterable[RuleRulesetsLogCustomFieldRuleActionParametersResponseField] + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["log_custom_field"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsLogCustomFieldRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -65,4 +126,5 @@ class RulesetUpdateParams(TypedDict, total=False): SetConfigRuleParam, SkipRuleParam, SetCacheSettingsRuleParam, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index 6cc2c3f102c..cab3e8851ce 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["RulesetUpdateResponse", "Rule"] +__all__ = [ + "RulesetUpdateResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/set_config_rule.py b/src/cloudflare/types/rulesets/set_config_rule.py index 8d135f95608..8f09bbe8b99 100644 --- a/src/cloudflare/types/rulesets/set_config_rule.py +++ b/src/cloudflare/types/rulesets/set_config_rule.py @@ -31,15 +31,21 @@ class ActionParameters(BaseModel): bic: Optional[bool] = None """Turn on or off Browser Integrity Check.""" - disable_apps: Optional[bool] = None + disable_apps: Optional[Literal[True]] = None """Turn off all active Cloudflare Apps.""" - disable_zaraz: Optional[bool] = None + disable_rum: Optional[Literal[True]] = None + """Turn off Real User Monitoring (RUM).""" + + disable_zaraz: Optional[Literal[True]] = None """Turn off Zaraz.""" email_obfuscation: Optional[bool] = None """Turn on or off Email Obfuscation.""" + fonts: Optional[bool] = None + """Turn on or off Cloudflare Fonts.""" + hotlink_protection: Optional[bool] = None """Turn on or off the Hotlink Protection.""" diff --git a/src/cloudflare/types/rulesets/set_config_rule_param.py b/src/cloudflare/types/rulesets/set_config_rule_param.py index e90a1670126..09ccc180461 100644 --- a/src/cloudflare/types/rulesets/set_config_rule_param.py +++ b/src/cloudflare/types/rulesets/set_config_rule_param.py @@ -30,15 +30,21 @@ class ActionParameters(TypedDict, total=False): bic: bool """Turn on or off Browser Integrity Check.""" - disable_apps: bool + disable_apps: Literal[True] """Turn off all active Cloudflare Apps.""" - disable_zaraz: bool + disable_rum: Literal[True] + """Turn off Real User Monitoring (RUM).""" + + disable_zaraz: Literal[True] """Turn off Zaraz.""" email_obfuscation: bool """Turn on or off Email Obfuscation.""" + fonts: bool + """Turn on or off Cloudflare Fonts.""" + hotlink_protection: bool """Turn on or off the Hotlink Protection.""" diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index cb03724ddeb..b90e376ea65 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .kind import Kind from .phase import Phase +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -22,7 +24,77 @@ from .managed_challenge_rule import ManagedChallengeRule from .set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["VersionGetResponse", "Rule"] +__all__ = [ + "VersionGetResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index f1aa698a4af..fc90c1d1689 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -2,9 +2,11 @@ from typing import List, Union, Optional from datetime import datetime +from typing_extensions import Literal from ..kind import Kind from ..phase import Phase +from ..logging import Logging from ..log_rule import LogRule from ...._models import BaseModel from ..skip_rule import SkipRule @@ -22,7 +24,77 @@ from ..managed_challenge_rule import ManagedChallengeRule from ..set_cache_settings_rule import SetCacheSettingsRule -__all__ = ["ByTagGetResponse", "Rule"] +__all__ = [ + "ByTagGetResponse", + "Rule", + "RuleRulesetsLogCustomFieldRule", + "RuleRulesetsLogCustomFieldRuleActionParameters", + "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", + "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", + "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", +] + + +class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersRequestField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParametersResponseField(BaseModel): + name: str + """The name of the field.""" + + +class RuleRulesetsLogCustomFieldRuleActionParameters(BaseModel): + cookie_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersCookieField]] = None + """The cookie fields to log.""" + + request_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersRequestField]] = None + """The request fields to log.""" + + response_fields: Optional[List[RuleRulesetsLogCustomFieldRuleActionParametersResponseField]] = None + """The response fields to log.""" + + +class RuleRulesetsLogCustomFieldRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log_custom_field"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsLogCustomFieldRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + Rule = Union[ BlockRule, @@ -40,6 +112,7 @@ SetConfigRule, SkipRule, SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, ] diff --git a/src/cloudflare/types/zero_trust/access/__init__.py b/src/cloudflare/types/zero_trust/access/__init__.py index eca299d4f71..fb96bfc62bc 100644 --- a/src/cloudflare/types/zero_trust/access/__init__.py +++ b/src/cloudflare/types/zero_trust/access/__init__.py @@ -5,7 +5,6 @@ from .tag import Tag as Tag from .bookmark import Bookmark as Bookmark from .access_user import AccessUser as AccessUser -from .application import Application as Application from .certificate import Certificate as Certificate from .custom_page import CustomPage as CustomPage from .allowed_idps import AllowedIdPs as AllowedIdPs @@ -38,15 +37,19 @@ from .bookmark_create_params import BookmarkCreateParams as BookmarkCreateParams from .bookmark_update_params import BookmarkUpdateParams as BookmarkUpdateParams from .saas_app_name_id_format import SaaSAppNameIDFormat as SaaSAppNameIDFormat +from .application_get_response import ApplicationGetResponse as ApplicationGetResponse from .bookmark_delete_response import BookmarkDeleteResponse as BookmarkDeleteResponse from .custom_page_without_html import CustomPageWithoutHTML as CustomPageWithoutHTML from .application_create_params import ApplicationCreateParams as ApplicationCreateParams +from .application_list_response import ApplicationListResponse as ApplicationListResponse from .application_update_params import ApplicationUpdateParams as ApplicationUpdateParams from .certificate_create_params import CertificateCreateParams as CertificateCreateParams from .certificate_update_params import CertificateUpdateParams as CertificateUpdateParams from .custom_page_create_params import CustomPageCreateParams as CustomPageCreateParams from .custom_page_update_params import CustomPageUpdateParams as CustomPageUpdateParams +from .application_create_response import ApplicationCreateResponse as ApplicationCreateResponse from .application_delete_response import ApplicationDeleteResponse as ApplicationDeleteResponse +from .application_update_response import ApplicationUpdateResponse as ApplicationUpdateResponse from .certificate_delete_response import CertificateDeleteResponse as CertificateDeleteResponse from .custom_page_delete_response import CustomPageDeleteResponse as CustomPageDeleteResponse from .service_token_create_params import ServiceTokenCreateParams as ServiceTokenCreateParams diff --git a/src/cloudflare/types/zero_trust/access/application.py b/src/cloudflare/types/zero_trust/access/application.py deleted file mode 100644 index 433fd75e505..00000000000 --- a/src/cloudflare/types/zero_trust/access/application.py +++ /dev/null @@ -1,709 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, List, Union, Optional -from datetime import datetime -from typing_extensions import Literal - -from ...._models import BaseModel -from .allowed_idps import AllowedIdPs -from .cors_headers import CORSHeaders -from .saml_saas_app import SAMLSaaSApp -from .application_type import ApplicationType -from .self_hosted_domains import SelfHostedDomains - -__all__ = [ - "Application", - "SelfHostedApplication", - "SaaSApplication", - "SaaSApplicationSaaSApp", - "SaaSApplicationSaaSAppAccessOIDCSaaSApp", - "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", - "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", - "BrowserSSHApplication", - "BrowserVncApplication", - "AppLauncherApplication", - "DeviceEnrollmentPermissionsApplication", - "BrowserIsolationPermissionsApplication", - "BookmarkApplication", -] - - -class SelfHostedApplication(BaseModel): - domain: str - """The primary hostname and path that Access will secure. - - If the app is visible in the App Launcher dashboard, this is the domain that - will be displayed. - """ - - type: str - """The application type.""" - - id: Optional[str] = None - """UUID""" - - allow_authenticate_via_warp: Optional[bool] = None - """ - When set to true, users can authenticate to this application using their WARP - session. When set to false this application will always require direct IdP - authentication. This setting always overrides the organization setting for WARP - authentication. - """ - - allowed_idps: Optional[List[AllowedIdPs]] = None - """The identity providers your users can select when connecting to this - application. - - Defaults to all IdPs configured in your account. - """ - - app_launcher_visible: Optional[bool] = None - """Displays the application in the App Launcher.""" - - aud: Optional[str] = None - """Audience tag.""" - - auto_redirect_to_identity: Optional[bool] = None - """When set to `true`, users skip the identity provider selection step during - login. - - You must specify only one identity provider in allowed_idps. - """ - - cors_headers: Optional[CORSHeaders] = None - - created_at: Optional[datetime] = None - - custom_deny_message: Optional[str] = None - """ - The custom error message shown to a user when they are denied access to the - application. - """ - - custom_deny_url: Optional[str] = None - """ - The custom URL a user is redirected to when they are denied access to the - application when failing identity-based rules. - """ - - custom_non_identity_deny_url: Optional[str] = None - """ - The custom URL a user is redirected to when they are denied access to the - application when failing non-identity rules. - """ - - custom_pages: Optional[List[str]] = None - """The custom pages that will be displayed when applicable for this application""" - - enable_binding_cookie: Optional[bool] = None - """ - Enables the binding cookie, which increases security against compromised - authorization tokens and CSRF attacks. - """ - - http_only_cookie_attribute: Optional[bool] = None - """ - Enables the HttpOnly cookie attribute, which increases security against XSS - attacks. - """ - - logo_url: Optional[str] = None - """The image URL for the logo shown in the App Launcher dashboard.""" - - name: Optional[str] = None - """The name of the application.""" - - options_preflight_bypass: Optional[bool] = None - """ - Allows options preflight requests to bypass Access authentication and go - directly to the origin. Cannot turn on if cors_headers is set. - """ - - path_cookie_attribute: Optional[bool] = None - """Enables cookie paths to scope an application's JWT to the application path. - - If disabled, the JWT will scope to the hostname by default - """ - - same_site_cookie_attribute: Optional[str] = None - """ - Sets the SameSite cookie setting, which provides increased security against CSRF - attacks. - """ - - self_hosted_domains: Optional[List[SelfHostedDomains]] = None - """List of domains that Access will secure.""" - - service_auth_401_redirect: Optional[bool] = None - """Returns a 401 status code when the request is blocked by a Service Auth policy.""" - - session_duration: Optional[str] = None - """The amount of time that tokens issued for this application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - skip_interstitial: Optional[bool] = None - """Enables automatic authentication through cloudflared.""" - - tags: Optional[List[str]] = None - """The tags you want assigned to an application. - - Tags are used to filter applications in the App Launcher dashboard. - """ - - updated_at: Optional[datetime] = None - - -class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): - name: Optional[str] = None - """The name of the IdP claim.""" - - -class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): - name: Optional[str] = None - """The name of the claim.""" - - name_by_idp: Optional[Dict[str, str]] = None - """A mapping from IdP ID to claim name.""" - - required: Optional[bool] = None - """If the claim is required when building an OIDC token.""" - - scope: Optional[Literal["groups", "profile", "email", "openid"]] = None - """The scope of the claim.""" - - source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None - - -class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): - app_launcher_url: Optional[str] = None - """The URL where this applications tile redirects users""" - - auth_type: Optional[Literal["saml", "oidc"]] = None - """Identifier of the authentication protocol used for the saas app. - - Required for OIDC. - """ - - client_id: Optional[str] = None - """The application client id""" - - client_secret: Optional[str] = None - """The application client secret, only returned on POST request.""" - - created_at: Optional[datetime] = None - - custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None - - grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce"]]] = None - """The OIDC flows supported by this application""" - - group_filter_regex: Optional[str] = None - """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" - - public_key: Optional[str] = None - """The Access public certificate that will be used to verify your identity.""" - - redirect_uris: Optional[List[str]] = None - """ - The permitted URL's for Cloudflare to return Authorization codes and Access/ID - tokens - """ - - scopes: Optional[List[Literal["openid", "groups", "email", "profile"]]] = None - """Define the user information shared with access""" - - updated_at: Optional[datetime] = None - - -SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] - - -class SaaSApplication(BaseModel): - id: Optional[str] = None - """UUID""" - - allowed_idps: Optional[List[AllowedIdPs]] = None - """The identity providers your users can select when connecting to this - application. - - Defaults to all IdPs configured in your account. - """ - - app_launcher_visible: Optional[bool] = None - """Displays the application in the App Launcher.""" - - aud: Optional[str] = None - """Audience tag.""" - - auto_redirect_to_identity: Optional[bool] = None - """When set to `true`, users skip the identity provider selection step during - login. - - You must specify only one identity provider in allowed_idps. - """ - - created_at: Optional[datetime] = None - - custom_pages: Optional[List[str]] = None - """The custom pages that will be displayed when applicable for this application""" - - logo_url: Optional[str] = None - """The image URL for the logo shown in the App Launcher dashboard.""" - - name: Optional[str] = None - """The name of the application.""" - - saas_app: Optional[SaaSApplicationSaaSApp] = None - - tags: Optional[List[str]] = None - """The tags you want assigned to an application. - - Tags are used to filter applications in the App Launcher dashboard. - """ - - type: Optional[str] = None - """The application type.""" - - updated_at: Optional[datetime] = None - - -class BrowserSSHApplication(BaseModel): - domain: str - """The primary hostname and path that Access will secure. - - If the app is visible in the App Launcher dashboard, this is the domain that - will be displayed. - """ - - type: str - """The application type.""" - - id: Optional[str] = None - """UUID""" - - allow_authenticate_via_warp: Optional[bool] = None - """ - When set to true, users can authenticate to this application using their WARP - session. When set to false this application will always require direct IdP - authentication. This setting always overrides the organization setting for WARP - authentication. - """ - - allowed_idps: Optional[List[AllowedIdPs]] = None - """The identity providers your users can select when connecting to this - application. - - Defaults to all IdPs configured in your account. - """ - - app_launcher_visible: Optional[bool] = None - """Displays the application in the App Launcher.""" - - aud: Optional[str] = None - """Audience tag.""" - - auto_redirect_to_identity: Optional[bool] = None - """When set to `true`, users skip the identity provider selection step during - login. - - You must specify only one identity provider in allowed_idps. - """ - - cors_headers: Optional[CORSHeaders] = None - - created_at: Optional[datetime] = None - - custom_deny_message: Optional[str] = None - """ - The custom error message shown to a user when they are denied access to the - application. - """ - - custom_deny_url: Optional[str] = None - """ - The custom URL a user is redirected to when they are denied access to the - application when failing identity-based rules. - """ - - custom_non_identity_deny_url: Optional[str] = None - """ - The custom URL a user is redirected to when they are denied access to the - application when failing non-identity rules. - """ - - custom_pages: Optional[List[str]] = None - """The custom pages that will be displayed when applicable for this application""" - - enable_binding_cookie: Optional[bool] = None - """ - Enables the binding cookie, which increases security against compromised - authorization tokens and CSRF attacks. - """ - - http_only_cookie_attribute: Optional[bool] = None - """ - Enables the HttpOnly cookie attribute, which increases security against XSS - attacks. - """ - - logo_url: Optional[str] = None - """The image URL for the logo shown in the App Launcher dashboard.""" - - name: Optional[str] = None - """The name of the application.""" - - options_preflight_bypass: Optional[bool] = None - """ - Allows options preflight requests to bypass Access authentication and go - directly to the origin. Cannot turn on if cors_headers is set. - """ - - path_cookie_attribute: Optional[bool] = None - """Enables cookie paths to scope an application's JWT to the application path. - - If disabled, the JWT will scope to the hostname by default - """ - - same_site_cookie_attribute: Optional[str] = None - """ - Sets the SameSite cookie setting, which provides increased security against CSRF - attacks. - """ - - self_hosted_domains: Optional[List[SelfHostedDomains]] = None - """List of domains that Access will secure.""" - - service_auth_401_redirect: Optional[bool] = None - """Returns a 401 status code when the request is blocked by a Service Auth policy.""" - - session_duration: Optional[str] = None - """The amount of time that tokens issued for this application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - skip_interstitial: Optional[bool] = None - """Enables automatic authentication through cloudflared.""" - - tags: Optional[List[str]] = None - """The tags you want assigned to an application. - - Tags are used to filter applications in the App Launcher dashboard. - """ - - updated_at: Optional[datetime] = None - - -class BrowserVncApplication(BaseModel): - domain: str - """The primary hostname and path that Access will secure. - - If the app is visible in the App Launcher dashboard, this is the domain that - will be displayed. - """ - - type: str - """The application type.""" - - id: Optional[str] = None - """UUID""" - - allow_authenticate_via_warp: Optional[bool] = None - """ - When set to true, users can authenticate to this application using their WARP - session. When set to false this application will always require direct IdP - authentication. This setting always overrides the organization setting for WARP - authentication. - """ - - allowed_idps: Optional[List[AllowedIdPs]] = None - """The identity providers your users can select when connecting to this - application. - - Defaults to all IdPs configured in your account. - """ - - app_launcher_visible: Optional[bool] = None - """Displays the application in the App Launcher.""" - - aud: Optional[str] = None - """Audience tag.""" - - auto_redirect_to_identity: Optional[bool] = None - """When set to `true`, users skip the identity provider selection step during - login. - - You must specify only one identity provider in allowed_idps. - """ - - cors_headers: Optional[CORSHeaders] = None - - created_at: Optional[datetime] = None - - custom_deny_message: Optional[str] = None - """ - The custom error message shown to a user when they are denied access to the - application. - """ - - custom_deny_url: Optional[str] = None - """ - The custom URL a user is redirected to when they are denied access to the - application when failing identity-based rules. - """ - - custom_non_identity_deny_url: Optional[str] = None - """ - The custom URL a user is redirected to when they are denied access to the - application when failing non-identity rules. - """ - - custom_pages: Optional[List[str]] = None - """The custom pages that will be displayed when applicable for this application""" - - enable_binding_cookie: Optional[bool] = None - """ - Enables the binding cookie, which increases security against compromised - authorization tokens and CSRF attacks. - """ - - http_only_cookie_attribute: Optional[bool] = None - """ - Enables the HttpOnly cookie attribute, which increases security against XSS - attacks. - """ - - logo_url: Optional[str] = None - """The image URL for the logo shown in the App Launcher dashboard.""" - - name: Optional[str] = None - """The name of the application.""" - - options_preflight_bypass: Optional[bool] = None - """ - Allows options preflight requests to bypass Access authentication and go - directly to the origin. Cannot turn on if cors_headers is set. - """ - - path_cookie_attribute: Optional[bool] = None - """Enables cookie paths to scope an application's JWT to the application path. - - If disabled, the JWT will scope to the hostname by default - """ - - same_site_cookie_attribute: Optional[str] = None - """ - Sets the SameSite cookie setting, which provides increased security against CSRF - attacks. - """ - - self_hosted_domains: Optional[List[SelfHostedDomains]] = None - """List of domains that Access will secure.""" - - service_auth_401_redirect: Optional[bool] = None - """Returns a 401 status code when the request is blocked by a Service Auth policy.""" - - session_duration: Optional[str] = None - """The amount of time that tokens issued for this application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - skip_interstitial: Optional[bool] = None - """Enables automatic authentication through cloudflared.""" - - tags: Optional[List[str]] = None - """The tags you want assigned to an application. - - Tags are used to filter applications in the App Launcher dashboard. - """ - - updated_at: Optional[datetime] = None - - -class AppLauncherApplication(BaseModel): - type: ApplicationType - """The application type.""" - - id: Optional[str] = None - """UUID""" - - allowed_idps: Optional[List[AllowedIdPs]] = None - """The identity providers your users can select when connecting to this - application. - - Defaults to all IdPs configured in your account. - """ - - aud: Optional[str] = None - """Audience tag.""" - - auto_redirect_to_identity: Optional[bool] = None - """When set to `true`, users skip the identity provider selection step during - login. - - You must specify only one identity provider in allowed_idps. - """ - - created_at: Optional[datetime] = None - - domain: Optional[str] = None - """The primary hostname and path that Access will secure. - - If the app is visible in the App Launcher dashboard, this is the domain that - will be displayed. - """ - - name: Optional[str] = None - """The name of the application.""" - - session_duration: Optional[str] = None - """The amount of time that tokens issued for this application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - updated_at: Optional[datetime] = None - - -class DeviceEnrollmentPermissionsApplication(BaseModel): - type: ApplicationType - """The application type.""" - - id: Optional[str] = None - """UUID""" - - allowed_idps: Optional[List[AllowedIdPs]] = None - """The identity providers your users can select when connecting to this - application. - - Defaults to all IdPs configured in your account. - """ - - aud: Optional[str] = None - """Audience tag.""" - - auto_redirect_to_identity: Optional[bool] = None - """When set to `true`, users skip the identity provider selection step during - login. - - You must specify only one identity provider in allowed_idps. - """ - - created_at: Optional[datetime] = None - - domain: Optional[str] = None - """The primary hostname and path that Access will secure. - - If the app is visible in the App Launcher dashboard, this is the domain that - will be displayed. - """ - - name: Optional[str] = None - """The name of the application.""" - - session_duration: Optional[str] = None - """The amount of time that tokens issued for this application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - updated_at: Optional[datetime] = None - - -class BrowserIsolationPermissionsApplication(BaseModel): - type: ApplicationType - """The application type.""" - - id: Optional[str] = None - """UUID""" - - allowed_idps: Optional[List[AllowedIdPs]] = None - """The identity providers your users can select when connecting to this - application. - - Defaults to all IdPs configured in your account. - """ - - aud: Optional[str] = None - """Audience tag.""" - - auto_redirect_to_identity: Optional[bool] = None - """When set to `true`, users skip the identity provider selection step during - login. - - You must specify only one identity provider in allowed_idps. - """ - - created_at: Optional[datetime] = None - - domain: Optional[str] = None - """The primary hostname and path that Access will secure. - - If the app is visible in the App Launcher dashboard, this is the domain that - will be displayed. - """ - - name: Optional[str] = None - """The name of the application.""" - - session_duration: Optional[str] = None - """The amount of time that tokens issued for this application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - updated_at: Optional[datetime] = None - - -class BookmarkApplication(BaseModel): - id: Optional[str] = None - """UUID""" - - app_launcher_visible: Optional[bool] = None - """Displays the application in the App Launcher.""" - - aud: Optional[str] = None - """Audience tag.""" - - created_at: Optional[datetime] = None - - domain: Optional[str] = None - """The URL or domain of the bookmark.""" - - logo_url: Optional[str] = None - """The image URL for the logo shown in the App Launcher dashboard.""" - - name: Optional[str] = None - """The name of the application.""" - - tags: Optional[List[str]] = None - """The tags you want assigned to an application. - - Tags are used to filter applications in the App Launcher dashboard. - """ - - type: Optional[str] = None - """The application type.""" - - updated_at: Optional[datetime] = None - - -Application = Union[ - SelfHostedApplication, - SaaSApplication, - BrowserSSHApplication, - BrowserVncApplication, - AppLauncherApplication, - DeviceEnrollmentPermissionsApplication, - BrowserIsolationPermissionsApplication, - BookmarkApplication, -] diff --git a/src/cloudflare/types/zero_trust/access/application_create_params.py b/src/cloudflare/types/zero_trust/access/application_create_params.py index d8f91af3899..db68d8ff416 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_params.py +++ b/src/cloudflare/types/zero_trust/access/application_create_params.py @@ -2,29 +2,53 @@ from __future__ import annotations -from typing import Dict, List, Union +from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict from .allowed_idps import AllowedIdPs from .application_type import ApplicationType +from ..access_rule_param import AccessRuleParam from .cors_headers_param import CORSHeadersParam from .saml_saas_app_param import SAMLSaaSAppParam from .self_hosted_domains import SelfHostedDomains +from .applications.approval_group_param import ApprovalGroupParam __all__ = [ "ApplicationCreateParams", "SelfHostedApplication", + "SelfHostedApplicationPolicy", + "SelfHostedApplicationPolicyAccessAppPolicyLink", + "SelfHostedApplicationPolicyUnionMember2", "SaaSApplication", + "SaaSApplicationPolicy", + "SaaSApplicationPolicyAccessAppPolicyLink", + "SaaSApplicationPolicyUnionMember2", "SaaSApplicationSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", "BrowserSSHApplication", + "BrowserSSHApplicationPolicy", + "BrowserSSHApplicationPolicyAccessAppPolicyLink", + "BrowserSSHApplicationPolicyUnionMember2", "BrowserVncApplication", + "BrowserVncApplicationPolicy", + "BrowserVncApplicationPolicyAccessAppPolicyLink", + "BrowserVncApplicationPolicyUnionMember2", "AppLauncherApplication", + "AppLauncherApplicationPolicy", + "AppLauncherApplicationPolicyAccessAppPolicyLink", + "AppLauncherApplicationPolicyUnionMember2", "DeviceEnrollmentPermissionsApplication", + "DeviceEnrollmentPermissionsApplicationPolicy", + "DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink", + "DeviceEnrollmentPermissionsApplicationPolicyUnionMember2", "BrowserIsolationPermissionsApplication", - "BookmarkApplication", + "BrowserIsolationPermissionsApplicationPolicy", + "BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink", + "BrowserIsolationPermissionsApplicationPolicyUnionMember2", + "AccessBookmarkProps", ] @@ -123,6 +147,13 @@ class SelfHostedApplication(TypedDict, total=False): If disabled, the JWT will scope to the hostname by default """ + policies: List[SelfHostedApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + same_site_cookie_attribute: str """ Sets the SameSite cookie setting, which provides increased security against CSRF @@ -152,6 +183,86 @@ class SelfHostedApplication(TypedDict, total=False): """ +class SelfHostedApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +SelfHostedApplicationPolicy = Union[ + SelfHostedApplicationPolicyAccessAppPolicyLink, str, SelfHostedApplicationPolicyUnionMember2 +] + + class SaaSApplication(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -185,6 +296,13 @@ class SaaSApplication(TypedDict, total=False): name: str """The name of the application.""" + policies: List[SaaSApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + saas_app: SaaSApplicationSaaSApp tags: List[str] @@ -197,6 +315,84 @@ class SaaSApplication(TypedDict, total=False): """The application type.""" +class SaaSApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class SaaSApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +SaaSApplicationPolicy = Union[SaaSApplicationPolicyAccessAppPolicyLink, str, SaaSApplicationPolicyUnionMember2] + + class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(TypedDict, total=False): name: str """The name of the IdP claim.""" @@ -218,7 +414,21 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(TypedDict, total=False source: SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource +class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(TypedDict, total=False): + lifetime: str + """How long a refresh token will be valid for after creation. + + Valid units are m,h,d. Must be longer than 1m. + """ + + class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): + allow_pkce_without_client_secret: bool + """ + If client secret should be required on the token endpoint when + authorization_code_with_pkce grant is used. + """ + app_launcher_url: str """The URL where this applications tile redirects users""" @@ -236,7 +446,7 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): custom_claims: SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims - grant_types: List[Literal["authorization_code", "authorization_code_with_pkce"]] + grant_types: List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]] """The OIDC flows supported by this application""" group_filter_regex: str @@ -251,8 +461,13 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): tokens """ + refresh_token_options: SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions + scopes: List[Literal["openid", "groups", "email", "profile"]] - """Define the user information shared with access""" + """ + Define the user information shared with access, "offline_access" scope will be + automatically enabled if refresh tokens are enabled + """ SaaSApplicationSaaSApp = Union[SAMLSaaSAppParam, SaaSApplicationSaaSAppAccessOIDCSaaSApp] @@ -353,6 +568,13 @@ class BrowserSSHApplication(TypedDict, total=False): If disabled, the JWT will scope to the hostname by default """ + policies: List[BrowserSSHApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + same_site_cookie_attribute: str """ Sets the SameSite cookie setting, which provides increased security against CSRF @@ -382,6 +604,86 @@ class BrowserSSHApplication(TypedDict, total=False): """ +class BrowserSSHApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +BrowserSSHApplicationPolicy = Union[ + BrowserSSHApplicationPolicyAccessAppPolicyLink, str, BrowserSSHApplicationPolicyUnionMember2 +] + + class BrowserVncApplication(TypedDict, total=False): domain: Required[str] """The primary hostname and path that Access will secure. @@ -477,6 +779,13 @@ class BrowserVncApplication(TypedDict, total=False): If disabled, the JWT will scope to the hostname by default """ + policies: List[BrowserVncApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + same_site_cookie_attribute: str """ Sets the SameSite cookie setting, which provides increased security against CSRF @@ -506,6 +815,86 @@ class BrowserVncApplication(TypedDict, total=False): """ +class BrowserVncApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +BrowserVncApplicationPolicy = Union[ + BrowserVncApplicationPolicyAccessAppPolicyLink, str, BrowserVncApplicationPolicyUnionMember2 +] + + class AppLauncherApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -530,6 +919,13 @@ class AppLauncherApplication(TypedDict, total=False): You must specify only one identity provider in allowed_idps. """ + policies: List[AppLauncherApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -538,6 +934,86 @@ class AppLauncherApplication(TypedDict, total=False): """ +class AppLauncherApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +AppLauncherApplicationPolicy = Union[ + AppLauncherApplicationPolicyAccessAppPolicyLink, str, AppLauncherApplicationPolicyUnionMember2 +] + + class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -562,6 +1038,13 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): You must specify only one identity provider in allowed_idps. """ + policies: List[DeviceEnrollmentPermissionsApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -570,6 +1053,88 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): """ +class DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +DeviceEnrollmentPermissionsApplicationPolicy = Union[ + DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink, + str, + DeviceEnrollmentPermissionsApplicationPolicyUnionMember2, +] + + class BrowserIsolationPermissionsApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -594,6 +1159,13 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): You must specify only one identity provider in allowed_idps. """ + policies: List[BrowserIsolationPermissionsApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -602,7 +1174,89 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): """ -class BookmarkApplication(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +BrowserIsolationPermissionsApplicationPolicy = Union[ + BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink, + str, + BrowserIsolationPermissionsApplicationPolicyUnionMember2, +] + + +class AccessBookmarkProps(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -639,5 +1293,5 @@ class BookmarkApplication(TypedDict, total=False): AppLauncherApplication, DeviceEnrollmentPermissionsApplication, BrowserIsolationPermissionsApplication, - BookmarkApplication, + AccessBookmarkProps, ] diff --git a/src/cloudflare/types/zero_trust/access/application_create_response.py b/src/cloudflare/types/zero_trust/access/application_create_response.py new file mode 100644 index 00000000000..08f080c6de1 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/application_create_response.py @@ -0,0 +1,2304 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ..access_rule import AccessRule +from .allowed_idps import AllowedIdPs +from .cors_headers import CORSHeaders +from .saml_saas_app import SAMLSaaSApp +from .application_type import ApplicationType +from .self_hosted_domains import SelfHostedDomains +from .applications.approval_group import ApprovalGroup + +__all__ = [ + "ApplicationCreateResponse", + "SelfHostedApplication", + "SelfHostedApplicationPolicy", + "SelfHostedApplicationScimConfig", + "SelfHostedApplicationScimConfigAuthentication", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SelfHostedApplicationScimConfigMapping", + "SelfHostedApplicationScimConfigMappingOperations", + "SaaSApplication", + "SaaSApplicationPolicy", + "SaaSApplicationSaaSApp", + "SaaSApplicationSaaSAppAccessOIDCSaaSApp", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", + "SaaSApplicationScimConfig", + "SaaSApplicationScimConfigAuthentication", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SaaSApplicationScimConfigMapping", + "SaaSApplicationScimConfigMappingOperations", + "BrowserSSHApplication", + "BrowserSSHApplicationPolicy", + "BrowserSSHApplicationScimConfig", + "BrowserSSHApplicationScimConfigAuthentication", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserSSHApplicationScimConfigMapping", + "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserVncApplication", + "BrowserVncApplicationPolicy", + "BrowserVncApplicationScimConfig", + "BrowserVncApplicationScimConfigAuthentication", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserVncApplicationScimConfigMapping", + "BrowserVncApplicationScimConfigMappingOperations", + "AppLauncherApplication", + "AppLauncherApplicationPolicy", + "AppLauncherApplicationScimConfig", + "AppLauncherApplicationScimConfigAuthentication", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "AppLauncherApplicationScimConfigMapping", + "AppLauncherApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplication", + "DeviceEnrollmentPermissionsApplicationPolicy", + "DeviceEnrollmentPermissionsApplicationScimConfig", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationScimConfigMapping", + "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplication", + "BrowserIsolationPermissionsApplicationPolicy", + "BrowserIsolationPermissionsApplicationScimConfig", + "BrowserIsolationPermissionsApplicationScimConfigAuthentication", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationScimConfigMapping", + "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BookmarkApplication", + "BookmarkApplicationScimConfig", + "BookmarkApplicationScimConfigAuthentication", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BookmarkApplicationScimConfigMapping", + "BookmarkApplicationScimConfigMappingOperations", +] + + +class SelfHostedApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SelfHostedApplicationScimConfigAuthentication = Union[ + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SelfHostedApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SelfHostedApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[SelfHostedApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SelfHostedApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[SelfHostedApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[SelfHostedApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class SelfHostedApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[SelfHostedApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[SelfHostedApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class SaaSApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): + name: Optional[str] = None + """The name of the IdP claim.""" + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): + name: Optional[str] = None + """The name of the claim.""" + + name_by_idp: Optional[Dict[str, str]] = None + """A mapping from IdP ID to claim name.""" + + required: Optional[bool] = None + """If the claim is required when building an OIDC token.""" + + scope: Optional[Literal["groups", "profile", "email", "openid"]] = None + """The scope of the claim.""" + + source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): + lifetime: Optional[str] = None + """How long a refresh token will be valid for after creation. + + Valid units are m,h,d. Must be longer than 1m. + """ + + +class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): + allow_pkce_without_client_secret: Optional[bool] = None + """ + If client secret should be required on the token endpoint when + authorization_code_with_pkce grant is used. + """ + + app_launcher_url: Optional[str] = None + """The URL where this applications tile redirects users""" + + auth_type: Optional[Literal["saml", "oidc"]] = None + """Identifier of the authentication protocol used for the saas app. + + Required for OIDC. + """ + + client_id: Optional[str] = None + """The application client id""" + + client_secret: Optional[str] = None + """The application client secret, only returned on POST request.""" + + created_at: Optional[datetime] = None + + custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None + + grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]]] = None + """The OIDC flows supported by this application""" + + group_filter_regex: Optional[str] = None + """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + + public_key: Optional[str] = None + """The Access public certificate that will be used to verify your identity.""" + + redirect_uris: Optional[List[str]] = None + """ + The permitted URL's for Cloudflare to return Authorization codes and Access/ID + tokens + """ + + refresh_token_options: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions] = None + + scopes: Optional[List[Literal["openid", "groups", "email", "profile"]]] = None + """ + Define the user information shared with access, "offline_access" scope will be + automatically enabled if refresh tokens are enabled + """ + + updated_at: Optional[datetime] = None + + +SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SaaSApplicationScimConfigAuthentication = Union[ + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SaaSApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SaaSApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[SaaSApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SaaSApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[SaaSApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[SaaSApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class SaaSApplication(BaseModel): + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[SaaSApplicationPolicy]] = None + + saas_app: Optional[SaaSApplicationSaaSApp] = None + + scim_config: Optional[SaaSApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + type: Optional[str] = None + """The application type.""" + + updated_at: Optional[datetime] = None + + +class BrowserSSHApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserSSHApplicationScimConfigAuthentication = Union[ + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserSSHApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserSSHApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserSSHApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserSSHApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserSSHApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserSSHApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[BrowserSSHApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[BrowserSSHApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class BrowserVncApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserVncApplicationScimConfigAuthentication = Union[ + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserVncApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserVncApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserVncApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserVncApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserVncApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserVncApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserVncApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[BrowserVncApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[BrowserVncApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class AppLauncherApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +AppLauncherApplicationScimConfigAuthentication = Union[ + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class AppLauncherApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class AppLauncherApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[AppLauncherApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class AppLauncherApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[AppLauncherApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[AppLauncherApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class AppLauncherApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[AppLauncherApplicationPolicy]] = None + + scim_config: Optional[AppLauncherApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + BaseModel +): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[DeviceEnrollmentPermissionsApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[DeviceEnrollmentPermissionsApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class DeviceEnrollmentPermissionsApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[DeviceEnrollmentPermissionsApplicationPolicy]] = None + + scim_config: Optional[DeviceEnrollmentPermissionsApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserIsolationPermissionsApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + BaseModel +): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserIsolationPermissionsApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserIsolationPermissionsApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserIsolationPermissionsApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserIsolationPermissionsApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[BrowserIsolationPermissionsApplicationPolicy]] = None + + scim_config: Optional[BrowserIsolationPermissionsApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BookmarkApplicationScimConfigAuthentication = Union[ + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BookmarkApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BookmarkApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BookmarkApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BookmarkApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BookmarkApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BookmarkApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BookmarkApplication(BaseModel): + id: Optional[str] = None + """UUID""" + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The URL or domain of the bookmark.""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + scim_config: Optional[BookmarkApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + type: Optional[str] = None + """The application type.""" + + updated_at: Optional[datetime] = None + + +ApplicationCreateResponse = Union[ + SelfHostedApplication, + SaaSApplication, + BrowserSSHApplication, + BrowserVncApplication, + AppLauncherApplication, + DeviceEnrollmentPermissionsApplication, + BrowserIsolationPermissionsApplication, + BookmarkApplication, +] diff --git a/src/cloudflare/types/zero_trust/access/application_get_response.py b/src/cloudflare/types/zero_trust/access/application_get_response.py new file mode 100644 index 00000000000..03f90736eab --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/application_get_response.py @@ -0,0 +1,2304 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ..access_rule import AccessRule +from .allowed_idps import AllowedIdPs +from .cors_headers import CORSHeaders +from .saml_saas_app import SAMLSaaSApp +from .application_type import ApplicationType +from .self_hosted_domains import SelfHostedDomains +from .applications.approval_group import ApprovalGroup + +__all__ = [ + "ApplicationGetResponse", + "SelfHostedApplication", + "SelfHostedApplicationPolicy", + "SelfHostedApplicationScimConfig", + "SelfHostedApplicationScimConfigAuthentication", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SelfHostedApplicationScimConfigMapping", + "SelfHostedApplicationScimConfigMappingOperations", + "SaaSApplication", + "SaaSApplicationPolicy", + "SaaSApplicationSaaSApp", + "SaaSApplicationSaaSAppAccessOIDCSaaSApp", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", + "SaaSApplicationScimConfig", + "SaaSApplicationScimConfigAuthentication", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SaaSApplicationScimConfigMapping", + "SaaSApplicationScimConfigMappingOperations", + "BrowserSSHApplication", + "BrowserSSHApplicationPolicy", + "BrowserSSHApplicationScimConfig", + "BrowserSSHApplicationScimConfigAuthentication", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserSSHApplicationScimConfigMapping", + "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserVncApplication", + "BrowserVncApplicationPolicy", + "BrowserVncApplicationScimConfig", + "BrowserVncApplicationScimConfigAuthentication", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserVncApplicationScimConfigMapping", + "BrowserVncApplicationScimConfigMappingOperations", + "AppLauncherApplication", + "AppLauncherApplicationPolicy", + "AppLauncherApplicationScimConfig", + "AppLauncherApplicationScimConfigAuthentication", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "AppLauncherApplicationScimConfigMapping", + "AppLauncherApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplication", + "DeviceEnrollmentPermissionsApplicationPolicy", + "DeviceEnrollmentPermissionsApplicationScimConfig", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationScimConfigMapping", + "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplication", + "BrowserIsolationPermissionsApplicationPolicy", + "BrowserIsolationPermissionsApplicationScimConfig", + "BrowserIsolationPermissionsApplicationScimConfigAuthentication", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationScimConfigMapping", + "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BookmarkApplication", + "BookmarkApplicationScimConfig", + "BookmarkApplicationScimConfigAuthentication", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BookmarkApplicationScimConfigMapping", + "BookmarkApplicationScimConfigMappingOperations", +] + + +class SelfHostedApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SelfHostedApplicationScimConfigAuthentication = Union[ + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SelfHostedApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SelfHostedApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[SelfHostedApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SelfHostedApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[SelfHostedApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[SelfHostedApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class SelfHostedApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[SelfHostedApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[SelfHostedApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class SaaSApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): + name: Optional[str] = None + """The name of the IdP claim.""" + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): + name: Optional[str] = None + """The name of the claim.""" + + name_by_idp: Optional[Dict[str, str]] = None + """A mapping from IdP ID to claim name.""" + + required: Optional[bool] = None + """If the claim is required when building an OIDC token.""" + + scope: Optional[Literal["groups", "profile", "email", "openid"]] = None + """The scope of the claim.""" + + source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): + lifetime: Optional[str] = None + """How long a refresh token will be valid for after creation. + + Valid units are m,h,d. Must be longer than 1m. + """ + + +class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): + allow_pkce_without_client_secret: Optional[bool] = None + """ + If client secret should be required on the token endpoint when + authorization_code_with_pkce grant is used. + """ + + app_launcher_url: Optional[str] = None + """The URL where this applications tile redirects users""" + + auth_type: Optional[Literal["saml", "oidc"]] = None + """Identifier of the authentication protocol used for the saas app. + + Required for OIDC. + """ + + client_id: Optional[str] = None + """The application client id""" + + client_secret: Optional[str] = None + """The application client secret, only returned on POST request.""" + + created_at: Optional[datetime] = None + + custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None + + grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]]] = None + """The OIDC flows supported by this application""" + + group_filter_regex: Optional[str] = None + """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + + public_key: Optional[str] = None + """The Access public certificate that will be used to verify your identity.""" + + redirect_uris: Optional[List[str]] = None + """ + The permitted URL's for Cloudflare to return Authorization codes and Access/ID + tokens + """ + + refresh_token_options: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions] = None + + scopes: Optional[List[Literal["openid", "groups", "email", "profile"]]] = None + """ + Define the user information shared with access, "offline_access" scope will be + automatically enabled if refresh tokens are enabled + """ + + updated_at: Optional[datetime] = None + + +SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SaaSApplicationScimConfigAuthentication = Union[ + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SaaSApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SaaSApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[SaaSApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SaaSApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[SaaSApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[SaaSApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class SaaSApplication(BaseModel): + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[SaaSApplicationPolicy]] = None + + saas_app: Optional[SaaSApplicationSaaSApp] = None + + scim_config: Optional[SaaSApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + type: Optional[str] = None + """The application type.""" + + updated_at: Optional[datetime] = None + + +class BrowserSSHApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserSSHApplicationScimConfigAuthentication = Union[ + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserSSHApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserSSHApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserSSHApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserSSHApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserSSHApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserSSHApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[BrowserSSHApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[BrowserSSHApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class BrowserVncApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserVncApplicationScimConfigAuthentication = Union[ + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserVncApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserVncApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserVncApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserVncApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserVncApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserVncApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserVncApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[BrowserVncApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[BrowserVncApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class AppLauncherApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +AppLauncherApplicationScimConfigAuthentication = Union[ + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class AppLauncherApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class AppLauncherApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[AppLauncherApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class AppLauncherApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[AppLauncherApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[AppLauncherApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class AppLauncherApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[AppLauncherApplicationPolicy]] = None + + scim_config: Optional[AppLauncherApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + BaseModel +): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[DeviceEnrollmentPermissionsApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[DeviceEnrollmentPermissionsApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class DeviceEnrollmentPermissionsApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[DeviceEnrollmentPermissionsApplicationPolicy]] = None + + scim_config: Optional[DeviceEnrollmentPermissionsApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserIsolationPermissionsApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + BaseModel +): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserIsolationPermissionsApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserIsolationPermissionsApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserIsolationPermissionsApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserIsolationPermissionsApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[BrowserIsolationPermissionsApplicationPolicy]] = None + + scim_config: Optional[BrowserIsolationPermissionsApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BookmarkApplicationScimConfigAuthentication = Union[ + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BookmarkApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BookmarkApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BookmarkApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BookmarkApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BookmarkApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BookmarkApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BookmarkApplication(BaseModel): + id: Optional[str] = None + """UUID""" + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The URL or domain of the bookmark.""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + scim_config: Optional[BookmarkApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + type: Optional[str] = None + """The application type.""" + + updated_at: Optional[datetime] = None + + +ApplicationGetResponse = Union[ + SelfHostedApplication, + SaaSApplication, + BrowserSSHApplication, + BrowserVncApplication, + AppLauncherApplication, + DeviceEnrollmentPermissionsApplication, + BrowserIsolationPermissionsApplication, + BookmarkApplication, +] diff --git a/src/cloudflare/types/zero_trust/access/application_list_response.py b/src/cloudflare/types/zero_trust/access/application_list_response.py new file mode 100644 index 00000000000..b0c7c6e6f69 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/application_list_response.py @@ -0,0 +1,2304 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ..access_rule import AccessRule +from .allowed_idps import AllowedIdPs +from .cors_headers import CORSHeaders +from .saml_saas_app import SAMLSaaSApp +from .application_type import ApplicationType +from .self_hosted_domains import SelfHostedDomains +from .applications.approval_group import ApprovalGroup + +__all__ = [ + "ApplicationListResponse", + "SelfHostedApplication", + "SelfHostedApplicationPolicy", + "SelfHostedApplicationScimConfig", + "SelfHostedApplicationScimConfigAuthentication", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SelfHostedApplicationScimConfigMapping", + "SelfHostedApplicationScimConfigMappingOperations", + "SaaSApplication", + "SaaSApplicationPolicy", + "SaaSApplicationSaaSApp", + "SaaSApplicationSaaSAppAccessOIDCSaaSApp", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", + "SaaSApplicationScimConfig", + "SaaSApplicationScimConfigAuthentication", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SaaSApplicationScimConfigMapping", + "SaaSApplicationScimConfigMappingOperations", + "BrowserSSHApplication", + "BrowserSSHApplicationPolicy", + "BrowserSSHApplicationScimConfig", + "BrowserSSHApplicationScimConfigAuthentication", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserSSHApplicationScimConfigMapping", + "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserVncApplication", + "BrowserVncApplicationPolicy", + "BrowserVncApplicationScimConfig", + "BrowserVncApplicationScimConfigAuthentication", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserVncApplicationScimConfigMapping", + "BrowserVncApplicationScimConfigMappingOperations", + "AppLauncherApplication", + "AppLauncherApplicationPolicy", + "AppLauncherApplicationScimConfig", + "AppLauncherApplicationScimConfigAuthentication", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "AppLauncherApplicationScimConfigMapping", + "AppLauncherApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplication", + "DeviceEnrollmentPermissionsApplicationPolicy", + "DeviceEnrollmentPermissionsApplicationScimConfig", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationScimConfigMapping", + "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplication", + "BrowserIsolationPermissionsApplicationPolicy", + "BrowserIsolationPermissionsApplicationScimConfig", + "BrowserIsolationPermissionsApplicationScimConfigAuthentication", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationScimConfigMapping", + "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BookmarkApplication", + "BookmarkApplicationScimConfig", + "BookmarkApplicationScimConfigAuthentication", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BookmarkApplicationScimConfigMapping", + "BookmarkApplicationScimConfigMappingOperations", +] + + +class SelfHostedApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SelfHostedApplicationScimConfigAuthentication = Union[ + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SelfHostedApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SelfHostedApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[SelfHostedApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SelfHostedApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[SelfHostedApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[SelfHostedApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class SelfHostedApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[SelfHostedApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[SelfHostedApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class SaaSApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): + name: Optional[str] = None + """The name of the IdP claim.""" + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): + name: Optional[str] = None + """The name of the claim.""" + + name_by_idp: Optional[Dict[str, str]] = None + """A mapping from IdP ID to claim name.""" + + required: Optional[bool] = None + """If the claim is required when building an OIDC token.""" + + scope: Optional[Literal["groups", "profile", "email", "openid"]] = None + """The scope of the claim.""" + + source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): + lifetime: Optional[str] = None + """How long a refresh token will be valid for after creation. + + Valid units are m,h,d. Must be longer than 1m. + """ + + +class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): + allow_pkce_without_client_secret: Optional[bool] = None + """ + If client secret should be required on the token endpoint when + authorization_code_with_pkce grant is used. + """ + + app_launcher_url: Optional[str] = None + """The URL where this applications tile redirects users""" + + auth_type: Optional[Literal["saml", "oidc"]] = None + """Identifier of the authentication protocol used for the saas app. + + Required for OIDC. + """ + + client_id: Optional[str] = None + """The application client id""" + + client_secret: Optional[str] = None + """The application client secret, only returned on POST request.""" + + created_at: Optional[datetime] = None + + custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None + + grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]]] = None + """The OIDC flows supported by this application""" + + group_filter_regex: Optional[str] = None + """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + + public_key: Optional[str] = None + """The Access public certificate that will be used to verify your identity.""" + + redirect_uris: Optional[List[str]] = None + """ + The permitted URL's for Cloudflare to return Authorization codes and Access/ID + tokens + """ + + refresh_token_options: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions] = None + + scopes: Optional[List[Literal["openid", "groups", "email", "profile"]]] = None + """ + Define the user information shared with access, "offline_access" scope will be + automatically enabled if refresh tokens are enabled + """ + + updated_at: Optional[datetime] = None + + +SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SaaSApplicationScimConfigAuthentication = Union[ + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SaaSApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SaaSApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[SaaSApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SaaSApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[SaaSApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[SaaSApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class SaaSApplication(BaseModel): + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[SaaSApplicationPolicy]] = None + + saas_app: Optional[SaaSApplicationSaaSApp] = None + + scim_config: Optional[SaaSApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + type: Optional[str] = None + """The application type.""" + + updated_at: Optional[datetime] = None + + +class BrowserSSHApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserSSHApplicationScimConfigAuthentication = Union[ + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserSSHApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserSSHApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserSSHApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserSSHApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserSSHApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserSSHApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[BrowserSSHApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[BrowserSSHApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class BrowserVncApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserVncApplicationScimConfigAuthentication = Union[ + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserVncApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserVncApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserVncApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserVncApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserVncApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserVncApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserVncApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[BrowserVncApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[BrowserVncApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class AppLauncherApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +AppLauncherApplicationScimConfigAuthentication = Union[ + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class AppLauncherApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class AppLauncherApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[AppLauncherApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class AppLauncherApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[AppLauncherApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[AppLauncherApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class AppLauncherApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[AppLauncherApplicationPolicy]] = None + + scim_config: Optional[AppLauncherApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + BaseModel +): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[DeviceEnrollmentPermissionsApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[DeviceEnrollmentPermissionsApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class DeviceEnrollmentPermissionsApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[DeviceEnrollmentPermissionsApplicationPolicy]] = None + + scim_config: Optional[DeviceEnrollmentPermissionsApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserIsolationPermissionsApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + BaseModel +): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserIsolationPermissionsApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserIsolationPermissionsApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserIsolationPermissionsApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserIsolationPermissionsApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[BrowserIsolationPermissionsApplicationPolicy]] = None + + scim_config: Optional[BrowserIsolationPermissionsApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BookmarkApplicationScimConfigAuthentication = Union[ + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BookmarkApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BookmarkApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BookmarkApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BookmarkApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BookmarkApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BookmarkApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BookmarkApplication(BaseModel): + id: Optional[str] = None + """UUID""" + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The URL or domain of the bookmark.""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + scim_config: Optional[BookmarkApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + type: Optional[str] = None + """The application type.""" + + updated_at: Optional[datetime] = None + + +ApplicationListResponse = Union[ + SelfHostedApplication, + SaaSApplication, + BrowserSSHApplication, + BrowserVncApplication, + AppLauncherApplication, + DeviceEnrollmentPermissionsApplication, + BrowserIsolationPermissionsApplication, + BookmarkApplication, +] diff --git a/src/cloudflare/types/zero_trust/access/application_update_params.py b/src/cloudflare/types/zero_trust/access/application_update_params.py index 53fac9bc0b1..1c55edcdad3 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_params.py +++ b/src/cloudflare/types/zero_trust/access/application_update_params.py @@ -2,29 +2,53 @@ from __future__ import annotations -from typing import Dict, List, Union +from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict from .allowed_idps import AllowedIdPs from .application_type import ApplicationType +from ..access_rule_param import AccessRuleParam from .cors_headers_param import CORSHeadersParam from .saml_saas_app_param import SAMLSaaSAppParam from .self_hosted_domains import SelfHostedDomains +from .applications.approval_group_param import ApprovalGroupParam __all__ = [ "ApplicationUpdateParams", "SelfHostedApplication", + "SelfHostedApplicationPolicy", + "SelfHostedApplicationPolicyAccessAppPolicyLink", + "SelfHostedApplicationPolicyUnionMember2", "SaaSApplication", + "SaaSApplicationPolicy", + "SaaSApplicationPolicyAccessAppPolicyLink", + "SaaSApplicationPolicyUnionMember2", "SaaSApplicationSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", "BrowserSSHApplication", + "BrowserSSHApplicationPolicy", + "BrowserSSHApplicationPolicyAccessAppPolicyLink", + "BrowserSSHApplicationPolicyUnionMember2", "BrowserVncApplication", + "BrowserVncApplicationPolicy", + "BrowserVncApplicationPolicyAccessAppPolicyLink", + "BrowserVncApplicationPolicyUnionMember2", "AppLauncherApplication", + "AppLauncherApplicationPolicy", + "AppLauncherApplicationPolicyAccessAppPolicyLink", + "AppLauncherApplicationPolicyUnionMember2", "DeviceEnrollmentPermissionsApplication", + "DeviceEnrollmentPermissionsApplicationPolicy", + "DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink", + "DeviceEnrollmentPermissionsApplicationPolicyUnionMember2", "BrowserIsolationPermissionsApplication", - "BookmarkApplication", + "BrowserIsolationPermissionsApplicationPolicy", + "BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink", + "BrowserIsolationPermissionsApplicationPolicyUnionMember2", + "AccessBookmarkProps", ] @@ -123,6 +147,13 @@ class SelfHostedApplication(TypedDict, total=False): If disabled, the JWT will scope to the hostname by default """ + policies: List[SelfHostedApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + same_site_cookie_attribute: str """ Sets the SameSite cookie setting, which provides increased security against CSRF @@ -152,6 +183,86 @@ class SelfHostedApplication(TypedDict, total=False): """ +class SelfHostedApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +SelfHostedApplicationPolicy = Union[ + SelfHostedApplicationPolicyAccessAppPolicyLink, str, SelfHostedApplicationPolicyUnionMember2 +] + + class SaaSApplication(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -185,6 +296,13 @@ class SaaSApplication(TypedDict, total=False): name: str """The name of the application.""" + policies: List[SaaSApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + saas_app: SaaSApplicationSaaSApp tags: List[str] @@ -197,6 +315,84 @@ class SaaSApplication(TypedDict, total=False): """The application type.""" +class SaaSApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class SaaSApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +SaaSApplicationPolicy = Union[SaaSApplicationPolicyAccessAppPolicyLink, str, SaaSApplicationPolicyUnionMember2] + + class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(TypedDict, total=False): name: str """The name of the IdP claim.""" @@ -218,7 +414,21 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(TypedDict, total=False source: SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource +class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(TypedDict, total=False): + lifetime: str + """How long a refresh token will be valid for after creation. + + Valid units are m,h,d. Must be longer than 1m. + """ + + class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): + allow_pkce_without_client_secret: bool + """ + If client secret should be required on the token endpoint when + authorization_code_with_pkce grant is used. + """ + app_launcher_url: str """The URL where this applications tile redirects users""" @@ -236,7 +446,7 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): custom_claims: SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims - grant_types: List[Literal["authorization_code", "authorization_code_with_pkce"]] + grant_types: List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]] """The OIDC flows supported by this application""" group_filter_regex: str @@ -251,8 +461,13 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): tokens """ + refresh_token_options: SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions + scopes: List[Literal["openid", "groups", "email", "profile"]] - """Define the user information shared with access""" + """ + Define the user information shared with access, "offline_access" scope will be + automatically enabled if refresh tokens are enabled + """ SaaSApplicationSaaSApp = Union[SAMLSaaSAppParam, SaaSApplicationSaaSAppAccessOIDCSaaSApp] @@ -353,6 +568,13 @@ class BrowserSSHApplication(TypedDict, total=False): If disabled, the JWT will scope to the hostname by default """ + policies: List[BrowserSSHApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + same_site_cookie_attribute: str """ Sets the SameSite cookie setting, which provides increased security against CSRF @@ -382,6 +604,86 @@ class BrowserSSHApplication(TypedDict, total=False): """ +class BrowserSSHApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +BrowserSSHApplicationPolicy = Union[ + BrowserSSHApplicationPolicyAccessAppPolicyLink, str, BrowserSSHApplicationPolicyUnionMember2 +] + + class BrowserVncApplication(TypedDict, total=False): domain: Required[str] """The primary hostname and path that Access will secure. @@ -477,6 +779,13 @@ class BrowserVncApplication(TypedDict, total=False): If disabled, the JWT will scope to the hostname by default """ + policies: List[BrowserVncApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + same_site_cookie_attribute: str """ Sets the SameSite cookie setting, which provides increased security against CSRF @@ -506,6 +815,86 @@ class BrowserVncApplication(TypedDict, total=False): """ +class BrowserVncApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +BrowserVncApplicationPolicy = Union[ + BrowserVncApplicationPolicyAccessAppPolicyLink, str, BrowserVncApplicationPolicyUnionMember2 +] + + class AppLauncherApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -530,6 +919,13 @@ class AppLauncherApplication(TypedDict, total=False): You must specify only one identity provider in allowed_idps. """ + policies: List[AppLauncherApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -538,6 +934,86 @@ class AppLauncherApplication(TypedDict, total=False): """ +class AppLauncherApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +AppLauncherApplicationPolicy = Union[ + AppLauncherApplicationPolicyAccessAppPolicyLink, str, AppLauncherApplicationPolicyUnionMember2 +] + + class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -562,6 +1038,13 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): You must specify only one identity provider in allowed_idps. """ + policies: List[DeviceEnrollmentPermissionsApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -570,6 +1053,88 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): """ +class DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +DeviceEnrollmentPermissionsApplicationPolicy = Union[ + DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink, + str, + DeviceEnrollmentPermissionsApplicationPolicyUnionMember2, +] + + class BrowserIsolationPermissionsApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -594,6 +1159,13 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): You must specify only one identity provider in allowed_idps. """ + policies: List[BrowserIsolationPermissionsApplicationPolicy] + """ + The policies that will apply to the application, in ascending order of + precedence. Items can reference existing policies or create new policies + exclusive to the application. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -602,7 +1174,89 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): """ -class BookmarkApplication(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The ID of the Access policy.""" + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + +class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total=False): + decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + id: str + """The ID of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + +BrowserIsolationPermissionsApplicationPolicy = Union[ + BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink, + str, + BrowserIsolationPermissionsApplicationPolicyUnionMember2, +] + + +class AccessBookmarkProps(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -639,5 +1293,5 @@ class BookmarkApplication(TypedDict, total=False): AppLauncherApplication, DeviceEnrollmentPermissionsApplication, BrowserIsolationPermissionsApplication, - BookmarkApplication, + AccessBookmarkProps, ] diff --git a/src/cloudflare/types/zero_trust/access/application_update_response.py b/src/cloudflare/types/zero_trust/access/application_update_response.py new file mode 100644 index 00000000000..187f7e57252 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/application_update_response.py @@ -0,0 +1,2304 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel +from ..access_rule import AccessRule +from .allowed_idps import AllowedIdPs +from .cors_headers import CORSHeaders +from .saml_saas_app import SAMLSaaSApp +from .application_type import ApplicationType +from .self_hosted_domains import SelfHostedDomains +from .applications.approval_group import ApprovalGroup + +__all__ = [ + "ApplicationUpdateResponse", + "SelfHostedApplication", + "SelfHostedApplicationPolicy", + "SelfHostedApplicationScimConfig", + "SelfHostedApplicationScimConfigAuthentication", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SelfHostedApplicationScimConfigMapping", + "SelfHostedApplicationScimConfigMappingOperations", + "SaaSApplication", + "SaaSApplicationPolicy", + "SaaSApplicationSaaSApp", + "SaaSApplicationSaaSAppAccessOIDCSaaSApp", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", + "SaaSApplicationScimConfig", + "SaaSApplicationScimConfigAuthentication", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SaaSApplicationScimConfigMapping", + "SaaSApplicationScimConfigMappingOperations", + "BrowserSSHApplication", + "BrowserSSHApplicationPolicy", + "BrowserSSHApplicationScimConfig", + "BrowserSSHApplicationScimConfigAuthentication", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserSSHApplicationScimConfigMapping", + "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserVncApplication", + "BrowserVncApplicationPolicy", + "BrowserVncApplicationScimConfig", + "BrowserVncApplicationScimConfigAuthentication", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserVncApplicationScimConfigMapping", + "BrowserVncApplicationScimConfigMappingOperations", + "AppLauncherApplication", + "AppLauncherApplicationPolicy", + "AppLauncherApplicationScimConfig", + "AppLauncherApplicationScimConfigAuthentication", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "AppLauncherApplicationScimConfigMapping", + "AppLauncherApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplication", + "DeviceEnrollmentPermissionsApplicationPolicy", + "DeviceEnrollmentPermissionsApplicationScimConfig", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationScimConfigMapping", + "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplication", + "BrowserIsolationPermissionsApplicationPolicy", + "BrowserIsolationPermissionsApplicationScimConfig", + "BrowserIsolationPermissionsApplicationScimConfigAuthentication", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationScimConfigMapping", + "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BookmarkApplication", + "BookmarkApplicationScimConfig", + "BookmarkApplicationScimConfigAuthentication", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BookmarkApplicationScimConfigMapping", + "BookmarkApplicationScimConfigMappingOperations", +] + + +class SelfHostedApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SelfHostedApplicationScimConfigAuthentication = Union[ + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SelfHostedApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SelfHostedApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[SelfHostedApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SelfHostedApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[SelfHostedApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[SelfHostedApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class SelfHostedApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[SelfHostedApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[SelfHostedApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class SaaSApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): + name: Optional[str] = None + """The name of the IdP claim.""" + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): + name: Optional[str] = None + """The name of the claim.""" + + name_by_idp: Optional[Dict[str, str]] = None + """A mapping from IdP ID to claim name.""" + + required: Optional[bool] = None + """If the claim is required when building an OIDC token.""" + + scope: Optional[Literal["groups", "profile", "email", "openid"]] = None + """The scope of the claim.""" + + source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None + + +class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): + lifetime: Optional[str] = None + """How long a refresh token will be valid for after creation. + + Valid units are m,h,d. Must be longer than 1m. + """ + + +class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): + allow_pkce_without_client_secret: Optional[bool] = None + """ + If client secret should be required on the token endpoint when + authorization_code_with_pkce grant is used. + """ + + app_launcher_url: Optional[str] = None + """The URL where this applications tile redirects users""" + + auth_type: Optional[Literal["saml", "oidc"]] = None + """Identifier of the authentication protocol used for the saas app. + + Required for OIDC. + """ + + client_id: Optional[str] = None + """The application client id""" + + client_secret: Optional[str] = None + """The application client secret, only returned on POST request.""" + + created_at: Optional[datetime] = None + + custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None + + grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]]] = None + """The OIDC flows supported by this application""" + + group_filter_regex: Optional[str] = None + """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + + public_key: Optional[str] = None + """The Access public certificate that will be used to verify your identity.""" + + redirect_uris: Optional[List[str]] = None + """ + The permitted URL's for Cloudflare to return Authorization codes and Access/ID + tokens + """ + + refresh_token_options: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions] = None + + scopes: Optional[List[Literal["openid", "groups", "email", "profile"]]] = None + """ + Define the user information shared with access, "offline_access" scope will be + automatically enabled if refresh tokens are enabled + """ + + updated_at: Optional[datetime] = None + + +SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SaaSApplicationScimConfigAuthentication = Union[ + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SaaSApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SaaSApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[SaaSApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SaaSApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[SaaSApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[SaaSApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class SaaSApplication(BaseModel): + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[SaaSApplicationPolicy]] = None + + saas_app: Optional[SaaSApplicationSaaSApp] = None + + scim_config: Optional[SaaSApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + type: Optional[str] = None + """The application type.""" + + updated_at: Optional[datetime] = None + + +class BrowserSSHApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserSSHApplicationScimConfigAuthentication = Union[ + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserSSHApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserSSHApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserSSHApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserSSHApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserSSHApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserSSHApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[BrowserSSHApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[BrowserSSHApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class BrowserVncApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserVncApplicationScimConfigAuthentication = Union[ + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserVncApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserVncApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserVncApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserVncApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserVncApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserVncApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserVncApplication(BaseModel): + domain: str + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + type: str + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allow_authenticate_via_warp: Optional[bool] = None + """ + When set to true, users can authenticate to this application using their WARP + session. When set to false this application will always require direct IdP + authentication. This setting always overrides the organization setting for WARP + authentication. + """ + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + cors_headers: Optional[CORSHeaders] = None + + created_at: Optional[datetime] = None + + custom_deny_message: Optional[str] = None + """ + The custom error message shown to a user when they are denied access to the + application. + """ + + custom_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing identity-based rules. + """ + + custom_non_identity_deny_url: Optional[str] = None + """ + The custom URL a user is redirected to when they are denied access to the + application when failing non-identity rules. + """ + + custom_pages: Optional[List[str]] = None + """The custom pages that will be displayed when applicable for this application""" + + enable_binding_cookie: Optional[bool] = None + """ + Enables the binding cookie, which increases security against compromised + authorization tokens and CSRF attacks. + """ + + http_only_cookie_attribute: Optional[bool] = None + """ + Enables the HttpOnly cookie attribute, which increases security against XSS + attacks. + """ + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + options_preflight_bypass: Optional[bool] = None + """ + Allows options preflight requests to bypass Access authentication and go + directly to the origin. Cannot turn on if cors_headers is set. + """ + + path_cookie_attribute: Optional[bool] = None + """Enables cookie paths to scope an application's JWT to the application path. + + If disabled, the JWT will scope to the hostname by default + """ + + policies: Optional[List[BrowserVncApplicationPolicy]] = None + + same_site_cookie_attribute: Optional[str] = None + """ + Sets the SameSite cookie setting, which provides increased security against CSRF + attacks. + """ + + scim_config: Optional[BrowserVncApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + self_hosted_domains: Optional[List[SelfHostedDomains]] = None + """List of domains that Access will secure.""" + + service_auth_401_redirect: Optional[bool] = None + """Returns a 401 status code when the request is blocked by a Service Auth policy.""" + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + skip_interstitial: Optional[bool] = None + """Enables automatic authentication through cloudflared.""" + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + updated_at: Optional[datetime] = None + + +class AppLauncherApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +AppLauncherApplicationScimConfigAuthentication = Union[ + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class AppLauncherApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class AppLauncherApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[AppLauncherApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class AppLauncherApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[AppLauncherApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[AppLauncherApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class AppLauncherApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[AppLauncherApplicationPolicy]] = None + + scim_config: Optional[AppLauncherApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + BaseModel +): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[DeviceEnrollmentPermissionsApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[DeviceEnrollmentPermissionsApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class DeviceEnrollmentPermissionsApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[DeviceEnrollmentPermissionsApplicationPolicy]] = None + + scim_config: Optional[DeviceEnrollmentPermissionsApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserIsolationPermissionsApplicationPolicy(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + BaseModel +): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BrowserIsolationPermissionsApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BrowserIsolationPermissionsApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BrowserIsolationPermissionsApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BrowserIsolationPermissionsApplication(BaseModel): + type: ApplicationType + """The application type.""" + + id: Optional[str] = None + """UUID""" + + allowed_idps: Optional[List[AllowedIdPs]] = None + """The identity providers your users can select when connecting to this + application. + + Defaults to all IdPs configured in your account. + """ + + aud: Optional[str] = None + """Audience tag.""" + + auto_redirect_to_identity: Optional[bool] = None + """When set to `true`, users skip the identity provider selection step during + login. + + You must specify only one identity provider in allowed_idps. + """ + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The primary hostname and path that Access will secure. + + If the app is visible in the App Launcher dashboard, this is the domain that + will be displayed. + """ + + name: Optional[str] = None + """The name of the application.""" + + policies: Optional[List[BrowserIsolationPermissionsApplicationPolicy]] = None + + scim_config: Optional[BrowserIsolationPermissionsApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for this application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): + password: str + """Password used to authenticate with the remote SCIM service.""" + + scheme: Literal["httpbasic"] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: str + """User name used to authenticate with the remote SCIM service.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): + token: str + """Token used to authenticate with the remote SCIM service.""" + + scheme: Literal["oauthbearertoken"] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): + authorization_url: str + """URL used to generate the auth code used during token generation.""" + + client_id: str + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: str + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Literal["oauth2"] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: str + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: Optional[List[str]] = None + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BookmarkApplicationScimConfigAuthentication = Union[ + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BookmarkApplicationScimConfigMappingOperations(BaseModel): + create: Optional[bool] = None + """Whether or not this mapping applies to create (POST) operations.""" + + delete: Optional[bool] = None + """Whether or not this mapping applies to DELETE operations.""" + + update: Optional[bool] = None + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BookmarkApplicationScimConfigMapping(BaseModel): + schema_: str = FieldInfo(alias="schema") + """Which SCIM resource type this mapping applies to.""" + + enabled: Optional[bool] = None + """Whether or not this mapping is enabled.""" + + filter: Optional[str] = None + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: Optional[BookmarkApplicationScimConfigMappingOperations] = None + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: Optional[str] = None + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BookmarkApplicationScimConfig(BaseModel): + idp_uid: str + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: str + """The base URI for the application's SCIM-compatible API.""" + + authentication: Optional[BookmarkApplicationScimConfigAuthentication] = None + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: Optional[bool] = None + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: Optional[bool] = None + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Optional[List[BookmarkApplicationScimConfigMapping]] = None + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BookmarkApplication(BaseModel): + id: Optional[str] = None + """UUID""" + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + aud: Optional[str] = None + """Audience tag.""" + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The URL or domain of the bookmark.""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the application.""" + + scim_config: Optional[BookmarkApplicationScimConfig] = None + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + + tags: Optional[List[str]] = None + """The tags you want assigned to an application. + + Tags are used to filter applications in the App Launcher dashboard. + """ + + type: Optional[str] = None + """The application type.""" + + updated_at: Optional[datetime] = None + + +ApplicationUpdateResponse = Union[ + SelfHostedApplication, + SaaSApplication, + BrowserSSHApplication, + BrowserVncApplication, + AppLauncherApplication, + DeviceEnrollmentPermissionsApplication, + BrowserIsolationPermissionsApplication, + BookmarkApplication, +] diff --git a/src/cloudflare/types/zero_trust/access/applications/__init__.py b/src/cloudflare/types/zero_trust/access/applications/__init__.py index a624e99e93d..206ec39071b 100644 --- a/src/cloudflare/types/zero_trust/access/applications/__init__.py +++ b/src/cloudflare/types/zero_trust/access/applications/__init__.py @@ -3,14 +3,17 @@ from __future__ import annotations from .ca import CA as CA -from .policy import Policy as Policy from .approval_group import ApprovalGroup as ApprovalGroup from .ca_get_response import CAGetResponse as CAGetResponse from .ca_create_response import CACreateResponse as CACreateResponse from .ca_delete_response import CADeleteResponse as CADeleteResponse +from .policy_get_response import PolicyGetResponse as PolicyGetResponse from .approval_group_param import ApprovalGroupParam as ApprovalGroupParam from .policy_create_params import PolicyCreateParams as PolicyCreateParams +from .policy_list_response import PolicyListResponse as PolicyListResponse from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams from .user_policy_check_geo import UserPolicyCheckGeo as UserPolicyCheckGeo +from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse from .policy_delete_response import PolicyDeleteResponse as PolicyDeleteResponse +from .policy_update_response import PolicyUpdateResponse as PolicyUpdateResponse from .user_policy_check_list_response import UserPolicyCheckListResponse as UserPolicyCheckListResponse diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py index 4d782cdf8c0..275ff4562b6 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py @@ -53,7 +53,10 @@ class PolicyCreateParams(TypedDict, total=False): """ precedence: int - """The order of execution for this policy. Must be unique for each policy.""" + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ purpose_justification_prompt: str """A custom message that will appear on the purpose justification screen.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py similarity index 92% rename from src/cloudflare/types/zero_trust/access/applications/policy.py rename to src/cloudflare/types/zero_trust/access/applications/policy_create_response.py index b19d148cea2..5efd40742e1 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py @@ -8,12 +8,12 @@ from ...access_rule import AccessRule from .approval_group import ApprovalGroup -__all__ = ["Policy"] +__all__ = ["PolicyCreateResponse"] -class Policy(BaseModel): +class PolicyCreateResponse(BaseModel): id: Optional[str] = None - """UUID""" + """The ID of the Access policy.""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -51,9 +51,6 @@ class Policy(BaseModel): name: Optional[str] = None """The name of the Access policy.""" - precedence: Optional[int] = None - """The order of execution for this policy. Must be unique for each policy.""" - purpose_justification_prompt: Optional[str] = None """A custom message that will appear on the purpose justification screen.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py new file mode 100644 index 00000000000..44fc880d8a8 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel +from ...access_rule import AccessRule +from .approval_group import ApprovalGroup + +__all__ = ["PolicyGetResponse"] + + +class PolicyGetResponse(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py new file mode 100644 index 00000000000..ac71a16fb6e --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel +from ...access_rule import AccessRule +from .approval_group import ApprovalGroup + +__all__ = ["PolicyListResponse"] + + +class PolicyListResponse(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py index 6047e104f04..31a9c3952b4 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py @@ -56,7 +56,10 @@ class PolicyUpdateParams(TypedDict, total=False): """ precedence: int - """The order of execution for this policy. Must be unique for each policy.""" + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ purpose_justification_prompt: str """A custom message that will appear on the purpose justification screen.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py new file mode 100644 index 00000000000..c7bf3a68e3a --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel +from ...access_rule import AccessRule +from .approval_group import ApprovalGroup + +__all__ = ["PolicyUpdateResponse"] + + +class PolicyUpdateResponse(BaseModel): + id: Optional[str] = None + """The ID of the Access policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_indicator_feeds.py b/tests/api_resources/intel/test_indicator_feeds.py index e0c1a3dea7a..2e3f9022dd1 100644 --- a/tests/api_resources/intel/test_indicator_feeds.py +++ b/tests/api_resources/intel/test_indicator_feeds.py @@ -83,7 +83,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: indicator_feed = client.intel.indicator_feeds.update( 12, account_id="023e105f4ecef8ad9ca31a8372d0c353", - feed_description="This is an example description", + description="This is an example description", is_attributable=True, is_public=True, ) @@ -309,7 +309,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare indicator_feed = await async_client.intel.indicator_feeds.update( 12, account_id="023e105f4ecef8ad9ca31a8372d0c353", - feed_description="This is an example description", + description="This is an example description", is_attributable=True, is_public=True, ) diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/radar/http/ases/test_bot_class.py b/tests/api_resources/radar/http/ases/test_bot_class.py index c1196859b45..298efb20286 100644 --- a/tests/api_resources/radar/http/ases/test_bot_class.py +++ b/tests/api_resources/radar/http/ases/test_bot_class.py @@ -30,6 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: bot_class = client.radar.http.ases.bot_class.get( "LIKELY_AUTOMATED", asn=["string", "string", "string"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -95,6 +96,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - bot_class = await async_client.radar.http.ases.bot_class.get( "LIKELY_AUTOMATED", asn=["string", "string", "string"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/ases/test_device_type.py b/tests/api_resources/radar/http/ases/test_device_type.py index cbf61936f48..6226975cd88 100644 --- a/tests/api_resources/radar/http/ases/test_device_type.py +++ b/tests/api_resources/radar/http/ases/test_device_type.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "DESKTOP", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "DESKTOP", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/ases/test_http_method.py b/tests/api_resources/radar/http/ases/test_http_method.py index e791bb09aa4..743ab8b7787 100644 --- a/tests/api_resources/radar/http/ases/test_http_method.py +++ b/tests/api_resources/radar/http/ases/test_http_method.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "HTTPv1", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "HTTPv1", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/ases/test_http_protocol.py b/tests/api_resources/radar/http/ases/test_http_protocol.py index 37266961af0..728e7358ecb 100644 --- a/tests/api_resources/radar/http/ases/test_http_protocol.py +++ b/tests/api_resources/radar/http/ases/test_http_protocol.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "HTTP", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -95,6 +96,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "HTTP", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/ases/test_ip_version.py b/tests/api_resources/radar/http/ases/test_ip_version.py index c69d7d39017..7cc1f35beb9 100644 --- a/tests/api_resources/radar/http/ases/test_ip_version.py +++ b/tests/api_resources/radar/http/ases/test_ip_version.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "IPv4", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "IPv4", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/ases/test_os.py b/tests/api_resources/radar/http/ases/test_os.py index a197d163aea..6dd25123783 100644 --- a/tests/api_resources/radar/http/ases/test_os.py +++ b/tests/api_resources/radar/http/ases/test_os.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "WINDOWS", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "WINDOWS", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/ases/test_tls_version.py b/tests/api_resources/radar/http/ases/test_tls_version.py index b785844f314..b7afb152fa9 100644 --- a/tests/api_resources/radar/http/ases/test_tls_version.py +++ b/tests/api_resources/radar/http/ases/test_tls_version.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "TLSv1_0", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "TLSv1_0", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/locations/test_bot_class.py b/tests/api_resources/radar/http/locations/test_bot_class.py index 064a76b14c5..87ccd2b18c3 100644 --- a/tests/api_resources/radar/http/locations/test_bot_class.py +++ b/tests/api_resources/radar/http/locations/test_bot_class.py @@ -30,6 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: bot_class = client.radar.http.locations.bot_class.get( "LIKELY_AUTOMATED", asn=["string", "string", "string"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -95,6 +96,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - bot_class = await async_client.radar.http.locations.bot_class.get( "LIKELY_AUTOMATED", asn=["string", "string", "string"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/locations/test_device_type.py b/tests/api_resources/radar/http/locations/test_device_type.py index 1fa468dd59c..fb659b5b095 100644 --- a/tests/api_resources/radar/http/locations/test_device_type.py +++ b/tests/api_resources/radar/http/locations/test_device_type.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "DESKTOP", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "DESKTOP", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/locations/test_http_method.py b/tests/api_resources/radar/http/locations/test_http_method.py index 972e82a1e61..dd886aa1364 100644 --- a/tests/api_resources/radar/http/locations/test_http_method.py +++ b/tests/api_resources/radar/http/locations/test_http_method.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "HTTPv1", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "HTTPv1", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/locations/test_http_protocol.py b/tests/api_resources/radar/http/locations/test_http_protocol.py index 944a356a577..def70042abf 100644 --- a/tests/api_resources/radar/http/locations/test_http_protocol.py +++ b/tests/api_resources/radar/http/locations/test_http_protocol.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "HTTP", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -95,6 +96,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "HTTP", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/locations/test_ip_version.py b/tests/api_resources/radar/http/locations/test_ip_version.py index f26711c76c0..48f4a35d023 100644 --- a/tests/api_resources/radar/http/locations/test_ip_version.py +++ b/tests/api_resources/radar/http/locations/test_ip_version.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "IPv4", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "IPv4", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/locations/test_os.py b/tests/api_resources/radar/http/locations/test_os.py index a72186e7703..4ca99262ff7 100644 --- a/tests/api_resources/radar/http/locations/test_os.py +++ b/tests/api_resources/radar/http/locations/test_os.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "WINDOWS", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "WINDOWS", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/locations/test_tls_version.py b/tests/api_resources/radar/http/locations/test_tls_version.py index 0be78706192..2b16a0b8c4e 100644 --- a/tests/api_resources/radar/http/locations/test_tls_version.py +++ b/tests/api_resources/radar/http/locations/test_tls_version.py @@ -31,6 +31,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "TLSv1_0", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -96,6 +97,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "TLSv1_0", asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/test_ases.py b/tests/api_resources/radar/http/test_ases.py index 8e22658cac3..623a65f1555 100644 --- a/tests/api_resources/radar/http/test_ases.py +++ b/tests/api_resources/radar/http/test_ases.py @@ -28,6 +28,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: ase = client.radar.http.ases.get( asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -87,6 +88,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - ase = await async_client.radar.http.ases.get( asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/test_locations.py b/tests/api_resources/radar/http/test_locations.py index 7f992255f7c..92935c99387 100644 --- a/tests/api_resources/radar/http/test_locations.py +++ b/tests/api_resources/radar/http/test_locations.py @@ -28,6 +28,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: location = client.radar.http.locations.get( asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -87,6 +88,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - location = await async_client.radar.http.locations.get( asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/radar/http/test_top.py b/tests/api_resources/radar/http/test_top.py index 4cac74c10b8..db326ab01e8 100644 --- a/tests/api_resources/radar/http/test_top.py +++ b/tests/api_resources/radar/http/test_top.py @@ -31,6 +31,7 @@ def test_method_browser_families_with_all_params(self, client: Cloudflare) -> No top = client.radar.http.top.browser_families( asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -86,6 +87,7 @@ def test_method_browsers_with_all_params(self, client: Cloudflare) -> None: top = client.radar.http.top.browsers( asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -145,6 +147,7 @@ async def test_method_browser_families_with_all_params(self, async_client: Async top = await async_client.radar.http.top.browser_families( asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), @@ -200,6 +203,7 @@ async def test_method_browsers_with_all_params(self, async_client: AsyncCloudfla top = await async_client.radar.http.top.browsers( asn=["string", "string", "string"], bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + browser_family=["CHROME", "EDGE", "FIREFOX"], continent=["string", "string", "string"], date_end=[ parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py index 390e99ca22f..1496d433303 100644 --- a/tests/api_resources/rulesets/test_rules.py +++ b/tests/api_resources/rulesets/test_rules.py @@ -1010,8 +1010,10 @@ def test_method_create_with_all_params_overload_13(self, client: Cloudflare) -> }, "bic": True, "disable_apps": True, + "disable_rum": True, "disable_zaraz": True, "email_obfuscation": True, + "fonts": True, "hotlink_protection": True, "mirage": True, "opportunistic_encryption": True, @@ -1221,7 +1223,7 @@ def test_method_create_with_all_params_overload_15(self, client: Cloudflare) -> "min_file_size": 0, }, "edge_ttl": { - "default": 1, + "default": 0, "mode": "respect_origin", "status_code_ttl": [ { @@ -1313,6 +1315,85 @@ def test_path_params_create_overload_15(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_16(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_16(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_16(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_delete(self, client: Cloudflare) -> None: @@ -2553,8 +2634,10 @@ def test_method_edit_with_all_params_overload_13(self, client: Cloudflare) -> No }, "bic": True, "disable_apps": True, + "disable_rum": True, "disable_zaraz": True, "email_obfuscation": True, + "fonts": True, "hotlink_protection": True, "mirage": True, "opportunistic_encryption": True, @@ -2792,7 +2875,7 @@ def test_method_edit_with_all_params_overload_15(self, client: Cloudflare) -> No "min_file_size": 0, }, "edge_ttl": { - "default": 1, + "default": 0, "mode": "respect_origin", "status_code_ttl": [ { @@ -2896,6 +2979,99 @@ def test_path_params_edit_overload_15(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_16(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_16(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + class TestAsyncRules: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -3889,8 +4065,10 @@ async def test_method_create_with_all_params_overload_13(self, async_client: Asy }, "bic": True, "disable_apps": True, + "disable_rum": True, "disable_zaraz": True, "email_obfuscation": True, + "fonts": True, "hotlink_protection": True, "mirage": True, "opportunistic_encryption": True, @@ -4100,7 +4278,7 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy "min_file_size": 0, }, "edge_ttl": { - "default": 1, + "default": 0, "mode": "respect_origin", "status_code_ttl": [ { @@ -4192,6 +4370,85 @@ async def test_path_params_create_overload_15(self, async_client: AsyncCloudflar account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: @@ -5432,8 +5689,10 @@ async def test_method_edit_with_all_params_overload_13(self, async_client: Async }, "bic": True, "disable_apps": True, + "disable_rum": True, "disable_zaraz": True, "email_obfuscation": True, + "fonts": True, "hotlink_protection": True, "mirage": True, "opportunistic_encryption": True, @@ -5671,7 +5930,7 @@ async def test_method_edit_with_all_params_overload_15(self, async_client: Async "min_file_size": 0, }, "edge_ttl": { - "default": 1, + "default": 0, "mode": "respect_origin", "status_code_ttl": [ { @@ -5774,3 +6033,96 @@ async def test_path_params_edit_overload_15(self, async_client: AsyncCloudflare) ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) diff --git a/tests/api_resources/test_calls.py b/tests/api_resources/test_calls.py index 09dab34806b..a518aded095 100644 --- a/tests/api_resources/test_calls.py +++ b/tests/api_resources/test_calls.py @@ -10,7 +10,11 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.calls import CallsApp, CallsAppWithSecret +from cloudflare.types.calls import ( + CallsApp, + CallListResponse, + CallsAppWithSecret, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -126,7 +130,7 @@ def test_method_list(self, client: Cloudflare) -> None: call = client.calls.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(SyncSinglePage[CallsApp], call, path=["response"]) + assert_matches_type(SyncSinglePage[CallListResponse], call, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -137,7 +141,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" call = response.parse() - assert_matches_type(SyncSinglePage[CallsApp], call, path=["response"]) + assert_matches_type(SyncSinglePage[CallListResponse], call, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -148,7 +152,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" call = response.parse() - assert_matches_type(SyncSinglePage[CallsApp], call, path=["response"]) + assert_matches_type(SyncSinglePage[CallListResponse], call, path=["response"]) assert cast(Any, response.is_closed) is True @@ -367,7 +371,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: call = await async_client.calls.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(AsyncSinglePage[CallsApp], call, path=["response"]) + assert_matches_type(AsyncSinglePage[CallListResponse], call, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -378,7 +382,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" call = await response.parse() - assert_matches_type(AsyncSinglePage[CallsApp], call, path=["response"]) + assert_matches_type(AsyncSinglePage[CallListResponse], call, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -389,7 +393,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" call = await response.parse() - assert_matches_type(AsyncSinglePage[CallsApp], call, path=["response"]) + assert_matches_type(AsyncSinglePage[CallListResponse], call, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/zero_trust/access/applications/test_policies.py b/tests/api_resources/zero_trust/access/applications/test_policies.py index 88c1920f5e9..b00514954fd 100644 --- a/tests/api_resources/zero_trust/access/applications/test_policies.py +++ b/tests/api_resources/zero_trust/access/applications/test_policies.py @@ -11,8 +11,11 @@ from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.zero_trust.access.applications import ( - Policy, + PolicyGetResponse, + PolicyListResponse, + PolicyCreateResponse, PolicyDeleteResponse, + PolicyUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -35,7 +38,7 @@ def test_method_create(self, client: Cloudflare) -> None: name="Allow devs", account_id="string", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -79,7 +82,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ], session_duration="24h", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -99,7 +102,7 @@ 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[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -119,7 +122,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -180,7 +183,7 @@ def test_method_update(self, client: Cloudflare) -> None: name="Allow devs", account_id="string", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -225,7 +228,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: ], session_duration="24h", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -246,7 +249,7 @@ 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" policy = response.parse() - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -267,7 +270,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -337,7 +340,7 @@ def test_method_list(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="string", ) - assert_matches_type(SyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -346,7 +349,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="string", ) - assert_matches_type(SyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -359,7 +362,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(SyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -372,7 +375,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(SyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -486,7 +489,7 @@ def test_method_get(self, client: Cloudflare) -> None: uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="string", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -496,7 +499,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="string", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -510,7 +513,7 @@ def test_raw_response_get(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[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -524,7 +527,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -577,7 +580,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: name="Allow devs", account_id="string", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -621,7 +624,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ], session_duration="24h", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -641,7 +644,7 @@ 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[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -661,7 +664,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -722,7 +725,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: name="Allow devs", account_id="string", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -767,7 +770,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare ], session_duration="24h", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -788,7 +791,7 @@ 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" policy = await response.parse() - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -809,7 +812,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -879,7 +882,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="string", ) - assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -888,7 +891,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="string", ) - assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -901,7 +904,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -914,7 +917,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1028,7 +1031,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="string", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1038,7 +1041,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="string", ) - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1052,7 +1055,7 @@ async def test_raw_response_get(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[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1066,7 +1069,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Optional[Policy], policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/zero_trust/access/test_applications.py b/tests/api_resources/zero_trust/access/test_applications.py index 3d23e6dc146..836c78af06b 100644 --- a/tests/api_resources/zero_trust/access/test_applications.py +++ b/tests/api_resources/zero_trust/access/test_applications.py @@ -11,8 +11,11 @@ from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.zero_trust.access import ( - Application, + ApplicationGetResponse, + ApplicationListResponse, + ApplicationCreateResponse, ApplicationDeleteResponse, + ApplicationUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -29,7 +32,7 @@ def test_method_create_overload_1(self, client: Cloudflare) -> None: type="self_hosted", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -70,6 +73,20 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -77,7 +94,7 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -91,7 +108,7 @@ def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -105,7 +122,7 @@ def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -132,7 +149,7 @@ def test_method_create_overload_2(self, client: Cloudflare) -> None: application = client.zero_trust.access.applications.create( account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -153,6 +170,20 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -181,7 +212,7 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N tags=["engineers", "engineers", "engineers"], type="saas", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -193,7 +224,7 @@ def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -205,7 +236,7 @@ def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -230,7 +261,7 @@ def test_method_create_overload_3(self, client: Cloudflare) -> None: type="ssh", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -271,6 +302,20 @@ def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -278,7 +323,7 @@ def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> N skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -292,7 +337,7 @@ def test_raw_response_create_overload_3(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -306,7 +351,7 @@ def test_streaming_response_create_overload_3(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -335,7 +380,7 @@ def test_method_create_overload_4(self, client: Cloudflare) -> None: type="vnc", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -376,6 +421,20 @@ def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -383,7 +442,7 @@ def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> N skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -397,7 +456,7 @@ def test_raw_response_create_overload_4(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -411,7 +470,7 @@ def test_streaming_response_create_overload_4(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -439,7 +498,7 @@ def test_method_create_overload_5(self, client: Cloudflare) -> None: type="app_launcher", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -453,9 +512,23 @@ def test_method_create_with_all_params_overload_5(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -468,7 +541,7 @@ def test_raw_response_create_overload_5(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -481,7 +554,7 @@ def test_streaming_response_create_overload_5(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -507,7 +580,7 @@ def test_method_create_overload_6(self, client: Cloudflare) -> None: type="warp", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -521,9 +594,23 @@ def test_method_create_with_all_params_overload_6(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -536,7 +623,7 @@ def test_raw_response_create_overload_6(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -549,7 +636,7 @@ def test_streaming_response_create_overload_6(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -575,7 +662,7 @@ def test_method_create_overload_7(self, client: Cloudflare) -> None: type="biso", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -589,9 +676,23 @@ def test_method_create_with_all_params_overload_7(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -604,7 +705,7 @@ def test_raw_response_create_overload_7(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -617,7 +718,7 @@ def test_streaming_response_create_overload_7(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -642,7 +743,7 @@ def test_method_create_overload_8(self, client: Cloudflare) -> None: application = client.zero_trust.access.applications.create( account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -656,7 +757,7 @@ def test_method_create_with_all_params_overload_8(self, client: Cloudflare) -> N tags=["engineers", "engineers", "engineers"], type="bookmark", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -668,7 +769,7 @@ def test_raw_response_create_overload_8(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -680,7 +781,7 @@ def test_streaming_response_create_overload_8(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -706,7 +807,7 @@ def test_method_update_overload_1(self, client: Cloudflare) -> None: type="self_hosted", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -748,6 +849,20 @@ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -755,7 +870,7 @@ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> N skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -770,7 +885,7 @@ def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -785,7 +900,7 @@ def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -815,7 +930,7 @@ def test_method_update_overload_2(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -837,6 +952,20 @@ def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> N ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -865,7 +994,7 @@ def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> N tags=["engineers", "engineers", "engineers"], type="saas", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -878,7 +1007,7 @@ def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -891,7 +1020,7 @@ def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -919,7 +1048,7 @@ def test_method_update_overload_3(self, client: Cloudflare) -> None: type="ssh", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -961,6 +1090,20 @@ def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -968,7 +1111,7 @@ def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> N skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -983,7 +1126,7 @@ def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -998,7 +1141,7 @@ def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1030,7 +1173,7 @@ def test_method_update_overload_4(self, client: Cloudflare) -> None: type="vnc", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1072,6 +1215,20 @@ def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -1079,7 +1236,7 @@ def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> N skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1094,7 +1251,7 @@ def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1109,7 +1266,7 @@ def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1140,7 +1297,7 @@ def test_method_update_overload_5(self, client: Cloudflare) -> None: type="app_launcher", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1155,9 +1312,23 @@ def test_method_update_with_all_params_overload_5(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1171,7 +1342,7 @@ def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1185,7 +1356,7 @@ def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1214,7 +1385,7 @@ def test_method_update_overload_6(self, client: Cloudflare) -> None: type="warp", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1229,9 +1400,23 @@ def test_method_update_with_all_params_overload_6(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1245,7 +1430,7 @@ def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1259,7 +1444,7 @@ def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1288,7 +1473,7 @@ def test_method_update_overload_7(self, client: Cloudflare) -> None: type="biso", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1303,9 +1488,23 @@ def test_method_update_with_all_params_overload_7(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1319,7 +1518,7 @@ def test_raw_response_update_overload_7(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1333,7 +1532,7 @@ def test_streaming_response_update_overload_7(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1361,7 +1560,7 @@ def test_method_update_overload_8(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1376,7 +1575,7 @@ def test_method_update_with_all_params_overload_8(self, client: Cloudflare) -> N tags=["engineers", "engineers", "engineers"], type="bookmark", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1389,7 +1588,7 @@ def test_raw_response_update_overload_8(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1402,7 +1601,7 @@ def test_streaming_response_update_overload_8(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1427,7 +1626,7 @@ def test_method_list(self, client: Cloudflare) -> None: application = client.zero_trust.access.applications.list( account_id="string", ) - assert_matches_type(SyncSinglePage[Application], application, path=["response"]) + assert_matches_type(SyncSinglePage[ApplicationListResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1435,7 +1634,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: application = client.zero_trust.access.applications.list( account_id="string", ) - assert_matches_type(SyncSinglePage[Application], application, path=["response"]) + assert_matches_type(SyncSinglePage[ApplicationListResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1447,7 +1646,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(SyncSinglePage[Application], application, path=["response"]) + assert_matches_type(SyncSinglePage[ApplicationListResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1459,7 +1658,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(SyncSinglePage[Application], application, path=["response"]) + assert_matches_type(SyncSinglePage[ApplicationListResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1544,7 +1743,7 @@ def test_method_get(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationGetResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1553,7 +1752,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationGetResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1566,7 +1765,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationGetResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1579,7 +1778,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationGetResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1671,7 +1870,7 @@ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> type="self_hosted", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1712,6 +1911,20 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -1719,7 +1932,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1733,7 +1946,7 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1747,7 +1960,7 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1774,7 +1987,7 @@ async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> application = await async_client.zero_trust.access.applications.create( account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1795,6 +2008,20 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -1823,7 +2050,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn tags=["engineers", "engineers", "engineers"], type="saas", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1835,7 +2062,7 @@ async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1847,7 +2074,7 @@ async def test_streaming_response_create_overload_2(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1872,7 +2099,7 @@ async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> type="ssh", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1913,6 +2140,20 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -1920,7 +2161,7 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1934,7 +2175,7 @@ async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -1948,7 +2189,7 @@ async def test_streaming_response_create_overload_3(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -1977,7 +2218,7 @@ async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> type="vnc", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2018,6 +2259,20 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -2025,7 +2280,7 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2039,7 +2294,7 @@ async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2053,7 +2308,7 @@ async def test_streaming_response_create_overload_4(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2081,7 +2336,7 @@ async def test_method_create_overload_5(self, async_client: AsyncCloudflare) -> type="app_launcher", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2095,9 +2350,23 @@ async def test_method_create_with_all_params_overload_5(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2110,7 +2379,7 @@ async def test_raw_response_create_overload_5(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2123,7 +2392,7 @@ async def test_streaming_response_create_overload_5(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2149,7 +2418,7 @@ async def test_method_create_overload_6(self, async_client: AsyncCloudflare) -> type="warp", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2163,9 +2432,23 @@ async def test_method_create_with_all_params_overload_6(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2178,7 +2461,7 @@ async def test_raw_response_create_overload_6(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2191,7 +2474,7 @@ async def test_streaming_response_create_overload_6(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2217,7 +2500,7 @@ async def test_method_create_overload_7(self, async_client: AsyncCloudflare) -> type="biso", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2231,9 +2514,23 @@ async def test_method_create_with_all_params_overload_7(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2246,7 +2543,7 @@ async def test_raw_response_create_overload_7(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2259,7 +2556,7 @@ async def test_streaming_response_create_overload_7(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2284,7 +2581,7 @@ async def test_method_create_overload_8(self, async_client: AsyncCloudflare) -> application = await async_client.zero_trust.access.applications.create( account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2298,7 +2595,7 @@ async def test_method_create_with_all_params_overload_8(self, async_client: Asyn tags=["engineers", "engineers", "engineers"], type="bookmark", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2310,7 +2607,7 @@ async def test_raw_response_create_overload_8(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2322,7 +2619,7 @@ async def test_streaming_response_create_overload_8(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2348,7 +2645,7 @@ async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> type="self_hosted", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2390,6 +2687,20 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -2397,7 +2708,7 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2412,7 +2723,7 @@ async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2427,7 +2738,7 @@ async def test_streaming_response_update_overload_1(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2457,7 +2768,7 @@ async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> "023e105f4ecef8ad9ca31a8372d0c353", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2479,6 +2790,20 @@ async def test_method_update_with_all_params_overload_2(self, async_client: Asyn ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -2507,7 +2832,7 @@ async def test_method_update_with_all_params_overload_2(self, async_client: Asyn tags=["engineers", "engineers", "engineers"], type="saas", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2520,7 +2845,7 @@ async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2533,7 +2858,7 @@ async def test_streaming_response_update_overload_2(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2561,7 +2886,7 @@ async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> type="ssh", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2603,6 +2928,20 @@ async def test_method_update_with_all_params_overload_3(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -2610,7 +2949,7 @@ async def test_method_update_with_all_params_overload_3(self, async_client: Asyn skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2625,7 +2964,7 @@ async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2640,7 +2979,7 @@ async def test_streaming_response_update_overload_3(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2672,7 +3011,7 @@ async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> type="vnc", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2714,6 +3053,20 @@ async def test_method_update_with_all_params_overload_4(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, @@ -2721,7 +3074,7 @@ async def test_method_update_with_all_params_overload_4(self, async_client: Asyn skip_interstitial=True, tags=["engineers", "engineers", "engineers"], ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2736,7 +3089,7 @@ async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2751,7 +3104,7 @@ async def test_streaming_response_update_overload_4(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2782,7 +3135,7 @@ async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> type="app_launcher", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2797,9 +3150,23 @@ async def test_method_update_with_all_params_overload_5(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2813,7 +3180,7 @@ async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2827,7 +3194,7 @@ async def test_streaming_response_update_overload_5(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2856,7 +3223,7 @@ async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> type="warp", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2871,9 +3238,23 @@ async def test_method_update_with_all_params_overload_6(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2887,7 +3268,7 @@ async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2901,7 +3282,7 @@ async def test_streaming_response_update_overload_6(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -2930,7 +3311,7 @@ async def test_method_update_overload_7(self, async_client: AsyncCloudflare) -> type="biso", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2945,9 +3326,23 @@ async def test_method_update_with_all_params_overload_7(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], session_duration="24h", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2961,7 +3356,7 @@ async def test_raw_response_update_overload_7(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -2975,7 +3370,7 @@ async def test_streaming_response_update_overload_7(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -3003,7 +3398,7 @@ async def test_method_update_overload_8(self, async_client: AsyncCloudflare) -> "023e105f4ecef8ad9ca31a8372d0c353", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3018,7 +3413,7 @@ async def test_method_update_with_all_params_overload_8(self, async_client: Asyn tags=["engineers", "engineers", "engineers"], type="bookmark", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3031,7 +3426,7 @@ async def test_raw_response_update_overload_8(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3044,7 +3439,7 @@ async def test_streaming_response_update_overload_8(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -3069,7 +3464,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: application = await async_client.zero_trust.access.applications.list( account_id="string", ) - assert_matches_type(AsyncSinglePage[Application], application, path=["response"]) + assert_matches_type(AsyncSinglePage[ApplicationListResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3077,7 +3472,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) application = await async_client.zero_trust.access.applications.list( account_id="string", ) - assert_matches_type(AsyncSinglePage[Application], application, path=["response"]) + assert_matches_type(AsyncSinglePage[ApplicationListResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3089,7 +3484,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(AsyncSinglePage[Application], application, path=["response"]) + assert_matches_type(AsyncSinglePage[ApplicationListResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3101,7 +3496,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(AsyncSinglePage[Application], application, path=["response"]) + assert_matches_type(AsyncSinglePage[ApplicationListResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True @@ -3186,7 +3581,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "023e105f4ecef8ad9ca31a8372d0c353", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationGetResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3195,7 +3590,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - "023e105f4ecef8ad9ca31a8372d0c353", account_id="string", ) - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationGetResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3208,7 +3603,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationGetResponse], application, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -3221,7 +3616,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" application = await response.parse() - assert_matches_type(Optional[Application], application, path=["response"]) + assert_matches_type(Optional[ApplicationGetResponse], application, path=["response"]) assert cast(Any, response.is_closed) is True From 25d7ab48517d36cc25b89e39c5b0d35ff5e8ff48 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 May 2024 18:09:00 +0000 Subject: [PATCH 002/532] feat(api): OpenAPI spec update via Stainless API (#483) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9dfc386c5ae..2a5b97f1aab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1274 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88d076c2683d7002e7743172b9488fb67d1a07b61995921f27209e01b224af60.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8f532f2d24923071fb4dd8efef5ac6d0573088cfcfc4513a148a591f9a97d8a0.yml From cd98d7591c3bc4098fb2412dc095ba8e2a059a9d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 May 2024 21:06:50 +0000 Subject: [PATCH 003/532] feat(api): OpenAPI spec update via Stainless API (#484) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2a5b97f1aab..59bc235f9c7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1274 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8f532f2d24923071fb4dd8efef5ac6d0573088cfcfc4513a148a591f9a97d8a0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-30337a7cd5a7e8751f3555fa711c1c25aebf6791bfa5daced9765f9b234d1a05.yml diff --git a/api.md b/api.md index 2d967bec1d7..06a803c79e9 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7384,14 +7384,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7407,10 +7407,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7427,11 +7427,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From f241e472390b03f46074c4a6e6a719fd201f1363 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 03:35:27 +0000 Subject: [PATCH 004/532] feat(api): update via SDK Studio (#485) --- .stats.yml | 2 +- api.md | 58 +- src/cloudflare/resources/calls/__init__.py | 33 ++ src/cloudflare/resources/{ => calls}/calls.py | 57 +- .../resources/calls/turn/__init__.py | 33 ++ src/cloudflare/resources/calls/turn/keys.py | 561 ++++++++++++++++++ src/cloudflare/resources/calls/turn/turn.py | 80 +++ .../resources/radar/http/ases/__init__.py | 14 + .../resources/radar/http/ases/ases.py | 32 + .../radar/http/ases/browser_family.py | 363 ++++++++++++ .../radar/http/locations/__init__.py | 14 + .../radar/http/locations/browser_family.py | 365 ++++++++++++ .../radar/http/locations/locations.py | 32 + src/cloudflare/types/calls/turn/__init__.py | 11 + .../types/calls/turn/key_create_params.py | 15 + .../types/calls/turn/key_create_response.py | 25 + .../types/calls/turn/key_delete_response.py | 6 + .../types/calls/turn/key_get_response.py | 6 + .../types/calls/turn/key_list_response.py | 6 + .../types/calls/turn/key_update_params.py | 15 + .../types/calls/turn/key_update_response.py | 6 + .../types/radar/http/ases/__init__.py | 2 + .../http/ases/browser_family_get_params.py | 104 ++++ .../http/ases/browser_family_get_response.py | 69 +++ .../types/radar/http/locations/__init__.py | 2 + .../locations/browser_family_get_params.py | 104 ++++ .../locations/browser_family_get_response.py | 69 +++ tests/api_resources/calls/__init__.py | 1 + tests/api_resources/calls/turn/__init__.py | 1 + tests/api_resources/calls/turn/test_keys.py | 500 ++++++++++++++++ .../radar/http/ases/test_browser_family.py | 147 +++++ .../http/locations/test_browser_family.py | 147 +++++ 32 files changed, 2862 insertions(+), 18 deletions(-) create mode 100644 src/cloudflare/resources/calls/__init__.py rename src/cloudflare/resources/{ => calls}/calls.py (92%) create mode 100644 src/cloudflare/resources/calls/turn/__init__.py create mode 100644 src/cloudflare/resources/calls/turn/keys.py create mode 100644 src/cloudflare/resources/calls/turn/turn.py create mode 100644 src/cloudflare/resources/radar/http/ases/browser_family.py create mode 100644 src/cloudflare/resources/radar/http/locations/browser_family.py create mode 100644 src/cloudflare/types/calls/turn/__init__.py create mode 100644 src/cloudflare/types/calls/turn/key_create_params.py create mode 100644 src/cloudflare/types/calls/turn/key_create_response.py create mode 100644 src/cloudflare/types/calls/turn/key_delete_response.py create mode 100644 src/cloudflare/types/calls/turn/key_get_response.py create mode 100644 src/cloudflare/types/calls/turn/key_list_response.py create mode 100644 src/cloudflare/types/calls/turn/key_update_params.py create mode 100644 src/cloudflare/types/calls/turn/key_update_response.py create mode 100644 src/cloudflare/types/radar/http/ases/browser_family_get_params.py create mode 100644 src/cloudflare/types/radar/http/ases/browser_family_get_response.py create mode 100644 src/cloudflare/types/radar/http/locations/browser_family_get_params.py create mode 100644 src/cloudflare/types/radar/http/locations/browser_family_get_response.py create mode 100644 tests/api_resources/calls/__init__.py create mode 100644 tests/api_resources/calls/turn/__init__.py create mode 100644 tests/api_resources/calls/turn/test_keys.py create mode 100644 tests/api_resources/radar/http/ases/test_browser_family.py create mode 100644 tests/api_resources/radar/http/locations/test_browser_family.py diff --git a/.stats.yml b/.stats.yml index 59bc235f9c7..4a6241d3039 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1274 +configured_endpoints: 1281 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-30337a7cd5a7e8751f3555fa711c1c25aebf6791bfa5daced9765f9b234d1a05.yml diff --git a/api.md b/api.md index 06a803c79e9..e776420c732 100644 --- a/api.md +++ b/api.md @@ -6934,6 +6934,18 @@ Methods: - client.radar.http.locations.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse +#### BrowserFamily + +Types: + +```python +from cloudflare.types.radar.http.locations import BrowserFamilyGetResponse +``` + +Methods: + +- client.radar.http.locations.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse + ### Ases Types: @@ -7030,6 +7042,18 @@ Methods: - client.radar.http.ases.tls_version.get(tls_version, \*\*params) -> TLSVersionGetResponse +#### BrowserFamily + +Types: + +```python +from cloudflare.types.radar.http.ases import BrowserFamilyGetResponse +``` + +Methods: + +- client.radar.http.ases.browser_family.get(browser_family, \*\*params) -> BrowserFamilyGetResponse + ### Summary Types: @@ -7359,11 +7383,35 @@ from cloudflare.types.calls import CallsApp, CallsAppWithSecret, CallListRespons Methods: -- client.calls.create(\*, account_id, \*\*params) -> Optional -- client.calls.update(app_id, \*, account_id, \*\*params) -> Optional -- client.calls.list(\*, account_id) -> SyncSinglePage[CallListResponse] -- client.calls.delete(app_id, \*, account_id) -> Optional -- client.calls.get(app_id, \*, account_id) -> Optional +- client.calls.create(\*, account_id, \*\*params) -> Optional +- client.calls.update(app_id, \*, account_id, \*\*params) -> Optional +- client.calls.list(\*, account_id) -> SyncSinglePage[CallListResponse] +- client.calls.delete(app_id, \*, account_id) -> Optional +- client.calls.get(app_id, \*, account_id) -> Optional + +## Turn + +### Keys + +Types: + +```python +from cloudflare.types.calls.turn import ( + KeyCreateResponse, + KeyUpdateResponse, + KeyListResponse, + KeyDeleteResponse, + KeyGetResponse, +) +``` + +Methods: + +- client.calls.turn.keys.create(\*, account_id, \*\*params) -> KeyCreateResponse +- client.calls.turn.keys.update(key_id, \*, account_id, \*\*params) -> str +- client.calls.turn.keys.list(\*, account_id) -> SyncSinglePage[KeyListResponse] +- client.calls.turn.keys.delete(key_id, \*, account_id) -> str +- client.calls.turn.keys.get(key_id, \*, account_id) -> str # CloudforceOne diff --git a/src/cloudflare/resources/calls/__init__.py b/src/cloudflare/resources/calls/__init__.py new file mode 100644 index 00000000000..e9d3fdeadcf --- /dev/null +++ b/src/cloudflare/resources/calls/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .turn import ( + TurnResource, + AsyncTurnResource, + TurnResourceWithRawResponse, + AsyncTurnResourceWithRawResponse, + TurnResourceWithStreamingResponse, + AsyncTurnResourceWithStreamingResponse, +) +from .calls import ( + CallsResource, + AsyncCallsResource, + CallsResourceWithRawResponse, + AsyncCallsResourceWithRawResponse, + CallsResourceWithStreamingResponse, + AsyncCallsResourceWithStreamingResponse, +) + +__all__ = [ + "TurnResource", + "AsyncTurnResource", + "TurnResourceWithRawResponse", + "AsyncTurnResourceWithRawResponse", + "TurnResourceWithStreamingResponse", + "AsyncTurnResourceWithStreamingResponse", + "CallsResource", + "AsyncCallsResource", + "CallsResourceWithRawResponse", + "AsyncCallsResourceWithRawResponse", + "CallsResourceWithStreamingResponse", + "AsyncCallsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/calls.py b/src/cloudflare/resources/calls/calls.py similarity index 92% rename from src/cloudflare/resources/calls.py rename to src/cloudflare/resources/calls/calls.py index d2865c1352e..fac5c48b430 100644 --- a/src/cloudflare/resources/calls.py +++ b/src/cloudflare/resources/calls/calls.py @@ -6,34 +6,47 @@ import httpx -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from .._utils import ( +from .turn import ( + TurnResource, + AsyncTurnResource, + TurnResourceWithRawResponse, + AsyncTurnResourceWithRawResponse, + TurnResourceWithStreamingResponse, + AsyncTurnResourceWithStreamingResponse, +) +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 .turn.turn import TurnResource, AsyncTurnResource +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 ..types.calls import call_create_params, call_update_params -from .._base_client import ( +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ...types.calls import call_create_params, call_update_params +from ..._base_client import ( AsyncPaginator, make_request_options, ) -from ..types.calls.calls_app import CallsApp -from ..types.calls.call_list_response import CallListResponse -from ..types.calls.calls_app_with_secret import CallsAppWithSecret +from ...types.calls.calls_app import CallsApp +from ...types.calls.call_list_response import CallListResponse +from ...types.calls.calls_app_with_secret import CallsAppWithSecret __all__ = ["CallsResource", "AsyncCallsResource"] class CallsResource(SyncAPIResource): + @cached_property + def turn(self) -> TurnResource: + return TurnResource(self._client) + @cached_property def with_raw_response(self) -> CallsResourceWithRawResponse: return CallsResourceWithRawResponse(self) @@ -261,6 +274,10 @@ def get( class AsyncCallsResource(AsyncAPIResource): + @cached_property + def turn(self) -> AsyncTurnResource: + return AsyncTurnResource(self._client) + @cached_property def with_raw_response(self) -> AsyncCallsResourceWithRawResponse: return AsyncCallsResourceWithRawResponse(self) @@ -507,6 +524,10 @@ def __init__(self, calls: CallsResource) -> None: calls.get, ) + @cached_property + def turn(self) -> TurnResourceWithRawResponse: + return TurnResourceWithRawResponse(self._calls.turn) + class AsyncCallsResourceWithRawResponse: def __init__(self, calls: AsyncCallsResource) -> None: @@ -528,6 +549,10 @@ def __init__(self, calls: AsyncCallsResource) -> None: calls.get, ) + @cached_property + def turn(self) -> AsyncTurnResourceWithRawResponse: + return AsyncTurnResourceWithRawResponse(self._calls.turn) + class CallsResourceWithStreamingResponse: def __init__(self, calls: CallsResource) -> None: @@ -549,6 +574,10 @@ def __init__(self, calls: CallsResource) -> None: calls.get, ) + @cached_property + def turn(self) -> TurnResourceWithStreamingResponse: + return TurnResourceWithStreamingResponse(self._calls.turn) + class AsyncCallsResourceWithStreamingResponse: def __init__(self, calls: AsyncCallsResource) -> None: @@ -569,3 +598,7 @@ def __init__(self, calls: AsyncCallsResource) -> None: self.get = async_to_streamed_response_wrapper( calls.get, ) + + @cached_property + def turn(self) -> AsyncTurnResourceWithStreamingResponse: + return AsyncTurnResourceWithStreamingResponse(self._calls.turn) diff --git a/src/cloudflare/resources/calls/turn/__init__.py b/src/cloudflare/resources/calls/turn/__init__.py new file mode 100644 index 00000000000..30445f2cff3 --- /dev/null +++ b/src/cloudflare/resources/calls/turn/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .keys import ( + KeysResource, + AsyncKeysResource, + KeysResourceWithRawResponse, + AsyncKeysResourceWithRawResponse, + KeysResourceWithStreamingResponse, + AsyncKeysResourceWithStreamingResponse, +) +from .turn import ( + TurnResource, + AsyncTurnResource, + TurnResourceWithRawResponse, + AsyncTurnResourceWithRawResponse, + TurnResourceWithStreamingResponse, + AsyncTurnResourceWithStreamingResponse, +) + +__all__ = [ + "KeysResource", + "AsyncKeysResource", + "KeysResourceWithRawResponse", + "AsyncKeysResourceWithRawResponse", + "KeysResourceWithStreamingResponse", + "AsyncKeysResourceWithStreamingResponse", + "TurnResource", + "AsyncTurnResource", + "TurnResourceWithRawResponse", + "AsyncTurnResourceWithRawResponse", + "TurnResourceWithStreamingResponse", + "AsyncTurnResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/calls/turn/keys.py b/src/cloudflare/resources/calls/turn/keys.py new file mode 100644 index 00000000000..f87b1c8c6f4 --- /dev/null +++ b/src/cloudflare/resources/calls/turn/keys.py @@ -0,0 +1,561 @@ +# 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 ...._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 ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.calls.turn import key_create_params, key_update_params +from ....types.calls.turn.key_get_response import KeyGetResponse +from ....types.calls.turn.key_list_response import KeyListResponse +from ....types.calls.turn.key_create_response import KeyCreateResponse +from ....types.calls.turn.key_delete_response import KeyDeleteResponse +from ....types.calls.turn.key_update_response import KeyUpdateResponse + +__all__ = ["KeysResource", "AsyncKeysResource"] + + +class KeysResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> KeysResourceWithRawResponse: + return KeysResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> KeysResourceWithStreamingResponse: + return KeysResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + name: 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, + ) -> KeyCreateResponse: + """ + Creates a new Cloudflare Calls TURN key. + + Args: + account_id: The account identifier tag. + + name: A short description of a TURN key, not shown to end users. + + 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}/calls/turn_keys", + body=maybe_transform({"name": name}, key_create_params.KeyCreateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=KeyCreateResponse, + ) + + def update( + self, + key_id: str, + *, + account_id: str, + name: 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, + ) -> str: + """ + Edit details for a single TURN key. + + Args: + account_id: The account identifier tag. + + key_id: A Cloudflare-generated unique identifier for a item. + + name: A short description of a TURN key, not shown to end users. + + 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 key_id: + raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") + return self._put( + f"/accounts/{account_id}/calls/turn_keys/{key_id}", + body=maybe_transform({"name": name}, key_update_params.KeyUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + 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[KeyListResponse]: + """ + Lists all TURN keys in the Cloudflare account + + Args: + account_id: The account identifier tag. + + 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}/calls/turn_keys", + page=SyncSinglePage[KeyListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=str, + ) + + def delete( + self, + key_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, + ) -> str: + """ + Deletes a TURN key from Cloudflare Calls + + Args: + account_id: The account identifier tag. + + key_id: A Cloudflare-generated unique identifier for a item. + + 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 key_id: + raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") + return self._delete( + f"/accounts/{account_id}/calls/turn_keys/{key_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + def get( + self, + key_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, + ) -> str: + """ + Fetches details for a single TURN key. + + Args: + account_id: The account identifier tag. + + key_id: A Cloudflare-generated unique identifier for a item. + + 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 key_id: + raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") + return self._get( + f"/accounts/{account_id}/calls/turn_keys/{key_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyGetResponse]]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + +class AsyncKeysResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncKeysResourceWithRawResponse: + return AsyncKeysResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncKeysResourceWithStreamingResponse: + return AsyncKeysResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + name: 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, + ) -> KeyCreateResponse: + """ + Creates a new Cloudflare Calls TURN key. + + Args: + account_id: The account identifier tag. + + name: A short description of a TURN key, not shown to end users. + + 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}/calls/turn_keys", + body=await async_maybe_transform({"name": name}, key_create_params.KeyCreateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=KeyCreateResponse, + ) + + async def update( + self, + key_id: str, + *, + account_id: str, + name: 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, + ) -> str: + """ + Edit details for a single TURN key. + + Args: + account_id: The account identifier tag. + + key_id: A Cloudflare-generated unique identifier for a item. + + name: A short description of a TURN key, not shown to end users. + + 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 key_id: + raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") + return await self._put( + f"/accounts/{account_id}/calls/turn_keys/{key_id}", + body=await async_maybe_transform({"name": name}, key_update_params.KeyUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + 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[KeyListResponse, AsyncSinglePage[KeyListResponse]]: + """ + Lists all TURN keys in the Cloudflare account + + Args: + account_id: The account identifier tag. + + 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}/calls/turn_keys", + page=AsyncSinglePage[KeyListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=str, + ) + + async def delete( + self, + key_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, + ) -> str: + """ + Deletes a TURN key from Cloudflare Calls + + Args: + account_id: The account identifier tag. + + key_id: A Cloudflare-generated unique identifier for a item. + + 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 key_id: + raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") + return await self._delete( + f"/accounts/{account_id}/calls/turn_keys/{key_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + async def get( + self, + key_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, + ) -> str: + """ + Fetches details for a single TURN key. + + Args: + account_id: The account identifier tag. + + key_id: A Cloudflare-generated unique identifier for a item. + + 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 key_id: + raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") + return await self._get( + f"/accounts/{account_id}/calls/turn_keys/{key_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyGetResponse]]._unwrapper, + ), + cast_to=cast(Type[str], ResultWrapper[str]), + ) + + +class KeysResourceWithRawResponse: + def __init__(self, keys: KeysResource) -> None: + self._keys = keys + + self.create = to_raw_response_wrapper( + keys.create, + ) + self.update = to_raw_response_wrapper( + keys.update, + ) + self.list = to_raw_response_wrapper( + keys.list, + ) + self.delete = to_raw_response_wrapper( + keys.delete, + ) + self.get = to_raw_response_wrapper( + keys.get, + ) + + +class AsyncKeysResourceWithRawResponse: + def __init__(self, keys: AsyncKeysResource) -> None: + self._keys = keys + + self.create = async_to_raw_response_wrapper( + keys.create, + ) + self.update = async_to_raw_response_wrapper( + keys.update, + ) + self.list = async_to_raw_response_wrapper( + keys.list, + ) + self.delete = async_to_raw_response_wrapper( + keys.delete, + ) + self.get = async_to_raw_response_wrapper( + keys.get, + ) + + +class KeysResourceWithStreamingResponse: + def __init__(self, keys: KeysResource) -> None: + self._keys = keys + + self.create = to_streamed_response_wrapper( + keys.create, + ) + self.update = to_streamed_response_wrapper( + keys.update, + ) + self.list = to_streamed_response_wrapper( + keys.list, + ) + self.delete = to_streamed_response_wrapper( + keys.delete, + ) + self.get = to_streamed_response_wrapper( + keys.get, + ) + + +class AsyncKeysResourceWithStreamingResponse: + def __init__(self, keys: AsyncKeysResource) -> None: + self._keys = keys + + self.create = async_to_streamed_response_wrapper( + keys.create, + ) + self.update = async_to_streamed_response_wrapper( + keys.update, + ) + self.list = async_to_streamed_response_wrapper( + keys.list, + ) + self.delete = async_to_streamed_response_wrapper( + keys.delete, + ) + self.get = async_to_streamed_response_wrapper( + keys.get, + ) diff --git a/src/cloudflare/resources/calls/turn/turn.py b/src/cloudflare/resources/calls/turn/turn.py new file mode 100644 index 00000000000..db8bf498989 --- /dev/null +++ b/src/cloudflare/resources/calls/turn/turn.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .keys import ( + KeysResource, + AsyncKeysResource, + KeysResourceWithRawResponse, + AsyncKeysResourceWithRawResponse, + KeysResourceWithStreamingResponse, + AsyncKeysResourceWithStreamingResponse, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["TurnResource", "AsyncTurnResource"] + + +class TurnResource(SyncAPIResource): + @cached_property + def keys(self) -> KeysResource: + return KeysResource(self._client) + + @cached_property + def with_raw_response(self) -> TurnResourceWithRawResponse: + return TurnResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TurnResourceWithStreamingResponse: + return TurnResourceWithStreamingResponse(self) + + +class AsyncTurnResource(AsyncAPIResource): + @cached_property + def keys(self) -> AsyncKeysResource: + return AsyncKeysResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncTurnResourceWithRawResponse: + return AsyncTurnResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTurnResourceWithStreamingResponse: + return AsyncTurnResourceWithStreamingResponse(self) + + +class TurnResourceWithRawResponse: + def __init__(self, turn: TurnResource) -> None: + self._turn = turn + + @cached_property + def keys(self) -> KeysResourceWithRawResponse: + return KeysResourceWithRawResponse(self._turn.keys) + + +class AsyncTurnResourceWithRawResponse: + def __init__(self, turn: AsyncTurnResource) -> None: + self._turn = turn + + @cached_property + def keys(self) -> AsyncKeysResourceWithRawResponse: + return AsyncKeysResourceWithRawResponse(self._turn.keys) + + +class TurnResourceWithStreamingResponse: + def __init__(self, turn: TurnResource) -> None: + self._turn = turn + + @cached_property + def keys(self) -> KeysResourceWithStreamingResponse: + return KeysResourceWithStreamingResponse(self._turn.keys) + + +class AsyncTurnResourceWithStreamingResponse: + def __init__(self, turn: AsyncTurnResource) -> None: + self._turn = turn + + @cached_property + def keys(self) -> AsyncKeysResourceWithStreamingResponse: + return AsyncKeysResourceWithStreamingResponse(self._turn.keys) diff --git a/src/cloudflare/resources/radar/http/ases/__init__.py b/src/cloudflare/resources/radar/http/ases/__init__.py index 725f29e303a..88eb8b2a278 100644 --- a/src/cloudflare/resources/radar/http/ases/__init__.py +++ b/src/cloudflare/resources/radar/http/ases/__init__.py @@ -64,6 +64,14 @@ HTTPProtocolResourceWithStreamingResponse, AsyncHTTPProtocolResourceWithStreamingResponse, ) +from .browser_family import ( + BrowserFamilyResource, + AsyncBrowserFamilyResource, + BrowserFamilyResourceWithRawResponse, + AsyncBrowserFamilyResourceWithRawResponse, + BrowserFamilyResourceWithStreamingResponse, + AsyncBrowserFamilyResourceWithStreamingResponse, +) __all__ = [ "BotClassResource", @@ -108,6 +116,12 @@ "AsyncTLSVersionResourceWithRawResponse", "TLSVersionResourceWithStreamingResponse", "AsyncTLSVersionResourceWithStreamingResponse", + "BrowserFamilyResource", + "AsyncBrowserFamilyResource", + "BrowserFamilyResourceWithRawResponse", + "AsyncBrowserFamilyResourceWithRawResponse", + "BrowserFamilyResourceWithStreamingResponse", + "AsyncBrowserFamilyResourceWithStreamingResponse", "AsesResource", "AsyncAsesResource", "AsesResourceWithRawResponse", diff --git a/src/cloudflare/resources/radar/http/ases/ases.py b/src/cloudflare/resources/radar/http/ases/ases.py index ccb97e7c87c..4666cedea05 100644 --- a/src/cloudflare/resources/radar/http/ases/ases.py +++ b/src/cloudflare/resources/radar/http/ases/ases.py @@ -78,6 +78,14 @@ HTTPProtocolResourceWithStreamingResponse, AsyncHTTPProtocolResourceWithStreamingResponse, ) +from .browser_family import ( + BrowserFamilyResource, + AsyncBrowserFamilyResource, + BrowserFamilyResourceWithRawResponse, + AsyncBrowserFamilyResourceWithRawResponse, + BrowserFamilyResourceWithStreamingResponse, + AsyncBrowserFamilyResourceWithStreamingResponse, +) from ....._base_client import ( make_request_options, ) @@ -116,6 +124,10 @@ def os(self) -> OSResource: def tls_version(self) -> TLSVersionResource: return TLSVersionResource(self._client) + @cached_property + def browser_family(self) -> BrowserFamilyResource: + return BrowserFamilyResource(self._client) + @cached_property def with_raw_response(self) -> AsesResourceWithRawResponse: return AsesResourceWithRawResponse(self) @@ -292,6 +304,10 @@ def os(self) -> AsyncOSResource: def tls_version(self) -> AsyncTLSVersionResource: return AsyncTLSVersionResource(self._client) + @cached_property + def browser_family(self) -> AsyncBrowserFamilyResource: + return AsyncBrowserFamilyResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAsesResourceWithRawResponse: return AsyncAsesResourceWithRawResponse(self) @@ -475,6 +491,10 @@ def os(self) -> OSResourceWithRawResponse: def tls_version(self) -> TLSVersionResourceWithRawResponse: return TLSVersionResourceWithRawResponse(self._ases.tls_version) + @cached_property + def browser_family(self) -> BrowserFamilyResourceWithRawResponse: + return BrowserFamilyResourceWithRawResponse(self._ases.browser_family) + class AsyncAsesResourceWithRawResponse: def __init__(self, ases: AsyncAsesResource) -> None: @@ -512,6 +532,10 @@ def os(self) -> AsyncOSResourceWithRawResponse: def tls_version(self) -> AsyncTLSVersionResourceWithRawResponse: return AsyncTLSVersionResourceWithRawResponse(self._ases.tls_version) + @cached_property + def browser_family(self) -> AsyncBrowserFamilyResourceWithRawResponse: + return AsyncBrowserFamilyResourceWithRawResponse(self._ases.browser_family) + class AsesResourceWithStreamingResponse: def __init__(self, ases: AsesResource) -> None: @@ -549,6 +573,10 @@ def os(self) -> OSResourceWithStreamingResponse: def tls_version(self) -> TLSVersionResourceWithStreamingResponse: return TLSVersionResourceWithStreamingResponse(self._ases.tls_version) + @cached_property + def browser_family(self) -> BrowserFamilyResourceWithStreamingResponse: + return BrowserFamilyResourceWithStreamingResponse(self._ases.browser_family) + class AsyncAsesResourceWithStreamingResponse: def __init__(self, ases: AsyncAsesResource) -> None: @@ -585,3 +613,7 @@ def os(self) -> AsyncOSResourceWithStreamingResponse: @cached_property def tls_version(self) -> AsyncTLSVersionResourceWithStreamingResponse: return AsyncTLSVersionResourceWithStreamingResponse(self._ases.tls_version) + + @cached_property + def browser_family(self) -> AsyncBrowserFamilyResourceWithStreamingResponse: + return AsyncBrowserFamilyResourceWithStreamingResponse(self._ases.browser_family) diff --git a/src/cloudflare/resources/radar/http/ases/browser_family.py b/src/cloudflare/resources/radar/http/ases/browser_family.py new file mode 100644 index 00000000000..93f2d1bcc91 --- /dev/null +++ b/src/cloudflare/resources/radar/http/ases/browser_family.py @@ -0,0 +1,363 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Union, cast +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import ( + make_request_options, +) +from .....types.radar.http.ases import browser_family_get_params +from .....types.radar.http.ases.browser_family_get_response import BrowserFamilyGetResponse + +__all__ = ["BrowserFamilyResource", "AsyncBrowserFamilyResource"] + + +class BrowserFamilyResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> BrowserFamilyResourceWithRawResponse: + return BrowserFamilyResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BrowserFamilyResourceWithStreamingResponse: + return BrowserFamilyResourceWithStreamingResponse(self) + + def get( + self, + browser_family: Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"], + *, + asn: List[str] | NotGiven = NOT_GIVEN, + bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + device_type: List[Literal["DESKTOP", "MOBILE", "OTHER"]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + http_protocol: List[Literal["HTTP", "HTTPS"]] | NotGiven = NOT_GIVEN, + http_version: List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]] | NotGiven = NOT_GIVEN, + ip_version: List[Literal["IPv4", "IPv6"]] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[str] | NotGiven = NOT_GIVEN, + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + | NotGiven = NOT_GIVEN, + tls_version: List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]] | 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, + ) -> BrowserFamilyGetResponse: + """ + Get the top autonomous systems (AS), by HTTP traffic, of the requested browser + family. Values are a percentage out of the total traffic. + + Args: + browser_family: Browser family. + + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + bot_class: Filter for bot class. Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + device_type: Filter for device type. + + format: Format results are returned in. + + http_protocol: Filter for http protocol. + + http_version: Filter for http version. + + ip_version: Filter for ip version. + + limit: Limit the number of objects in the response. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + os: Filter for os name. + + tls_version: Filter for tls version. + + 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 browser_family: + raise ValueError(f"Expected a non-empty value for `browser_family` but received {browser_family!r}") + return self._get( + f"/radar/http/top/ases/browser_family/{browser_family}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "asn": asn, + "bot_class": bot_class, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "device_type": device_type, + "format": format, + "http_protocol": http_protocol, + "http_version": http_version, + "ip_version": ip_version, + "limit": limit, + "location": location, + "name": name, + "os": os, + "tls_version": tls_version, + }, + browser_family_get_params.BrowserFamilyGetParams, + ), + post_parser=ResultWrapper[BrowserFamilyGetResponse]._unwrapper, + ), + cast_to=cast(Type[BrowserFamilyGetResponse], ResultWrapper[BrowserFamilyGetResponse]), + ) + + +class AsyncBrowserFamilyResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncBrowserFamilyResourceWithRawResponse: + return AsyncBrowserFamilyResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBrowserFamilyResourceWithStreamingResponse: + return AsyncBrowserFamilyResourceWithStreamingResponse(self) + + async def get( + self, + browser_family: Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"], + *, + asn: List[str] | NotGiven = NOT_GIVEN, + bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + device_type: List[Literal["DESKTOP", "MOBILE", "OTHER"]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + http_protocol: List[Literal["HTTP", "HTTPS"]] | NotGiven = NOT_GIVEN, + http_version: List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]] | NotGiven = NOT_GIVEN, + ip_version: List[Literal["IPv4", "IPv6"]] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[str] | NotGiven = NOT_GIVEN, + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + | NotGiven = NOT_GIVEN, + tls_version: List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]] | 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, + ) -> BrowserFamilyGetResponse: + """ + Get the top autonomous systems (AS), by HTTP traffic, of the requested browser + family. Values are a percentage out of the total traffic. + + Args: + browser_family: Browser family. + + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + bot_class: Filter for bot class. Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + device_type: Filter for device type. + + format: Format results are returned in. + + http_protocol: Filter for http protocol. + + http_version: Filter for http version. + + ip_version: Filter for ip version. + + limit: Limit the number of objects in the response. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + os: Filter for os name. + + tls_version: Filter for tls version. + + 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 browser_family: + raise ValueError(f"Expected a non-empty value for `browser_family` but received {browser_family!r}") + return await self._get( + f"/radar/http/top/ases/browser_family/{browser_family}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "asn": asn, + "bot_class": bot_class, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "device_type": device_type, + "format": format, + "http_protocol": http_protocol, + "http_version": http_version, + "ip_version": ip_version, + "limit": limit, + "location": location, + "name": name, + "os": os, + "tls_version": tls_version, + }, + browser_family_get_params.BrowserFamilyGetParams, + ), + post_parser=ResultWrapper[BrowserFamilyGetResponse]._unwrapper, + ), + cast_to=cast(Type[BrowserFamilyGetResponse], ResultWrapper[BrowserFamilyGetResponse]), + ) + + +class BrowserFamilyResourceWithRawResponse: + def __init__(self, browser_family: BrowserFamilyResource) -> None: + self._browser_family = browser_family + + self.get = to_raw_response_wrapper( + browser_family.get, + ) + + +class AsyncBrowserFamilyResourceWithRawResponse: + def __init__(self, browser_family: AsyncBrowserFamilyResource) -> None: + self._browser_family = browser_family + + self.get = async_to_raw_response_wrapper( + browser_family.get, + ) + + +class BrowserFamilyResourceWithStreamingResponse: + def __init__(self, browser_family: BrowserFamilyResource) -> None: + self._browser_family = browser_family + + self.get = to_streamed_response_wrapper( + browser_family.get, + ) + + +class AsyncBrowserFamilyResourceWithStreamingResponse: + def __init__(self, browser_family: AsyncBrowserFamilyResource) -> None: + self._browser_family = browser_family + + self.get = async_to_streamed_response_wrapper( + browser_family.get, + ) diff --git a/src/cloudflare/resources/radar/http/locations/__init__.py b/src/cloudflare/resources/radar/http/locations/__init__.py index 6ea85e36a11..3e402801e47 100644 --- a/src/cloudflare/resources/radar/http/locations/__init__.py +++ b/src/cloudflare/resources/radar/http/locations/__init__.py @@ -64,6 +64,14 @@ HTTPProtocolResourceWithStreamingResponse, AsyncHTTPProtocolResourceWithStreamingResponse, ) +from .browser_family import ( + BrowserFamilyResource, + AsyncBrowserFamilyResource, + BrowserFamilyResourceWithRawResponse, + AsyncBrowserFamilyResourceWithRawResponse, + BrowserFamilyResourceWithStreamingResponse, + AsyncBrowserFamilyResourceWithStreamingResponse, +) __all__ = [ "BotClassResource", @@ -108,6 +116,12 @@ "AsyncTLSVersionResourceWithRawResponse", "TLSVersionResourceWithStreamingResponse", "AsyncTLSVersionResourceWithStreamingResponse", + "BrowserFamilyResource", + "AsyncBrowserFamilyResource", + "BrowserFamilyResourceWithRawResponse", + "AsyncBrowserFamilyResourceWithRawResponse", + "BrowserFamilyResourceWithStreamingResponse", + "AsyncBrowserFamilyResourceWithStreamingResponse", "LocationsResource", "AsyncLocationsResource", "LocationsResourceWithRawResponse", diff --git a/src/cloudflare/resources/radar/http/locations/browser_family.py b/src/cloudflare/resources/radar/http/locations/browser_family.py new file mode 100644 index 00000000000..42a6dfc2c94 --- /dev/null +++ b/src/cloudflare/resources/radar/http/locations/browser_family.py @@ -0,0 +1,365 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Union, cast +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import ( + make_request_options, +) +from .....types.radar.http.locations import browser_family_get_params +from .....types.radar.http.locations.browser_family_get_response import BrowserFamilyGetResponse + +__all__ = ["BrowserFamilyResource", "AsyncBrowserFamilyResource"] + + +class BrowserFamilyResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> BrowserFamilyResourceWithRawResponse: + return BrowserFamilyResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BrowserFamilyResourceWithStreamingResponse: + return BrowserFamilyResourceWithStreamingResponse(self) + + def get( + self, + browser_family: Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"], + *, + asn: List[str] | NotGiven = NOT_GIVEN, + bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + device_type: List[Literal["DESKTOP", "MOBILE", "OTHER"]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + http_protocol: List[Literal["HTTP", "HTTPS"]] | NotGiven = NOT_GIVEN, + http_version: List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]] | NotGiven = NOT_GIVEN, + ip_version: List[Literal["IPv4", "IPv6"]] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[str] | NotGiven = NOT_GIVEN, + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + | NotGiven = NOT_GIVEN, + tls_version: List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]] | 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, + ) -> BrowserFamilyGetResponse: + """Get the top locations, by HTTP traffic, of the requested browser family. + + Values + are a percentage out of the total traffic. + + Args: + browser_family: Browser family. + + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + bot_class: Filter for bot class. Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + device_type: Filter for device type. + + format: Format results are returned in. + + http_protocol: Filter for http protocol. + + http_version: Filter for http version. + + ip_version: Filter for ip version. + + limit: Limit the number of objects in the response. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + os: Filter for os name. + + tls_version: Filter for tls version. + + 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 browser_family: + raise ValueError(f"Expected a non-empty value for `browser_family` but received {browser_family!r}") + return self._get( + f"/radar/http/top/locations/browser_family/{browser_family}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "asn": asn, + "bot_class": bot_class, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "device_type": device_type, + "format": format, + "http_protocol": http_protocol, + "http_version": http_version, + "ip_version": ip_version, + "limit": limit, + "location": location, + "name": name, + "os": os, + "tls_version": tls_version, + }, + browser_family_get_params.BrowserFamilyGetParams, + ), + post_parser=ResultWrapper[BrowserFamilyGetResponse]._unwrapper, + ), + cast_to=cast(Type[BrowserFamilyGetResponse], ResultWrapper[BrowserFamilyGetResponse]), + ) + + +class AsyncBrowserFamilyResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncBrowserFamilyResourceWithRawResponse: + return AsyncBrowserFamilyResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBrowserFamilyResourceWithStreamingResponse: + return AsyncBrowserFamilyResourceWithStreamingResponse(self) + + async def get( + self, + browser_family: Literal["CHROME", "EDGE", "FIREFOX", "SAFARI"], + *, + asn: List[str] | NotGiven = NOT_GIVEN, + bot_class: List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + device_type: List[Literal["DESKTOP", "MOBILE", "OTHER"]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + http_protocol: List[Literal["HTTP", "HTTPS"]] | NotGiven = NOT_GIVEN, + http_version: List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]] | NotGiven = NOT_GIVEN, + ip_version: List[Literal["IPv4", "IPv6"]] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[str] | NotGiven = NOT_GIVEN, + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + | NotGiven = NOT_GIVEN, + tls_version: List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]] | 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, + ) -> BrowserFamilyGetResponse: + """Get the top locations, by HTTP traffic, of the requested browser family. + + Values + are a percentage out of the total traffic. + + Args: + browser_family: Browser family. + + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + bot_class: Filter for bot class. Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + device_type: Filter for device type. + + format: Format results are returned in. + + http_protocol: Filter for http protocol. + + http_version: Filter for http version. + + ip_version: Filter for ip version. + + limit: Limit the number of objects in the response. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + os: Filter for os name. + + tls_version: Filter for tls version. + + 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 browser_family: + raise ValueError(f"Expected a non-empty value for `browser_family` but received {browser_family!r}") + return await self._get( + f"/radar/http/top/locations/browser_family/{browser_family}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "asn": asn, + "bot_class": bot_class, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "device_type": device_type, + "format": format, + "http_protocol": http_protocol, + "http_version": http_version, + "ip_version": ip_version, + "limit": limit, + "location": location, + "name": name, + "os": os, + "tls_version": tls_version, + }, + browser_family_get_params.BrowserFamilyGetParams, + ), + post_parser=ResultWrapper[BrowserFamilyGetResponse]._unwrapper, + ), + cast_to=cast(Type[BrowserFamilyGetResponse], ResultWrapper[BrowserFamilyGetResponse]), + ) + + +class BrowserFamilyResourceWithRawResponse: + def __init__(self, browser_family: BrowserFamilyResource) -> None: + self._browser_family = browser_family + + self.get = to_raw_response_wrapper( + browser_family.get, + ) + + +class AsyncBrowserFamilyResourceWithRawResponse: + def __init__(self, browser_family: AsyncBrowserFamilyResource) -> None: + self._browser_family = browser_family + + self.get = async_to_raw_response_wrapper( + browser_family.get, + ) + + +class BrowserFamilyResourceWithStreamingResponse: + def __init__(self, browser_family: BrowserFamilyResource) -> None: + self._browser_family = browser_family + + self.get = to_streamed_response_wrapper( + browser_family.get, + ) + + +class AsyncBrowserFamilyResourceWithStreamingResponse: + def __init__(self, browser_family: AsyncBrowserFamilyResource) -> None: + self._browser_family = browser_family + + self.get = async_to_streamed_response_wrapper( + browser_family.get, + ) diff --git a/src/cloudflare/resources/radar/http/locations/locations.py b/src/cloudflare/resources/radar/http/locations/locations.py index 5d89799c3ee..0839a8f25ae 100644 --- a/src/cloudflare/resources/radar/http/locations/locations.py +++ b/src/cloudflare/resources/radar/http/locations/locations.py @@ -78,6 +78,14 @@ HTTPProtocolResourceWithStreamingResponse, AsyncHTTPProtocolResourceWithStreamingResponse, ) +from .browser_family import ( + BrowserFamilyResource, + AsyncBrowserFamilyResource, + BrowserFamilyResourceWithRawResponse, + AsyncBrowserFamilyResourceWithRawResponse, + BrowserFamilyResourceWithStreamingResponse, + AsyncBrowserFamilyResourceWithStreamingResponse, +) from ....._base_client import ( make_request_options, ) @@ -116,6 +124,10 @@ def os(self) -> OSResource: def tls_version(self) -> TLSVersionResource: return TLSVersionResource(self._client) + @cached_property + def browser_family(self) -> BrowserFamilyResource: + return BrowserFamilyResource(self._client) + @cached_property def with_raw_response(self) -> LocationsResourceWithRawResponse: return LocationsResourceWithRawResponse(self) @@ -292,6 +304,10 @@ def os(self) -> AsyncOSResource: def tls_version(self) -> AsyncTLSVersionResource: return AsyncTLSVersionResource(self._client) + @cached_property + def browser_family(self) -> AsyncBrowserFamilyResource: + return AsyncBrowserFamilyResource(self._client) + @cached_property def with_raw_response(self) -> AsyncLocationsResourceWithRawResponse: return AsyncLocationsResourceWithRawResponse(self) @@ -475,6 +491,10 @@ def os(self) -> OSResourceWithRawResponse: def tls_version(self) -> TLSVersionResourceWithRawResponse: return TLSVersionResourceWithRawResponse(self._locations.tls_version) + @cached_property + def browser_family(self) -> BrowserFamilyResourceWithRawResponse: + return BrowserFamilyResourceWithRawResponse(self._locations.browser_family) + class AsyncLocationsResourceWithRawResponse: def __init__(self, locations: AsyncLocationsResource) -> None: @@ -512,6 +532,10 @@ def os(self) -> AsyncOSResourceWithRawResponse: def tls_version(self) -> AsyncTLSVersionResourceWithRawResponse: return AsyncTLSVersionResourceWithRawResponse(self._locations.tls_version) + @cached_property + def browser_family(self) -> AsyncBrowserFamilyResourceWithRawResponse: + return AsyncBrowserFamilyResourceWithRawResponse(self._locations.browser_family) + class LocationsResourceWithStreamingResponse: def __init__(self, locations: LocationsResource) -> None: @@ -549,6 +573,10 @@ def os(self) -> OSResourceWithStreamingResponse: def tls_version(self) -> TLSVersionResourceWithStreamingResponse: return TLSVersionResourceWithStreamingResponse(self._locations.tls_version) + @cached_property + def browser_family(self) -> BrowserFamilyResourceWithStreamingResponse: + return BrowserFamilyResourceWithStreamingResponse(self._locations.browser_family) + class AsyncLocationsResourceWithStreamingResponse: def __init__(self, locations: AsyncLocationsResource) -> None: @@ -585,3 +613,7 @@ def os(self) -> AsyncOSResourceWithStreamingResponse: @cached_property def tls_version(self) -> AsyncTLSVersionResourceWithStreamingResponse: return AsyncTLSVersionResourceWithStreamingResponse(self._locations.tls_version) + + @cached_property + def browser_family(self) -> AsyncBrowserFamilyResourceWithStreamingResponse: + return AsyncBrowserFamilyResourceWithStreamingResponse(self._locations.browser_family) diff --git a/src/cloudflare/types/calls/turn/__init__.py b/src/cloudflare/types/calls/turn/__init__.py new file mode 100644 index 00000000000..4bb96b15b72 --- /dev/null +++ b/src/cloudflare/types/calls/turn/__init__.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .key_get_response import KeyGetResponse as KeyGetResponse +from .key_create_params import KeyCreateParams as KeyCreateParams +from .key_list_response import KeyListResponse as KeyListResponse +from .key_update_params import KeyUpdateParams as KeyUpdateParams +from .key_create_response import KeyCreateResponse as KeyCreateResponse +from .key_delete_response import KeyDeleteResponse as KeyDeleteResponse +from .key_update_response import KeyUpdateResponse as KeyUpdateResponse diff --git a/src/cloudflare/types/calls/turn/key_create_params.py b/src/cloudflare/types/calls/turn/key_create_params.py new file mode 100644 index 00000000000..7bf69400dc0 --- /dev/null +++ b/src/cloudflare/types/calls/turn/key_create_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["KeyCreateParams"] + + +class KeyCreateParams(TypedDict, total=False): + account_id: Required[str] + """The account identifier tag.""" + + name: str + """A short description of a TURN key, not shown to end users.""" diff --git a/src/cloudflare/types/calls/turn/key_create_response.py b/src/cloudflare/types/calls/turn/key_create_response.py new file mode 100644 index 00000000000..fb228b86b86 --- /dev/null +++ b/src/cloudflare/types/calls/turn/key_create_response.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["KeyCreateResponse"] + + +class KeyCreateResponse(BaseModel): + created: Optional[datetime] = None + """The date and time the item was created.""" + + key: Optional[str] = None + """Bearer token""" + + modified: Optional[datetime] = None + """The date and time the item was last modified.""" + + name: Optional[str] = None + """A short description of a TURN key, not shown to end users.""" + + uid: Optional[str] = None + """A Cloudflare-generated unique identifier for a item.""" diff --git a/src/cloudflare/types/calls/turn/key_delete_response.py b/src/cloudflare/types/calls/turn/key_delete_response.py new file mode 100644 index 00000000000..567f4d5cd8f --- /dev/null +++ b/src/cloudflare/types/calls/turn/key_delete_response.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +__all__ = ["KeyDeleteResponse"] + +KeyDeleteResponse = str diff --git a/src/cloudflare/types/calls/turn/key_get_response.py b/src/cloudflare/types/calls/turn/key_get_response.py new file mode 100644 index 00000000000..71d24bb41c9 --- /dev/null +++ b/src/cloudflare/types/calls/turn/key_get_response.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +__all__ = ["KeyGetResponse"] + +KeyGetResponse = str diff --git a/src/cloudflare/types/calls/turn/key_list_response.py b/src/cloudflare/types/calls/turn/key_list_response.py new file mode 100644 index 00000000000..0361bf29dc9 --- /dev/null +++ b/src/cloudflare/types/calls/turn/key_list_response.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +__all__ = ["KeyListResponse"] + +KeyListResponse = str diff --git a/src/cloudflare/types/calls/turn/key_update_params.py b/src/cloudflare/types/calls/turn/key_update_params.py new file mode 100644 index 00000000000..0895691ce90 --- /dev/null +++ b/src/cloudflare/types/calls/turn/key_update_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["KeyUpdateParams"] + + +class KeyUpdateParams(TypedDict, total=False): + account_id: Required[str] + """The account identifier tag.""" + + name: str + """A short description of a TURN key, not shown to end users.""" diff --git a/src/cloudflare/types/calls/turn/key_update_response.py b/src/cloudflare/types/calls/turn/key_update_response.py new file mode 100644 index 00000000000..77ea5be7481 --- /dev/null +++ b/src/cloudflare/types/calls/turn/key_update_response.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +__all__ = ["KeyUpdateResponse"] + +KeyUpdateResponse = str diff --git a/src/cloudflare/types/radar/http/ases/__init__.py b/src/cloudflare/types/radar/http/ases/__init__.py index f91ee63822a..c527d55fdc2 100644 --- a/src/cloudflare/types/radar/http/ases/__init__.py +++ b/src/cloudflare/types/radar/http/ases/__init__.py @@ -15,4 +15,6 @@ from .http_method_get_response import HTTPMethodGetResponse as HTTPMethodGetResponse from .http_protocol_get_params import HTTPProtocolGetParams as HTTPProtocolGetParams from .tls_version_get_response import TLSVersionGetResponse as TLSVersionGetResponse +from .browser_family_get_params import BrowserFamilyGetParams as BrowserFamilyGetParams from .http_protocol_get_response import HTTPProtocolGetResponse as HTTPProtocolGetResponse +from .browser_family_get_response import BrowserFamilyGetResponse as BrowserFamilyGetResponse diff --git a/src/cloudflare/types/radar/http/ases/browser_family_get_params.py b/src/cloudflare/types/radar/http/ases/browser_family_get_params.py new file mode 100644 index 00000000000..e4869f37c27 --- /dev/null +++ b/src/cloudflare/types/radar/http/ases/browser_family_get_params.py @@ -0,0 +1,104 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ....._utils import PropertyInfo + +__all__ = ["BrowserFamilyGetParams"] + + +class BrowserFamilyGetParams(TypedDict, total=False): + asn: List[str] + """Array of comma separated list of ASNs, start with `-` to exclude from results. + + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + """ + + bot_class: Annotated[List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]], PropertyInfo(alias="botClass")] + """Filter for bot class. + + Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + """ + + continent: List[str] + """Array of comma separated list of continents (alpha-2 continent codes). + + Start with `-` to exclude from results. For example, `-EU,NA` excludes results + from Europe, but includes results from North America. + """ + + date_end: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[ + List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ], + PropertyInfo(alias="dateRange"), + ] + """ + For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + """ + + date_start: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateStart", format="iso8601")] + """Array of datetimes to filter the start of a series.""" + + device_type: Annotated[List[Literal["DESKTOP", "MOBILE", "OTHER"]], PropertyInfo(alias="deviceType")] + """Filter for device type.""" + + format: Literal["JSON", "CSV"] + """Format results are returned in.""" + + http_protocol: Annotated[List[Literal["HTTP", "HTTPS"]], PropertyInfo(alias="httpProtocol")] + """Filter for http protocol.""" + + http_version: Annotated[List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]], PropertyInfo(alias="httpVersion")] + """Filter for http version.""" + + ip_version: Annotated[List[Literal["IPv4", "IPv6"]], PropertyInfo(alias="ipVersion")] + """Filter for ip version.""" + + limit: int + """Limit the number of objects in the response.""" + + location: List[str] + """Array of comma separated list of locations (alpha-2 country codes). + + Start with `-` to exclude from results. For example, `-US,PT` excludes results + from the US, but includes results from PT. + """ + + name: List[str] + """Array of names that will be used to name the series in responses.""" + + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + """Filter for os name.""" + + tls_version: Annotated[ + List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]], PropertyInfo(alias="tlsVersion") + ] + """Filter for tls version.""" diff --git a/src/cloudflare/types/radar/http/ases/browser_family_get_response.py b/src/cloudflare/types/radar/http/ases/browser_family_get_response.py new file mode 100644 index 00000000000..e7bd3b48901 --- /dev/null +++ b/src/cloudflare/types/radar/http/ases/browser_family_get_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel + +__all__ = [ + "BrowserFamilyGetResponse", + "Meta", + "MetaDateRange", + "MetaConfidenceInfo", + "MetaConfidenceInfoAnnotation", + "Top0", +] + + +class MetaDateRange(BaseModel): + end_time: datetime = FieldInfo(alias="endTime") + """Adjusted end of date range.""" + + start_time: datetime = FieldInfo(alias="startTime") + """Adjusted start of date range.""" + + +class MetaConfidenceInfoAnnotation(BaseModel): + data_source: str = FieldInfo(alias="dataSource") + + description: str + + event_type: str = FieldInfo(alias="eventType") + + is_instantaneous: object = FieldInfo(alias="isInstantaneous") + + end_time: Optional[datetime] = FieldInfo(alias="endTime", default=None) + + linked_url: Optional[str] = FieldInfo(alias="linkedUrl", default=None) + + start_time: Optional[datetime] = FieldInfo(alias="startTime", default=None) + + +class MetaConfidenceInfo(BaseModel): + annotations: Optional[List[MetaConfidenceInfoAnnotation]] = None + + level: Optional[int] = None + + +class Meta(BaseModel): + date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") + + last_updated: str = FieldInfo(alias="lastUpdated") + + confidence_info: Optional[MetaConfidenceInfo] = FieldInfo(alias="confidenceInfo", default=None) + + +class Top0(BaseModel): + client_asn: int = FieldInfo(alias="clientASN") + + client_as_name: str = FieldInfo(alias="clientASName") + + value: str + + +class BrowserFamilyGetResponse(BaseModel): + meta: Meta + + top_0: List[Top0] diff --git a/src/cloudflare/types/radar/http/locations/__init__.py b/src/cloudflare/types/radar/http/locations/__init__.py index f91ee63822a..c527d55fdc2 100644 --- a/src/cloudflare/types/radar/http/locations/__init__.py +++ b/src/cloudflare/types/radar/http/locations/__init__.py @@ -15,4 +15,6 @@ from .http_method_get_response import HTTPMethodGetResponse as HTTPMethodGetResponse from .http_protocol_get_params import HTTPProtocolGetParams as HTTPProtocolGetParams from .tls_version_get_response import TLSVersionGetResponse as TLSVersionGetResponse +from .browser_family_get_params import BrowserFamilyGetParams as BrowserFamilyGetParams from .http_protocol_get_response import HTTPProtocolGetResponse as HTTPProtocolGetResponse +from .browser_family_get_response import BrowserFamilyGetResponse as BrowserFamilyGetResponse diff --git a/src/cloudflare/types/radar/http/locations/browser_family_get_params.py b/src/cloudflare/types/radar/http/locations/browser_family_get_params.py new file mode 100644 index 00000000000..e4869f37c27 --- /dev/null +++ b/src/cloudflare/types/radar/http/locations/browser_family_get_params.py @@ -0,0 +1,104 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ....._utils import PropertyInfo + +__all__ = ["BrowserFamilyGetParams"] + + +class BrowserFamilyGetParams(TypedDict, total=False): + asn: List[str] + """Array of comma separated list of ASNs, start with `-` to exclude from results. + + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + """ + + bot_class: Annotated[List[Literal["LIKELY_AUTOMATED", "LIKELY_HUMAN"]], PropertyInfo(alias="botClass")] + """Filter for bot class. + + Refer to + [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + """ + + continent: List[str] + """Array of comma separated list of continents (alpha-2 continent codes). + + Start with `-` to exclude from results. For example, `-EU,NA` excludes results + from Europe, but includes results from North America. + """ + + date_end: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[ + List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ], + PropertyInfo(alias="dateRange"), + ] + """ + For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + """ + + date_start: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateStart", format="iso8601")] + """Array of datetimes to filter the start of a series.""" + + device_type: Annotated[List[Literal["DESKTOP", "MOBILE", "OTHER"]], PropertyInfo(alias="deviceType")] + """Filter for device type.""" + + format: Literal["JSON", "CSV"] + """Format results are returned in.""" + + http_protocol: Annotated[List[Literal["HTTP", "HTTPS"]], PropertyInfo(alias="httpProtocol")] + """Filter for http protocol.""" + + http_version: Annotated[List[Literal["HTTPv1", "HTTPv2", "HTTPv3"]], PropertyInfo(alias="httpVersion")] + """Filter for http version.""" + + ip_version: Annotated[List[Literal["IPv4", "IPv6"]], PropertyInfo(alias="ipVersion")] + """Filter for ip version.""" + + limit: int + """Limit the number of objects in the response.""" + + location: List[str] + """Array of comma separated list of locations (alpha-2 country codes). + + Start with `-` to exclude from results. For example, `-US,PT` excludes results + from the US, but includes results from PT. + """ + + name: List[str] + """Array of names that will be used to name the series in responses.""" + + os: List[Literal["WINDOWS", "MACOSX", "IOS", "ANDROID", "CHROMEOS", "LINUX", "SMART_TV"]] + """Filter for os name.""" + + tls_version: Annotated[ + List[Literal["TLSv1_0", "TLSv1_1", "TLSv1_2", "TLSv1_3", "TLSvQUIC"]], PropertyInfo(alias="tlsVersion") + ] + """Filter for tls version.""" diff --git a/src/cloudflare/types/radar/http/locations/browser_family_get_response.py b/src/cloudflare/types/radar/http/locations/browser_family_get_response.py new file mode 100644 index 00000000000..faa107c1193 --- /dev/null +++ b/src/cloudflare/types/radar/http/locations/browser_family_get_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel + +__all__ = [ + "BrowserFamilyGetResponse", + "Meta", + "MetaDateRange", + "MetaConfidenceInfo", + "MetaConfidenceInfoAnnotation", + "Top0", +] + + +class MetaDateRange(BaseModel): + end_time: datetime = FieldInfo(alias="endTime") + """Adjusted end of date range.""" + + start_time: datetime = FieldInfo(alias="startTime") + """Adjusted start of date range.""" + + +class MetaConfidenceInfoAnnotation(BaseModel): + data_source: str = FieldInfo(alias="dataSource") + + description: str + + event_type: str = FieldInfo(alias="eventType") + + is_instantaneous: object = FieldInfo(alias="isInstantaneous") + + end_time: Optional[datetime] = FieldInfo(alias="endTime", default=None) + + linked_url: Optional[str] = FieldInfo(alias="linkedUrl", default=None) + + start_time: Optional[datetime] = FieldInfo(alias="startTime", default=None) + + +class MetaConfidenceInfo(BaseModel): + annotations: Optional[List[MetaConfidenceInfoAnnotation]] = None + + level: Optional[int] = None + + +class Meta(BaseModel): + date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") + + last_updated: str = FieldInfo(alias="lastUpdated") + + confidence_info: Optional[MetaConfidenceInfo] = FieldInfo(alias="confidenceInfo", default=None) + + +class Top0(BaseModel): + client_country_alpha2: str = FieldInfo(alias="clientCountryAlpha2") + + client_country_name: str = FieldInfo(alias="clientCountryName") + + value: str + + +class BrowserFamilyGetResponse(BaseModel): + meta: Meta + + top_0: List[Top0] diff --git a/tests/api_resources/calls/__init__.py b/tests/api_resources/calls/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/calls/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/calls/turn/__init__.py b/tests/api_resources/calls/turn/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/calls/turn/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/calls/turn/test_keys.py b/tests/api_resources/calls/turn/test_keys.py new file mode 100644 index 00000000000..65c537af125 --- /dev/null +++ b/tests/api_resources/calls/turn/test_keys.py @@ -0,0 +1,500 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.calls.turn import ( + KeyListResponse, + KeyCreateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestKeys: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + key = client.calls.turn.keys.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(KeyCreateResponse, key, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + key = client.calls.turn.keys.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="my-turn-key", + ) + assert_matches_type(KeyCreateResponse, key, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.calls.turn.keys.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(KeyCreateResponse, key, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.calls.turn.keys.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(KeyCreateResponse, key, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.calls.turn.keys.with_raw_response.create( + account_id="", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + key = client.calls.turn.keys.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(str, key, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + key = client.calls.turn.keys.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="my-turn-key", + ) + assert_matches_type(str, key, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.calls.turn.keys.with_raw_response.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(str, key, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.calls.turn.keys.with_streaming_response.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(str, key, 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.calls.turn.keys.with_raw_response.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `key_id` but received ''"): + client.calls.turn.keys.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + key = client.calls.turn.keys.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[KeyListResponse], key, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.calls.turn.keys.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(SyncSinglePage[KeyListResponse], key, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.calls.turn.keys.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(SyncSinglePage[KeyListResponse], key, 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.calls.turn.keys.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + key = client.calls.turn.keys.delete( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(str, key, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.calls.turn.keys.with_raw_response.delete( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(str, key, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.calls.turn.keys.with_streaming_response.delete( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(str, key, 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.calls.turn.keys.with_raw_response.delete( + "2a95132c15732412d22c1476fa83f27a", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `key_id` but received ''"): + client.calls.turn.keys.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + key = client.calls.turn.keys.get( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(str, key, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.calls.turn.keys.with_raw_response.get( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(str, key, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.calls.turn.keys.with_streaming_response.get( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(str, key, 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.calls.turn.keys.with_raw_response.get( + "2a95132c15732412d22c1476fa83f27a", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `key_id` but received ''"): + client.calls.turn.keys.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncKeys: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + key = await async_client.calls.turn.keys.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(KeyCreateResponse, key, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + key = await async_client.calls.turn.keys.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="my-turn-key", + ) + assert_matches_type(KeyCreateResponse, key, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.calls.turn.keys.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(KeyCreateResponse, key, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.calls.turn.keys.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(KeyCreateResponse, key, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.calls.turn.keys.with_raw_response.create( + account_id="", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + key = await async_client.calls.turn.keys.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(str, key, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + key = await async_client.calls.turn.keys.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="my-turn-key", + ) + assert_matches_type(str, key, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.calls.turn.keys.with_raw_response.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(str, key, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.calls.turn.keys.with_streaming_response.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(str, key, 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.calls.turn.keys.with_raw_response.update( + "2a95132c15732412d22c1476fa83f27a", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `key_id` but received ''"): + await async_client.calls.turn.keys.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + key = await async_client.calls.turn.keys.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[KeyListResponse], key, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.calls.turn.keys.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(AsyncSinglePage[KeyListResponse], key, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.calls.turn.keys.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(AsyncSinglePage[KeyListResponse], key, 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.calls.turn.keys.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + key = await async_client.calls.turn.keys.delete( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(str, key, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.calls.turn.keys.with_raw_response.delete( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(str, key, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.calls.turn.keys.with_streaming_response.delete( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(str, key, 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.calls.turn.keys.with_raw_response.delete( + "2a95132c15732412d22c1476fa83f27a", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `key_id` but received ''"): + await async_client.calls.turn.keys.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + key = await async_client.calls.turn.keys.get( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(str, key, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.calls.turn.keys.with_raw_response.get( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(str, key, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.calls.turn.keys.with_streaming_response.get( + "2a95132c15732412d22c1476fa83f27a", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(str, key, 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.calls.turn.keys.with_raw_response.get( + "2a95132c15732412d22c1476fa83f27a", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `key_id` but received ''"): + await async_client.calls.turn.keys.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/radar/http/ases/test_browser_family.py b/tests/api_resources/radar/http/ases/test_browser_family.py new file mode 100644 index 00000000000..2de13ca3b67 --- /dev/null +++ b/tests/api_resources/radar/http/ases/test_browser_family.py @@ -0,0 +1,147 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.radar.http.ases import BrowserFamilyGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestBrowserFamily: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + browser_family = client.radar.http.ases.browser_family.get( + "CHROME", + ) + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + browser_family = client.radar.http.ases.browser_family.get( + "CHROME", + asn=["string", "string", "string"], + bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + device_type=["DESKTOP", "MOBILE", "OTHER"], + format="JSON", + http_protocol=["HTTP", "HTTPS"], + http_version=["HTTPv1", "HTTPv2", "HTTPv3"], + ip_version=["IPv4", "IPv6"], + limit=5, + location=["string", "string", "string"], + name=["string", "string", "string"], + os=["WINDOWS", "MACOSX", "IOS"], + tls_version=["TLSv1_0", "TLSv1_1", "TLSv1_2"], + ) + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.radar.http.ases.browser_family.with_raw_response.get( + "CHROME", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + browser_family = response.parse() + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.radar.http.ases.browser_family.with_streaming_response.get( + "CHROME", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + browser_family = response.parse() + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncBrowserFamily: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + browser_family = await async_client.radar.http.ases.browser_family.get( + "CHROME", + ) + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + browser_family = await async_client.radar.http.ases.browser_family.get( + "CHROME", + asn=["string", "string", "string"], + bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + device_type=["DESKTOP", "MOBILE", "OTHER"], + format="JSON", + http_protocol=["HTTP", "HTTPS"], + http_version=["HTTPv1", "HTTPv2", "HTTPv3"], + ip_version=["IPv4", "IPv6"], + limit=5, + location=["string", "string", "string"], + name=["string", "string", "string"], + os=["WINDOWS", "MACOSX", "IOS"], + tls_version=["TLSv1_0", "TLSv1_1", "TLSv1_2"], + ) + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.http.ases.browser_family.with_raw_response.get( + "CHROME", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + browser_family = await response.parse() + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.http.ases.browser_family.with_streaming_response.get( + "CHROME", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + browser_family = await response.parse() + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/radar/http/locations/test_browser_family.py b/tests/api_resources/radar/http/locations/test_browser_family.py new file mode 100644 index 00000000000..7dd0326e896 --- /dev/null +++ b/tests/api_resources/radar/http/locations/test_browser_family.py @@ -0,0 +1,147 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.radar.http.locations import BrowserFamilyGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestBrowserFamily: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + browser_family = client.radar.http.locations.browser_family.get( + "CHROME", + ) + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + browser_family = client.radar.http.locations.browser_family.get( + "CHROME", + asn=["string", "string", "string"], + bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + device_type=["DESKTOP", "MOBILE", "OTHER"], + format="JSON", + http_protocol=["HTTP", "HTTPS"], + http_version=["HTTPv1", "HTTPv2", "HTTPv3"], + ip_version=["IPv4", "IPv6"], + limit=5, + location=["string", "string", "string"], + name=["string", "string", "string"], + os=["WINDOWS", "MACOSX", "IOS"], + tls_version=["TLSv1_0", "TLSv1_1", "TLSv1_2"], + ) + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.radar.http.locations.browser_family.with_raw_response.get( + "CHROME", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + browser_family = response.parse() + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.radar.http.locations.browser_family.with_streaming_response.get( + "CHROME", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + browser_family = response.parse() + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncBrowserFamily: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + browser_family = await async_client.radar.http.locations.browser_family.get( + "CHROME", + ) + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + browser_family = await async_client.radar.http.locations.browser_family.get( + "CHROME", + asn=["string", "string", "string"], + bot_class=["LIKELY_AUTOMATED", "LIKELY_HUMAN"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + device_type=["DESKTOP", "MOBILE", "OTHER"], + format="JSON", + http_protocol=["HTTP", "HTTPS"], + http_version=["HTTPv1", "HTTPv2", "HTTPv3"], + ip_version=["IPv4", "IPv6"], + limit=5, + location=["string", "string", "string"], + name=["string", "string", "string"], + os=["WINDOWS", "MACOSX", "IOS"], + tls_version=["TLSv1_0", "TLSv1_1", "TLSv1_2"], + ) + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.http.locations.browser_family.with_raw_response.get( + "CHROME", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + browser_family = await response.parse() + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.http.locations.browser_family.with_streaming_response.get( + "CHROME", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + browser_family = await response.parse() + assert_matches_type(BrowserFamilyGetResponse, browser_family, path=["response"]) + + assert cast(Any, response.is_closed) is True From 9e58daf6309b71235038caf7181123c52aa3057b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 03:40:44 +0000 Subject: [PATCH 005/532] feat(api): update via SDK Studio (#486) --- api.md | 2 +- src/cloudflare/resources/calls/__init__.py | 24 ++++++------ src/cloudflare/resources/calls/calls.py | 38 +++++++++---------- .../resources/calls/turn/__init__.py | 24 ++++++------ src/cloudflare/resources/calls/turn/turn.py | 38 +++++++++---------- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/api.md b/api.md index e776420c732..33d264c0615 100644 --- a/api.md +++ b/api.md @@ -7389,7 +7389,7 @@ Methods: - client.calls.delete(app_id, \*, account_id) -> Optional - client.calls.get(app_id, \*, account_id) -> Optional -## Turn +## TURN ### Keys diff --git a/src/cloudflare/resources/calls/__init__.py b/src/cloudflare/resources/calls/__init__.py index e9d3fdeadcf..2d00a1bdd9e 100644 --- a/src/cloudflare/resources/calls/__init__.py +++ b/src/cloudflare/resources/calls/__init__.py @@ -1,12 +1,12 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from .turn import ( - TurnResource, - AsyncTurnResource, - TurnResourceWithRawResponse, - AsyncTurnResourceWithRawResponse, - TurnResourceWithStreamingResponse, - AsyncTurnResourceWithStreamingResponse, + TURNResource, + AsyncTURNResource, + TURNResourceWithRawResponse, + AsyncTURNResourceWithRawResponse, + TURNResourceWithStreamingResponse, + AsyncTURNResourceWithStreamingResponse, ) from .calls import ( CallsResource, @@ -18,12 +18,12 @@ ) __all__ = [ - "TurnResource", - "AsyncTurnResource", - "TurnResourceWithRawResponse", - "AsyncTurnResourceWithRawResponse", - "TurnResourceWithStreamingResponse", - "AsyncTurnResourceWithStreamingResponse", + "TURNResource", + "AsyncTURNResource", + "TURNResourceWithRawResponse", + "AsyncTURNResourceWithRawResponse", + "TURNResourceWithStreamingResponse", + "AsyncTURNResourceWithStreamingResponse", "CallsResource", "AsyncCallsResource", "CallsResourceWithRawResponse", diff --git a/src/cloudflare/resources/calls/calls.py b/src/cloudflare/resources/calls/calls.py index fac5c48b430..17455714979 100644 --- a/src/cloudflare/resources/calls/calls.py +++ b/src/cloudflare/resources/calls/calls.py @@ -7,12 +7,12 @@ import httpx from .turn import ( - TurnResource, - AsyncTurnResource, - TurnResourceWithRawResponse, - AsyncTurnResourceWithRawResponse, - TurnResourceWithStreamingResponse, - AsyncTurnResourceWithStreamingResponse, + TURNResource, + AsyncTURNResource, + TURNResourceWithRawResponse, + AsyncTURNResourceWithRawResponse, + TURNResourceWithStreamingResponse, + AsyncTURNResourceWithStreamingResponse, ) from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import ( @@ -20,7 +20,7 @@ async_maybe_transform, ) from ..._compat import cached_property -from .turn.turn import TurnResource, AsyncTurnResource +from .turn.turn import TURNResource, AsyncTURNResource from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, @@ -44,8 +44,8 @@ class CallsResource(SyncAPIResource): @cached_property - def turn(self) -> TurnResource: - return TurnResource(self._client) + def turn(self) -> TURNResource: + return TURNResource(self._client) @cached_property def with_raw_response(self) -> CallsResourceWithRawResponse: @@ -275,8 +275,8 @@ def get( class AsyncCallsResource(AsyncAPIResource): @cached_property - def turn(self) -> AsyncTurnResource: - return AsyncTurnResource(self._client) + def turn(self) -> AsyncTURNResource: + return AsyncTURNResource(self._client) @cached_property def with_raw_response(self) -> AsyncCallsResourceWithRawResponse: @@ -525,8 +525,8 @@ def __init__(self, calls: CallsResource) -> None: ) @cached_property - def turn(self) -> TurnResourceWithRawResponse: - return TurnResourceWithRawResponse(self._calls.turn) + def turn(self) -> TURNResourceWithRawResponse: + return TURNResourceWithRawResponse(self._calls.turn) class AsyncCallsResourceWithRawResponse: @@ -550,8 +550,8 @@ def __init__(self, calls: AsyncCallsResource) -> None: ) @cached_property - def turn(self) -> AsyncTurnResourceWithRawResponse: - return AsyncTurnResourceWithRawResponse(self._calls.turn) + def turn(self) -> AsyncTURNResourceWithRawResponse: + return AsyncTURNResourceWithRawResponse(self._calls.turn) class CallsResourceWithStreamingResponse: @@ -575,8 +575,8 @@ def __init__(self, calls: CallsResource) -> None: ) @cached_property - def turn(self) -> TurnResourceWithStreamingResponse: - return TurnResourceWithStreamingResponse(self._calls.turn) + def turn(self) -> TURNResourceWithStreamingResponse: + return TURNResourceWithStreamingResponse(self._calls.turn) class AsyncCallsResourceWithStreamingResponse: @@ -600,5 +600,5 @@ def __init__(self, calls: AsyncCallsResource) -> None: ) @cached_property - def turn(self) -> AsyncTurnResourceWithStreamingResponse: - return AsyncTurnResourceWithStreamingResponse(self._calls.turn) + def turn(self) -> AsyncTURNResourceWithStreamingResponse: + return AsyncTURNResourceWithStreamingResponse(self._calls.turn) diff --git a/src/cloudflare/resources/calls/turn/__init__.py b/src/cloudflare/resources/calls/turn/__init__.py index 30445f2cff3..4ad11d459cd 100644 --- a/src/cloudflare/resources/calls/turn/__init__.py +++ b/src/cloudflare/resources/calls/turn/__init__.py @@ -9,12 +9,12 @@ AsyncKeysResourceWithStreamingResponse, ) from .turn import ( - TurnResource, - AsyncTurnResource, - TurnResourceWithRawResponse, - AsyncTurnResourceWithRawResponse, - TurnResourceWithStreamingResponse, - AsyncTurnResourceWithStreamingResponse, + TURNResource, + AsyncTURNResource, + TURNResourceWithRawResponse, + AsyncTURNResourceWithRawResponse, + TURNResourceWithStreamingResponse, + AsyncTURNResourceWithStreamingResponse, ) __all__ = [ @@ -24,10 +24,10 @@ "AsyncKeysResourceWithRawResponse", "KeysResourceWithStreamingResponse", "AsyncKeysResourceWithStreamingResponse", - "TurnResource", - "AsyncTurnResource", - "TurnResourceWithRawResponse", - "AsyncTurnResourceWithRawResponse", - "TurnResourceWithStreamingResponse", - "AsyncTurnResourceWithStreamingResponse", + "TURNResource", + "AsyncTURNResource", + "TURNResourceWithRawResponse", + "AsyncTURNResourceWithRawResponse", + "TURNResourceWithStreamingResponse", + "AsyncTURNResourceWithStreamingResponse", ] diff --git a/src/cloudflare/resources/calls/turn/turn.py b/src/cloudflare/resources/calls/turn/turn.py index db8bf498989..830fa7f663b 100644 --- a/src/cloudflare/resources/calls/turn/turn.py +++ b/src/cloudflare/resources/calls/turn/turn.py @@ -13,39 +13,39 @@ from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource -__all__ = ["TurnResource", "AsyncTurnResource"] +__all__ = ["TURNResource", "AsyncTURNResource"] -class TurnResource(SyncAPIResource): +class TURNResource(SyncAPIResource): @cached_property def keys(self) -> KeysResource: return KeysResource(self._client) @cached_property - def with_raw_response(self) -> TurnResourceWithRawResponse: - return TurnResourceWithRawResponse(self) + def with_raw_response(self) -> TURNResourceWithRawResponse: + return TURNResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> TurnResourceWithStreamingResponse: - return TurnResourceWithStreamingResponse(self) + def with_streaming_response(self) -> TURNResourceWithStreamingResponse: + return TURNResourceWithStreamingResponse(self) -class AsyncTurnResource(AsyncAPIResource): +class AsyncTURNResource(AsyncAPIResource): @cached_property def keys(self) -> AsyncKeysResource: return AsyncKeysResource(self._client) @cached_property - def with_raw_response(self) -> AsyncTurnResourceWithRawResponse: - return AsyncTurnResourceWithRawResponse(self) + def with_raw_response(self) -> AsyncTURNResourceWithRawResponse: + return AsyncTURNResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncTurnResourceWithStreamingResponse: - return AsyncTurnResourceWithStreamingResponse(self) + def with_streaming_response(self) -> AsyncTURNResourceWithStreamingResponse: + return AsyncTURNResourceWithStreamingResponse(self) -class TurnResourceWithRawResponse: - def __init__(self, turn: TurnResource) -> None: +class TURNResourceWithRawResponse: + def __init__(self, turn: TURNResource) -> None: self._turn = turn @cached_property @@ -53,8 +53,8 @@ def keys(self) -> KeysResourceWithRawResponse: return KeysResourceWithRawResponse(self._turn.keys) -class AsyncTurnResourceWithRawResponse: - def __init__(self, turn: AsyncTurnResource) -> None: +class AsyncTURNResourceWithRawResponse: + def __init__(self, turn: AsyncTURNResource) -> None: self._turn = turn @cached_property @@ -62,8 +62,8 @@ def keys(self) -> AsyncKeysResourceWithRawResponse: return AsyncKeysResourceWithRawResponse(self._turn.keys) -class TurnResourceWithStreamingResponse: - def __init__(self, turn: TurnResource) -> None: +class TURNResourceWithStreamingResponse: + def __init__(self, turn: TURNResource) -> None: self._turn = turn @cached_property @@ -71,8 +71,8 @@ def keys(self) -> KeysResourceWithStreamingResponse: return KeysResourceWithStreamingResponse(self._turn.keys) -class AsyncTurnResourceWithStreamingResponse: - def __init__(self, turn: AsyncTurnResource) -> None: +class AsyncTURNResourceWithStreamingResponse: + def __init__(self, turn: AsyncTURNResource) -> None: self._turn = turn @cached_property From 552a2fbecd71c815985571b36bed7a9868df9fdb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 07:58:05 +0000 Subject: [PATCH 006/532] feat(api): OpenAPI spec update via Stainless API (#487) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4a6241d3039..c51d58997e4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-30337a7cd5a7e8751f3555fa711c1c25aebf6791bfa5daced9765f9b234d1a05.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8f532f2d24923071fb4dd8efef5ac6d0573088cfcfc4513a148a591f9a97d8a0.yml diff --git a/api.md b/api.md index 33d264c0615..5deda047fb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7432,14 +7432,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7455,10 +7455,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7475,11 +7475,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From abfdaf8354c9b13076951b19bebbf42bcc4e7353 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 08:00:35 +0000 Subject: [PATCH 007/532] feat(api): OpenAPI spec update via Stainless API (#488) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index c51d58997e4..4a6241d3039 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8f532f2d24923071fb4dd8efef5ac6d0573088cfcfc4513a148a591f9a97d8a0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-30337a7cd5a7e8751f3555fa711c1c25aebf6791bfa5daced9765f9b234d1a05.yml diff --git a/api.md b/api.md index 5deda047fb8..33d264c0615 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7432,14 +7432,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7455,10 +7455,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7475,11 +7475,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From bcbeeed326e6ef02dfbe03acec7e6eed845abc0f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 16:15:36 +0000 Subject: [PATCH 008/532] feat(api): OpenAPI spec update via Stainless API (#489) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4a6241d3039..c51d58997e4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-30337a7cd5a7e8751f3555fa711c1c25aebf6791bfa5daced9765f9b234d1a05.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8f532f2d24923071fb4dd8efef5ac6d0573088cfcfc4513a148a591f9a97d8a0.yml diff --git a/api.md b/api.md index 33d264c0615..5deda047fb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7432,14 +7432,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7455,10 +7455,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7475,11 +7475,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 788a09058cba8f0bbcf7ddc5c03189f06cca4670 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 16:18:19 +0000 Subject: [PATCH 009/532] feat(api): OpenAPI spec update via Stainless API (#490) --- .stats.yml | 2 +- api.md | 28 +- .../cloudforce_one/requests/message.py | 76 +- .../cloudforce_one/requests/priority.py | 88 +- .../cloudforce_one/requests/requests.py | 112 +- src/cloudflare/resources/intel/whois.py | 14 +- .../access/applications/applications.py | 136 ++ .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- .../access/application_create_params.py | 1186 ++++++++++- .../access/application_create_response.py | 20 +- .../access/application_get_response.py | 20 +- .../access/application_list_response.py | 20 +- .../access/application_update_params.py | 1186 ++++++++++- .../access/application_update_response.py | 20 +- .../applications/policy_create_response.py | 2 +- .../applications/policy_get_response.py | 2 +- .../applications/policy_list_response.py | 2 +- .../applications/policy_update_response.py | 2 +- .../cloudforce_one/requests/test_message.py | 50 +- .../cloudforce_one/requests/test_priority.py | 50 +- .../cloudforce_one/test_requests.py | 82 +- tests/api_resources/intel/test_whois.py | 18 +- .../zero_trust/access/test_applications.py | 1868 +++++++++++++---- 25 files changed, 4216 insertions(+), 813 deletions(-) diff --git a/.stats.yml b/.stats.yml index c51d58997e4..180c43d61b4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8f532f2d24923071fb4dd8efef5ac6d0573088cfcfc4513a148a591f9a97d8a0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-60b75a573109cad5aa0149c739c7e355f3e2571b3a71fced4c8848e44b8c334f.yml diff --git a/api.md b/api.md index 5deda047fb8..33d264c0615 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7432,14 +7432,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7455,10 +7455,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7475,11 +7475,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/zero_trust/access/applications/applications.py b/src/cloudflare/resources/zero_trust/access/applications/applications.py index b2865d2bafb..cb837d07265 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/applications.py +++ b/src/cloudflare/resources/zero_trust/access/applications/applications.py @@ -114,6 +114,7 @@ def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -186,6 +187,9 @@ def create( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -223,6 +227,7 @@ def create( name: str | NotGiven = NOT_GIVEN, policies: List[application_create_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_create_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SaaSApplicationScimConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -258,6 +263,9 @@ def create( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -298,6 +306,7 @@ def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserSSHApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -370,6 +379,9 @@ def create( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -418,6 +430,7 @@ def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserVncApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -490,6 +503,9 @@ def create( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -523,6 +539,7 @@ def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_create_params.AppLauncherApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -551,6 +568,9 @@ def create( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -575,6 +595,7 @@ def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_create_params.DeviceEnrollmentPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -603,6 +624,9 @@ def create( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -627,6 +651,7 @@ def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserIsolationPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -655,6 +680,9 @@ def create( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -679,6 +707,7 @@ def create( domain: str | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BookmarkApplicationScimConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -704,6 +733,9 @@ def create( name: The name of the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -743,6 +775,7 @@ def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -793,6 +826,7 @@ def create( "path_cookie_attribute": path_cookie_attribute, "policies": policies, "same_site_cookie_attribute": same_site_cookie_attribute, + "scim_config": scim_config, "self_hosted_domains": self_hosted_domains, "service_auth_401_redirect": service_auth_401_redirect, "session_duration": session_duration, @@ -841,6 +875,7 @@ def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -915,6 +950,9 @@ def update( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -953,6 +991,7 @@ def update( name: str | NotGiven = NOT_GIVEN, policies: List[application_update_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_update_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SaaSApplicationScimConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -990,6 +1029,9 @@ def update( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -1031,6 +1073,7 @@ def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserSSHApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -1105,6 +1148,9 @@ def update( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -1154,6 +1200,7 @@ def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserVncApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -1228,6 +1275,9 @@ def update( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -1262,6 +1312,7 @@ def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_update_params.AppLauncherApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1292,6 +1343,9 @@ def update( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -1317,6 +1371,7 @@ def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_update_params.DeviceEnrollmentPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1347,6 +1402,9 @@ def update( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -1372,6 +1430,7 @@ def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserIsolationPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1402,6 +1461,9 @@ def update( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -1427,6 +1489,7 @@ def update( domain: str | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BookmarkApplicationScimConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1454,6 +1517,9 @@ def update( name: The name of the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -1494,6 +1560,7 @@ def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -1544,6 +1611,7 @@ def update( "path_cookie_attribute": path_cookie_attribute, "policies": policies, "same_site_cookie_attribute": same_site_cookie_attribute, + "scim_config": scim_config, "self_hosted_domains": self_hosted_domains, "service_auth_401_redirect": service_auth_401_redirect, "session_duration": session_duration, @@ -1832,6 +1900,7 @@ async def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -1904,6 +1973,9 @@ async def create( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -1941,6 +2013,7 @@ async def create( name: str | NotGiven = NOT_GIVEN, policies: List[application_create_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_create_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SaaSApplicationScimConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1976,6 +2049,9 @@ async def create( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -2016,6 +2092,7 @@ async def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserSSHApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2088,6 +2165,9 @@ async def create( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -2136,6 +2216,7 @@ async def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserVncApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2208,6 +2289,9 @@ async def create( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -2241,6 +2325,7 @@ async def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_create_params.AppLauncherApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2269,6 +2354,9 @@ async def create( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -2293,6 +2381,7 @@ async def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_create_params.DeviceEnrollmentPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2321,6 +2410,9 @@ async def create( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -2345,6 +2437,7 @@ async def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserIsolationPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2373,6 +2466,9 @@ async def create( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -2397,6 +2493,7 @@ async def create( domain: str | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BookmarkApplicationScimConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -2422,6 +2519,9 @@ async def create( name: The name of the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -2461,6 +2561,7 @@ async def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2511,6 +2612,7 @@ async def create( "path_cookie_attribute": path_cookie_attribute, "policies": policies, "same_site_cookie_attribute": same_site_cookie_attribute, + "scim_config": scim_config, "self_hosted_domains": self_hosted_domains, "service_auth_401_redirect": service_auth_401_redirect, "session_duration": session_duration, @@ -2559,6 +2661,7 @@ async def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2633,6 +2736,9 @@ async def update( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -2671,6 +2777,7 @@ async def update( name: str | NotGiven = NOT_GIVEN, policies: List[application_update_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_update_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SaaSApplicationScimConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -2708,6 +2815,9 @@ async def update( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -2749,6 +2859,7 @@ async def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserSSHApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2823,6 +2934,9 @@ async def update( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -2872,6 +2986,7 @@ async def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserVncApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2946,6 +3061,9 @@ async def update( same_site_cookie_attribute: Sets the SameSite cookie setting, which provides increased security against CSRF attacks. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + self_hosted_domains: List of domains that Access will secure. service_auth_401_redirect: Returns a 401 status code when the request is blocked by a Service Auth policy. @@ -2980,6 +3098,7 @@ async def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_update_params.AppLauncherApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -3010,6 +3129,9 @@ async def update( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -3035,6 +3157,7 @@ async def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_update_params.DeviceEnrollmentPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -3065,6 +3188,9 @@ async def update( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -3090,6 +3216,7 @@ async def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserIsolationPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -3120,6 +3247,9 @@ async def update( precedence. Items can reference existing policies or create new policies exclusive to the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + session_duration: The amount of time that tokens issued for this application will be valid. Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. @@ -3145,6 +3275,7 @@ async def update( domain: str | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BookmarkApplicationScimConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -3172,6 +3303,9 @@ async def update( name: The name of the application. + scim_config: Configuration for provisioning to this application via SCIM. This is currently + in closed beta. + tags: The tags you want assigned to an application. Tags are used to filter applications in the App Launcher dashboard. @@ -3212,6 +3346,7 @@ async def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -3262,6 +3397,7 @@ async def update( "path_cookie_attribute": path_cookie_attribute, "policies": policies, "same_site_cookie_attribute": same_site_cookie_attribute, + "scim_config": scim_config, "self_hosted_domains": self_hosted_domains, "service_auth_401_redirect": service_auth_401_redirect, "session_duration": session_duration, diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/zero_trust/access/application_create_params.py b/src/cloudflare/types/zero_trust/access/application_create_params.py index db68d8ff416..f29914b123b 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_params.py +++ b/src/cloudflare/types/zero_trust/access/application_create_params.py @@ -19,6 +19,13 @@ "SelfHostedApplicationPolicy", "SelfHostedApplicationPolicyAccessAppPolicyLink", "SelfHostedApplicationPolicyUnionMember2", + "SelfHostedApplicationScimConfig", + "SelfHostedApplicationScimConfigAuthentication", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SelfHostedApplicationScimConfigMapping", + "SelfHostedApplicationScimConfigMappingOperations", "SaaSApplication", "SaaSApplicationPolicy", "SaaSApplicationPolicyAccessAppPolicyLink", @@ -28,27 +35,76 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", + "SaaSApplicationScimConfig", + "SaaSApplicationScimConfigAuthentication", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SaaSApplicationScimConfigMapping", + "SaaSApplicationScimConfigMappingOperations", "BrowserSSHApplication", "BrowserSSHApplicationPolicy", "BrowserSSHApplicationPolicyAccessAppPolicyLink", "BrowserSSHApplicationPolicyUnionMember2", + "BrowserSSHApplicationScimConfig", + "BrowserSSHApplicationScimConfigAuthentication", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserSSHApplicationScimConfigMapping", + "BrowserSSHApplicationScimConfigMappingOperations", "BrowserVncApplication", "BrowserVncApplicationPolicy", "BrowserVncApplicationPolicyAccessAppPolicyLink", "BrowserVncApplicationPolicyUnionMember2", + "BrowserVncApplicationScimConfig", + "BrowserVncApplicationScimConfigAuthentication", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserVncApplicationScimConfigMapping", + "BrowserVncApplicationScimConfigMappingOperations", "AppLauncherApplication", "AppLauncherApplicationPolicy", "AppLauncherApplicationPolicyAccessAppPolicyLink", "AppLauncherApplicationPolicyUnionMember2", + "AppLauncherApplicationScimConfig", + "AppLauncherApplicationScimConfigAuthentication", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "AppLauncherApplicationScimConfigMapping", + "AppLauncherApplicationScimConfigMappingOperations", "DeviceEnrollmentPermissionsApplication", "DeviceEnrollmentPermissionsApplicationPolicy", "DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink", "DeviceEnrollmentPermissionsApplicationPolicyUnionMember2", + "DeviceEnrollmentPermissionsApplicationScimConfig", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationScimConfigMapping", + "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", "BrowserIsolationPermissionsApplication", "BrowserIsolationPermissionsApplicationPolicy", "BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink", "BrowserIsolationPermissionsApplicationPolicyUnionMember2", - "AccessBookmarkProps", + "BrowserIsolationPermissionsApplicationScimConfig", + "BrowserIsolationPermissionsApplicationScimConfigAuthentication", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationScimConfigMapping", + "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BookmarkApplication", + "BookmarkApplicationScimConfig", + "BookmarkApplicationScimConfigAuthentication", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BookmarkApplicationScimConfigMapping", + "BookmarkApplicationScimConfigMappingOperations", ] @@ -160,6 +216,12 @@ class SelfHostedApplication(TypedDict, total=False): attacks. """ + scim_config: SelfHostedApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + self_hosted_domains: List[SelfHostedDomains] """List of domains that Access will secure.""" @@ -184,9 +246,6 @@ class SelfHostedApplication(TypedDict, total=False): class SelfHostedApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -207,9 +266,6 @@ class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -263,6 +319,134 @@ class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): ] +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SelfHostedApplicationScimConfigAuthentication = Union[ + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SelfHostedApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SelfHostedApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: SelfHostedApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SelfHostedApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: SelfHostedApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[SelfHostedApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class SaaSApplication(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -305,6 +489,12 @@ class SaaSApplication(TypedDict, total=False): saas_app: SaaSApplicationSaaSApp + scim_config: SaaSApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + tags: List[str] """The tags you want assigned to an application. @@ -316,9 +506,6 @@ class SaaSApplication(TypedDict, total=False): class SaaSApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -339,9 +526,6 @@ class SaaSApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -397,14 +581,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(TypedDict, total name: str """The name of the IdP claim.""" + name_by_idp: Dict[str, str] + """A mapping from IdP ID to claim name.""" + class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(TypedDict, total=False): name: str """The name of the claim.""" - name_by_idp: Dict[str, str] - """A mapping from IdP ID to claim name.""" - required: bool """If the claim is required when building an OIDC token.""" @@ -473,6 +657,132 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): SaaSApplicationSaaSApp = Union[SAMLSaaSAppParam, SaaSApplicationSaaSAppAccessOIDCSaaSApp] +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(TypedDict, total=False): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SaaSApplicationScimConfigAuthentication = Union[ + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SaaSApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SaaSApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: SaaSApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SaaSApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: SaaSApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[SaaSApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class BrowserSSHApplication(TypedDict, total=False): domain: Required[str] """The primary hostname and path that Access will secure. @@ -581,6 +891,12 @@ class BrowserSSHApplication(TypedDict, total=False): attacks. """ + scim_config: BrowserSSHApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + self_hosted_domains: List[SelfHostedDomains] """List of domains that Access will secure.""" @@ -605,9 +921,6 @@ class BrowserSSHApplication(TypedDict, total=False): class BrowserSSHApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -628,9 +941,6 @@ class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -684,6 +994,134 @@ class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): ] +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserSSHApplicationScimConfigAuthentication = Union[ + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserSSHApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserSSHApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: BrowserSSHApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserSSHApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: BrowserSSHApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[BrowserSSHApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class BrowserVncApplication(TypedDict, total=False): domain: Required[str] """The primary hostname and path that Access will secure. @@ -792,6 +1230,12 @@ class BrowserVncApplication(TypedDict, total=False): attacks. """ + scim_config: BrowserVncApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + self_hosted_domains: List[SelfHostedDomains] """List of domains that Access will secure.""" @@ -816,9 +1260,6 @@ class BrowserVncApplication(TypedDict, total=False): class BrowserVncApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -839,9 +1280,6 @@ class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -895,6 +1333,134 @@ class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): ] +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserVncApplicationScimConfigAuthentication = Union[ + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserVncApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserVncApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: BrowserVncApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserVncApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: BrowserVncApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[BrowserVncApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class AppLauncherApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -926,6 +1492,12 @@ class AppLauncherApplication(TypedDict, total=False): exclusive to the application. """ + scim_config: AppLauncherApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -935,9 +1507,6 @@ class AppLauncherApplication(TypedDict, total=False): class AppLauncherApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -958,9 +1527,6 @@ class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1014,6 +1580,134 @@ class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): ] +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +AppLauncherApplicationScimConfigAuthentication = Union[ + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class AppLauncherApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class AppLauncherApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: AppLauncherApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class AppLauncherApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: AppLauncherApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[AppLauncherApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -1045,6 +1739,12 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): exclusive to the application. """ + scim_config: DeviceEnrollmentPermissionsApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -1054,9 +1754,6 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): class DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -1077,9 +1774,6 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total= name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1135,6 +1829,138 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total= ] +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic( + TypedDict, total=False +): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2( + TypedDict, total=False +): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class DeviceEnrollmentPermissionsApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: DeviceEnrollmentPermissionsApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[DeviceEnrollmentPermissionsApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class BrowserIsolationPermissionsApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -1166,6 +1992,12 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): exclusive to the application. """ + scim_config: BrowserIsolationPermissionsApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -1175,9 +2007,6 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): class BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -1198,9 +2027,6 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total= name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1256,7 +2082,139 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total= ] -class AccessBookmarkProps(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic( + TypedDict, total=False +): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2( + TypedDict, total=False +): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserIsolationPermissionsApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: BrowserIsolationPermissionsApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserIsolationPermissionsApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: BrowserIsolationPermissionsApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[BrowserIsolationPermissionsApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BookmarkApplication(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -1275,6 +2233,12 @@ class AccessBookmarkProps(TypedDict, total=False): name: str """The name of the application.""" + scim_config: BookmarkApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + tags: List[str] """The tags you want assigned to an application. @@ -1285,6 +2249,132 @@ class AccessBookmarkProps(TypedDict, total=False): """The application type.""" +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(TypedDict, total=False): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BookmarkApplicationScimConfigAuthentication = Union[ + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BookmarkApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BookmarkApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: BookmarkApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BookmarkApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: BookmarkApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[BookmarkApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + ApplicationCreateParams = Union[ SelfHostedApplication, SaaSApplication, @@ -1293,5 +2383,5 @@ class AccessBookmarkProps(TypedDict, total=False): AppLauncherApplication, DeviceEnrollmentPermissionsApplication, BrowserIsolationPermissionsApplication, - AccessBookmarkProps, + BookmarkApplication, ] diff --git a/src/cloudflare/types/zero_trust/access/application_create_response.py b/src/cloudflare/types/zero_trust/access/application_create_response.py index 08f080c6de1..359191a2ae9 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_response.py +++ b/src/cloudflare/types/zero_trust/access/application_create_response.py @@ -98,7 +98,7 @@ class SelfHostedApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -422,7 +422,7 @@ class SelfHostedApplication(BaseModel): class SaaSApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -486,14 +486,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): name: Optional[str] = None """The name of the IdP claim.""" + name_by_idp: Optional[Dict[str, str]] = None + """A mapping from IdP ID to claim name.""" + class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): name: Optional[str] = None """The name of the claim.""" - name_by_idp: Optional[Dict[str, str]] = None - """A mapping from IdP ID to claim name.""" - required: Optional[bool] = None """If the claim is required when building an OIDC token.""" @@ -751,7 +751,7 @@ class SaaSApplication(BaseModel): class BrowserSSHApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1075,7 +1075,7 @@ class BrowserSSHApplication(BaseModel): class BrowserVncApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1399,7 +1399,7 @@ class BrowserVncApplication(BaseModel): class AppLauncherApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1641,7 +1641,7 @@ class AppLauncherApplication(BaseModel): class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1885,7 +1885,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): class BrowserIsolationPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/application_get_response.py b/src/cloudflare/types/zero_trust/access/application_get_response.py index 03f90736eab..eff006cb5b3 100644 --- a/src/cloudflare/types/zero_trust/access/application_get_response.py +++ b/src/cloudflare/types/zero_trust/access/application_get_response.py @@ -98,7 +98,7 @@ class SelfHostedApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -422,7 +422,7 @@ class SelfHostedApplication(BaseModel): class SaaSApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -486,14 +486,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): name: Optional[str] = None """The name of the IdP claim.""" + name_by_idp: Optional[Dict[str, str]] = None + """A mapping from IdP ID to claim name.""" + class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): name: Optional[str] = None """The name of the claim.""" - name_by_idp: Optional[Dict[str, str]] = None - """A mapping from IdP ID to claim name.""" - required: Optional[bool] = None """If the claim is required when building an OIDC token.""" @@ -751,7 +751,7 @@ class SaaSApplication(BaseModel): class BrowserSSHApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1075,7 +1075,7 @@ class BrowserSSHApplication(BaseModel): class BrowserVncApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1399,7 +1399,7 @@ class BrowserVncApplication(BaseModel): class AppLauncherApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1641,7 +1641,7 @@ class AppLauncherApplication(BaseModel): class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1885,7 +1885,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): class BrowserIsolationPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/application_list_response.py b/src/cloudflare/types/zero_trust/access/application_list_response.py index b0c7c6e6f69..6572267f545 100644 --- a/src/cloudflare/types/zero_trust/access/application_list_response.py +++ b/src/cloudflare/types/zero_trust/access/application_list_response.py @@ -98,7 +98,7 @@ class SelfHostedApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -422,7 +422,7 @@ class SelfHostedApplication(BaseModel): class SaaSApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -486,14 +486,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): name: Optional[str] = None """The name of the IdP claim.""" + name_by_idp: Optional[Dict[str, str]] = None + """A mapping from IdP ID to claim name.""" + class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): name: Optional[str] = None """The name of the claim.""" - name_by_idp: Optional[Dict[str, str]] = None - """A mapping from IdP ID to claim name.""" - required: Optional[bool] = None """If the claim is required when building an OIDC token.""" @@ -751,7 +751,7 @@ class SaaSApplication(BaseModel): class BrowserSSHApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1075,7 +1075,7 @@ class BrowserSSHApplication(BaseModel): class BrowserVncApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1399,7 +1399,7 @@ class BrowserVncApplication(BaseModel): class AppLauncherApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1641,7 +1641,7 @@ class AppLauncherApplication(BaseModel): class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1885,7 +1885,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): class BrowserIsolationPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/application_update_params.py b/src/cloudflare/types/zero_trust/access/application_update_params.py index 1c55edcdad3..c1eebf75350 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_params.py +++ b/src/cloudflare/types/zero_trust/access/application_update_params.py @@ -19,6 +19,13 @@ "SelfHostedApplicationPolicy", "SelfHostedApplicationPolicyAccessAppPolicyLink", "SelfHostedApplicationPolicyUnionMember2", + "SelfHostedApplicationScimConfig", + "SelfHostedApplicationScimConfigAuthentication", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SelfHostedApplicationScimConfigMapping", + "SelfHostedApplicationScimConfigMappingOperations", "SaaSApplication", "SaaSApplicationPolicy", "SaaSApplicationPolicyAccessAppPolicyLink", @@ -28,27 +35,76 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", + "SaaSApplicationScimConfig", + "SaaSApplicationScimConfigAuthentication", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "SaaSApplicationScimConfigMapping", + "SaaSApplicationScimConfigMappingOperations", "BrowserSSHApplication", "BrowserSSHApplicationPolicy", "BrowserSSHApplicationPolicyAccessAppPolicyLink", "BrowserSSHApplicationPolicyUnionMember2", + "BrowserSSHApplicationScimConfig", + "BrowserSSHApplicationScimConfigAuthentication", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserSSHApplicationScimConfigMapping", + "BrowserSSHApplicationScimConfigMappingOperations", "BrowserVncApplication", "BrowserVncApplicationPolicy", "BrowserVncApplicationPolicyAccessAppPolicyLink", "BrowserVncApplicationPolicyUnionMember2", + "BrowserVncApplicationScimConfig", + "BrowserVncApplicationScimConfigAuthentication", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserVncApplicationScimConfigMapping", + "BrowserVncApplicationScimConfigMappingOperations", "AppLauncherApplication", "AppLauncherApplicationPolicy", "AppLauncherApplicationPolicyAccessAppPolicyLink", "AppLauncherApplicationPolicyUnionMember2", + "AppLauncherApplicationScimConfig", + "AppLauncherApplicationScimConfigAuthentication", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "AppLauncherApplicationScimConfigMapping", + "AppLauncherApplicationScimConfigMappingOperations", "DeviceEnrollmentPermissionsApplication", "DeviceEnrollmentPermissionsApplicationPolicy", "DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink", "DeviceEnrollmentPermissionsApplicationPolicyUnionMember2", + "DeviceEnrollmentPermissionsApplicationScimConfig", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationScimConfigMapping", + "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", "BrowserIsolationPermissionsApplication", "BrowserIsolationPermissionsApplicationPolicy", "BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink", "BrowserIsolationPermissionsApplicationPolicyUnionMember2", - "AccessBookmarkProps", + "BrowserIsolationPermissionsApplicationScimConfig", + "BrowserIsolationPermissionsApplicationScimConfigAuthentication", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationScimConfigMapping", + "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BookmarkApplication", + "BookmarkApplicationScimConfig", + "BookmarkApplicationScimConfigAuthentication", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", + "BookmarkApplicationScimConfigMapping", + "BookmarkApplicationScimConfigMappingOperations", ] @@ -160,6 +216,12 @@ class SelfHostedApplication(TypedDict, total=False): attacks. """ + scim_config: SelfHostedApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + self_hosted_domains: List[SelfHostedDomains] """List of domains that Access will secure.""" @@ -184,9 +246,6 @@ class SelfHostedApplication(TypedDict, total=False): class SelfHostedApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -207,9 +266,6 @@ class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -263,6 +319,134 @@ class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): ] +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SelfHostedApplicationScimConfigAuthentication = Union[ + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SelfHostedApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SelfHostedApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: SelfHostedApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SelfHostedApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: SelfHostedApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[SelfHostedApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class SaaSApplication(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -305,6 +489,12 @@ class SaaSApplication(TypedDict, total=False): saas_app: SaaSApplicationSaaSApp + scim_config: SaaSApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + tags: List[str] """The tags you want assigned to an application. @@ -316,9 +506,6 @@ class SaaSApplication(TypedDict, total=False): class SaaSApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -339,9 +526,6 @@ class SaaSApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -397,14 +581,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(TypedDict, total name: str """The name of the IdP claim.""" + name_by_idp: Dict[str, str] + """A mapping from IdP ID to claim name.""" + class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(TypedDict, total=False): name: str """The name of the claim.""" - name_by_idp: Dict[str, str] - """A mapping from IdP ID to claim name.""" - required: bool """If the claim is required when building an OIDC token.""" @@ -473,6 +657,132 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): SaaSApplicationSaaSApp = Union[SAMLSaaSAppParam, SaaSApplicationSaaSAppAccessOIDCSaaSApp] +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(TypedDict, total=False): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +SaaSApplicationScimConfigAuthentication = Union[ + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class SaaSApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class SaaSApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: SaaSApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class SaaSApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: SaaSApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[SaaSApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class BrowserSSHApplication(TypedDict, total=False): domain: Required[str] """The primary hostname and path that Access will secure. @@ -581,6 +891,12 @@ class BrowserSSHApplication(TypedDict, total=False): attacks. """ + scim_config: BrowserSSHApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + self_hosted_domains: List[SelfHostedDomains] """List of domains that Access will secure.""" @@ -605,9 +921,6 @@ class BrowserSSHApplication(TypedDict, total=False): class BrowserSSHApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -628,9 +941,6 @@ class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -684,6 +994,134 @@ class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): ] +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserSSHApplicationScimConfigAuthentication = Union[ + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserSSHApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserSSHApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: BrowserSSHApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserSSHApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: BrowserSSHApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[BrowserSSHApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class BrowserVncApplication(TypedDict, total=False): domain: Required[str] """The primary hostname and path that Access will secure. @@ -792,6 +1230,12 @@ class BrowserVncApplication(TypedDict, total=False): attacks. """ + scim_config: BrowserVncApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + self_hosted_domains: List[SelfHostedDomains] """List of domains that Access will secure.""" @@ -816,9 +1260,6 @@ class BrowserVncApplication(TypedDict, total=False): class BrowserVncApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -839,9 +1280,6 @@ class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -895,6 +1333,134 @@ class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): ] +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserVncApplicationScimConfigAuthentication = Union[ + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserVncApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserVncApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: BrowserVncApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserVncApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: BrowserVncApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[BrowserVncApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class AppLauncherApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -926,6 +1492,12 @@ class AppLauncherApplication(TypedDict, total=False): exclusive to the application. """ + scim_config: AppLauncherApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -935,9 +1507,6 @@ class AppLauncherApplication(TypedDict, total=False): class AppLauncherApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -958,9 +1527,6 @@ class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1014,6 +1580,134 @@ class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): ] +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +AppLauncherApplicationScimConfigAuthentication = Union[ + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class AppLauncherApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class AppLauncherApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: AppLauncherApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class AppLauncherApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: AppLauncherApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[AppLauncherApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -1045,6 +1739,12 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): exclusive to the application. """ + scim_config: DeviceEnrollmentPermissionsApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -1054,9 +1754,6 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): class DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -1077,9 +1774,6 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total= name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1135,6 +1829,138 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total= ] +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic( + TypedDict, total=False +): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2( + TypedDict, total=False +): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class DeviceEnrollmentPermissionsApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class DeviceEnrollmentPermissionsApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: DeviceEnrollmentPermissionsApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[DeviceEnrollmentPermissionsApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + class BrowserIsolationPermissionsApplication(TypedDict, total=False): type: Required[ApplicationType] """The application type.""" @@ -1166,6 +1992,12 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): exclusive to the application. """ + scim_config: BrowserIsolationPermissionsApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + session_duration: str """The amount of time that tokens issued for this application will be valid. @@ -1175,9 +2007,6 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): class BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): - id: str - """The ID of the Access policy.""" - precedence: int """The order of execution for this policy. @@ -1198,9 +2027,6 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total= name: Required[str] """The name of the Access policy.""" - id: str - """The ID of the Access policy.""" - approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1256,7 +2082,139 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total= ] -class AccessBookmarkProps(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic( + TypedDict, total=False +): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( + TypedDict, total=False +): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2( + TypedDict, total=False +): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BrowserIsolationPermissionsApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: BrowserIsolationPermissionsApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BrowserIsolationPermissionsApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: BrowserIsolationPermissionsApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[BrowserIsolationPermissionsApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + +class BookmarkApplication(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -1275,6 +2233,12 @@ class AccessBookmarkProps(TypedDict, total=False): name: str """The name of the application.""" + scim_config: BookmarkApplicationScimConfig + """Configuration for provisioning to this application via SCIM. + + This is currently in closed beta. + """ + tags: List[str] """The tags you want assigned to an application. @@ -1285,6 +2249,132 @@ class AccessBookmarkProps(TypedDict, total=False): """The application type.""" +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): + password: Required[str] + """Password used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["httpbasic"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + user: Required[str] + """User name used to authenticate with the remote SCIM service.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(TypedDict, total=False): + token: Required[str] + """Token used to authenticate with the remote SCIM service.""" + + scheme: Required[Literal["oauthbearertoken"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + +class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): + authorization_url: Required[str] + """URL used to generate the auth code used during token generation.""" + + client_id: Required[str] + """ + Client ID used to authenticate when generating a token for authenticating with + the remote SCIM service. + """ + + client_secret: Required[str] + """ + Secret used to authenticate when generating a token for authenticating with the + remove SCIM service. + """ + + scheme: Required[Literal["oauth2"]] + """The authentication scheme to use when making SCIM requests to this application.""" + + token_url: Required[str] + """ + URL used to generate the token used to authenticate with the remote SCIM + service. + """ + + scopes: List[str] + """ + The authorization scopes to request when generating the token used to + authenticate with the remove SCIM service. + """ + + +BookmarkApplicationScimConfigAuthentication = Union[ + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, + BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +] + + +class BookmarkApplicationScimConfigMappingOperations(TypedDict, total=False): + create: bool + """Whether or not this mapping applies to create (POST) operations.""" + + delete: bool + """Whether or not this mapping applies to DELETE operations.""" + + update: bool + """Whether or not this mapping applies to update (PATCH/PUT) operations.""" + + +class BookmarkApplicationScimConfigMapping(TypedDict, total=False): + schema: Required[str] + """Which SCIM resource type this mapping applies to.""" + + enabled: bool + """Whether or not this mapping is enabled.""" + + filter: str + """ + A + [SCIM filter expression](https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.2) + that matches resources that should be provisioned to this application. + """ + + operations: BookmarkApplicationScimConfigMappingOperations + """Whether or not this mapping applies to creates, updates, or deletes.""" + + transform_jsonata: str + """ + A [JSONata](https://jsonata.org/) expression that transforms the resource before + provisioning it in the application. + """ + + +class BookmarkApplicationScimConfig(TypedDict, total=False): + idp_uid: Required[str] + """ + The UID of the IdP to use as the source for SCIM resources to provision to this + application. + """ + + remote_uri: Required[str] + """The base URI for the application's SCIM-compatible API.""" + + authentication: BookmarkApplicationScimConfigAuthentication + """ + Attributes for configuring HTTP Basic authentication scheme for SCIM + provisioning to an application. + """ + + deactivate_on_delete: bool + """ + If false, propagates DELETE requests to the target application for SCIM + resources. If true, sets 'active' to false on the SCIM resource. Note: Some + targets do not support DELETE operations. + """ + + enabled: bool + """Whether SCIM provisioning is turned on for this application.""" + + mappings: Iterable[BookmarkApplicationScimConfigMapping] + """ + A list of mappings to apply to SCIM resources before provisioning them in this + application. These can transform or filter the resources to be provisioned. + """ + + ApplicationUpdateParams = Union[ SelfHostedApplication, SaaSApplication, @@ -1293,5 +2383,5 @@ class AccessBookmarkProps(TypedDict, total=False): AppLauncherApplication, DeviceEnrollmentPermissionsApplication, BrowserIsolationPermissionsApplication, - AccessBookmarkProps, + BookmarkApplication, ] diff --git a/src/cloudflare/types/zero_trust/access/application_update_response.py b/src/cloudflare/types/zero_trust/access/application_update_response.py index 187f7e57252..56900e32eec 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_response.py +++ b/src/cloudflare/types/zero_trust/access/application_update_response.py @@ -98,7 +98,7 @@ class SelfHostedApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -422,7 +422,7 @@ class SelfHostedApplication(BaseModel): class SaaSApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -486,14 +486,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource(BaseModel): name: Optional[str] = None """The name of the IdP claim.""" + name_by_idp: Optional[Dict[str, str]] = None + """A mapping from IdP ID to claim name.""" + class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): name: Optional[str] = None """The name of the claim.""" - name_by_idp: Optional[Dict[str, str]] = None - """A mapping from IdP ID to claim name.""" - required: Optional[bool] = None """If the claim is required when building an OIDC token.""" @@ -751,7 +751,7 @@ class SaaSApplication(BaseModel): class BrowserSSHApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1075,7 +1075,7 @@ class BrowserSSHApplication(BaseModel): class BrowserVncApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1399,7 +1399,7 @@ class BrowserVncApplication(BaseModel): class AppLauncherApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1641,7 +1641,7 @@ class AppLauncherApplication(BaseModel): class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1885,7 +1885,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): class BrowserIsolationPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py index 5efd40742e1..dc60336edb5 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py @@ -13,7 +13,7 @@ class PolicyCreateResponse(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py index 44fc880d8a8..0e236f6d6e4 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py @@ -13,7 +13,7 @@ class PolicyGetResponse(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py index ac71a16fb6e..26df53cf1e6 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py @@ -13,7 +13,7 @@ class PolicyListResponse(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py index c7bf3a68e3a..0e34d6c8c05 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py @@ -13,7 +13,7 @@ class PolicyUpdateResponse(BaseModel): id: Optional[str] = None - """The ID of the Access policy.""" + """UUID""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/zero_trust/access/test_applications.py b/tests/api_resources/zero_trust/access/test_applications.py index 836c78af06b..df34f66d7ef 100644 --- a/tests/api_resources/zero_trust/access/test_applications.py +++ b/tests/api_resources/zero_trust/access/test_applications.py @@ -73,21 +73,54 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -170,20 +203,7 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -209,6 +229,52 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N "sp_entity_id": "example unique name", "sso_endpoint": "https://example.cloudflareaccess.com/cdn-cgi/access/sso/saml/b3f58a2b414e0b51d45c8c2af26fccca0e27c63763c426fa52f98dcf0b3b3bfd", }, + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, tags=["engineers", "engineers", "engineers"], type="saas", ) @@ -302,21 +368,54 @@ def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -421,21 +520,54 @@ def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -512,20 +644,53 @@ def test_method_create_with_all_params_overload_5(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -594,20 +759,53 @@ def test_method_create_with_all_params_overload_6(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -676,20 +874,53 @@ def test_method_create_with_all_params_overload_7(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -754,6 +985,52 @@ def test_method_create_with_all_params_overload_8(self, client: Cloudflare) -> N domain="https://mybookmark.com", logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, tags=["engineers", "engineers", "engineers"], type="bookmark", ) @@ -849,21 +1126,54 @@ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -952,20 +1262,7 @@ def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> N ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -991,6 +1288,52 @@ def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> N "sp_entity_id": "example unique name", "sso_endpoint": "https://example.cloudflareaccess.com/cdn-cgi/access/sso/saml/b3f58a2b414e0b51d45c8c2af26fccca0e27c63763c426fa52f98dcf0b3b3bfd", }, + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, tags=["engineers", "engineers", "engineers"], type="saas", ) @@ -1090,21 +1433,54 @@ def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -1215,21 +1591,54 @@ def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -1312,20 +1721,53 @@ def test_method_update_with_all_params_overload_5(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -1400,20 +1842,53 @@ def test_method_update_with_all_params_overload_6(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -1488,20 +1963,53 @@ def test_method_update_with_all_params_overload_7(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -1572,6 +2080,52 @@ def test_method_update_with_all_params_overload_8(self, client: Cloudflare) -> N domain="https://mybookmark.com", logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, tags=["engineers", "engineers", "engineers"], type="bookmark", ) @@ -1911,21 +2465,54 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -2008,20 +2595,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -2047,6 +2621,52 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn "sp_entity_id": "example unique name", "sso_endpoint": "https://example.cloudflareaccess.com/cdn-cgi/access/sso/saml/b3f58a2b414e0b51d45c8c2af26fccca0e27c63763c426fa52f98dcf0b3b3bfd", }, + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, tags=["engineers", "engineers", "engineers"], type="saas", ) @@ -2140,21 +2760,54 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -2259,21 +2912,54 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -2350,20 +3036,53 @@ async def test_method_create_with_all_params_overload_5(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -2432,20 +3151,53 @@ async def test_method_create_with_all_params_overload_6(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -2514,20 +3266,53 @@ async def test_method_create_with_all_params_overload_7(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationCreateResponse], application, path=["response"]) @@ -2592,6 +3377,52 @@ async def test_method_create_with_all_params_overload_8(self, async_client: Asyn domain="https://mybookmark.com", logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, tags=["engineers", "engineers", "engineers"], type="bookmark", ) @@ -2687,21 +3518,54 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -2790,20 +3654,7 @@ async def test_method_update_with_all_params_overload_2(self, async_client: Asyn ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -2829,6 +3680,52 @@ async def test_method_update_with_all_params_overload_2(self, async_client: Asyn "sp_entity_id": "example unique name", "sso_endpoint": "https://example.cloudflareaccess.com/cdn-cgi/access/sso/saml/b3f58a2b414e0b51d45c8c2af26fccca0e27c63763c426fa52f98dcf0b3b3bfd", }, + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, tags=["engineers", "engineers", "engineers"], type="saas", ) @@ -2928,21 +3825,54 @@ async def test_method_update_with_all_params_overload_3(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -3053,21 +3983,54 @@ async def test_method_update_with_all_params_overload_4(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], same_site_cookie_attribute="strict", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, self_hosted_domains=["test.example.com/admin", "test.anotherexample.com/staff"], service_auth_401_redirect=True, session_duration="24h", @@ -3150,20 +4113,53 @@ async def test_method_update_with_all_params_overload_5(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -3238,20 +4234,53 @@ async def test_method_update_with_all_params_overload_6(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -3326,20 +4355,53 @@ async def test_method_update_with_all_params_overload_7(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[ - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, + policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - { - "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "precedence": 0, - }, - ], + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, session_duration="24h", ) assert_matches_type(Optional[ApplicationUpdateResponse], application, path=["response"]) @@ -3410,6 +4472,52 @@ async def test_method_update_with_all_params_overload_8(self, async_client: Asyn domain="https://mybookmark.com", logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", + scim_config={ + "authentication": { + "password": "string", + "scheme": "httpbasic", + "user": "string", + }, + "deactivate_on_delete": True, + "enabled": True, + "idp_uid": "string", + "mappings": [ + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + { + "enabled": True, + "filter": 'title pr or userType eq "Intern"', + "operations": { + "create": True, + "delete": True, + "update": True, + }, + "schema": "urn:ietf:params:scim:schemas:core:2.0:User", + "transform_jsonata": "$merge([$, {'userName': $substringBefore($.userName, '@') & '+test@' & $substringAfter($.userName, '@')}])", + }, + ], + "remote_uri": "string", + }, tags=["engineers", "engineers", "engineers"], type="bookmark", ) From 954be3744aa5c5cb8bc7dd99c65b0c2fb3d541ec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 17:29:56 +0000 Subject: [PATCH 010/532] feat(api): update via SDK Studio (#491) --- .../types/rulesets/phase_get_response.py | 40 ++++++++++--------- .../types/rulesets/phase_update_response.py | 40 ++++++++++--------- .../rulesets/phases/version_get_response.py | 40 ++++++++++--------- .../types/rulesets/rule_create_response.py | 40 ++++++++++--------- .../types/rulesets/rule_delete_response.py | 40 ++++++++++--------- .../types/rulesets/rule_edit_response.py | 40 ++++++++++--------- .../types/rulesets/ruleset_create_response.py | 40 ++++++++++--------- .../types/rulesets/ruleset_get_response.py | 40 ++++++++++--------- .../types/rulesets/ruleset_update_response.py | 40 ++++++++++--------- .../types/rulesets/version_get_response.py | 40 ++++++++++--------- .../rulesets/versions/by_tag_get_response.py | 40 ++++++++++--------- 11 files changed, 242 insertions(+), 198 deletions(-) diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index e3d6988d4f7..476a9254497 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index c1054efae2b..a92b28cb216 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index 0a9474bba0a..bf04a129360 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from ..kind import Kind from ..phase import Phase from ..logging import Logging +from ...._utils import PropertyInfo from ..log_rule import LogRule from ...._models import BaseModel from ..skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index c5256f8ae0b..9a729d3fbe1 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 073fedab4b0..1b6810d585e 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 88169813921..3bf0100ef6f 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index f3694cb0358..f87b58ceec8 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index e83fd9354d0..d5864df9b91 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index cab3e8851ce..d2aaaa91d6f 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index b90e376ea65..4d61f17e3ec 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from .kind import Kind from .phase import Phase from .logging import Logging +from ..._utils import PropertyInfo from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index fc90c1d1689..62def70b1fd 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -2,11 +2,12 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, Annotated from ..kind import Kind from ..phase import Phase from ..logging import Logging +from ...._utils import PropertyInfo from ..log_rule import LogRule from ...._models import BaseModel from ..skip_rule import SkipRule @@ -96,23 +97,26 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -Rule = Union[ - BlockRule, - ChallengeRule, - CompressResponseRule, - ExecuteRule, - JSChallengeRule, - LogRule, - ManagedChallengeRule, - RedirectRule, - RewriteRule, - RouteRule, - ScoreRule, - ServeErrorRule, - SetConfigRule, - SkipRule, - SetCacheSettingsRule, - RuleRulesetsLogCustomFieldRule, +Rule = Annotated[ + Union[ + BlockRule, + ChallengeRule, + CompressResponseRule, + ExecuteRule, + JSChallengeRule, + LogRule, + ManagedChallengeRule, + RedirectRule, + RewriteRule, + RouteRule, + ScoreRule, + ServeErrorRule, + SetConfigRule, + SkipRule, + SetCacheSettingsRule, + RuleRulesetsLogCustomFieldRule, + ], + PropertyInfo(discriminator="action"), ] From 7ee5b45b274ae0df15667c84f2b666a783c2c3ed Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 18:07:49 +0000 Subject: [PATCH 011/532] feat(api): OpenAPI spec update via Stainless API (#492) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 180c43d61b4..46bc4446e53 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-60b75a573109cad5aa0149c739c7e355f3e2571b3a71fced4c8848e44b8c334f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c29a8e5a4a9b932030192272e03404b274e9119c670d493d19150b93d01c2b51.yml From c3990ac7badfee945dcc279a2ba9d9dce8ec02d9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 18:57:51 +0000 Subject: [PATCH 012/532] feat(api): update via SDK Studio (#493) --- .stats.yml | 2 +- api.md | 1 + .../zero_trust/access/applications/policies.py | 11 ++++++----- .../types/zero_trust/access/__init__.py | 1 + .../access/application_create_params.py | 15 ++++++++------- .../access/application_create_response.py | 15 ++++++++------- .../zero_trust/access/application_get_response.py | 15 ++++++++------- .../access/application_list_response.py | 15 ++++++++------- .../access/application_update_params.py | 15 ++++++++------- .../access/application_update_response.py | 15 ++++++++------- .../access/applications/policy_create_params.py | 5 +++-- .../access/applications/policy_create_response.py | 4 ++-- .../access/applications/policy_get_response.py | 4 ++-- .../access/applications/policy_list_response.py | 4 ++-- .../access/applications/policy_update_params.py | 5 +++-- .../access/applications/policy_update_response.py | 4 ++-- .../types/zero_trust/access/decision.py | 7 +++++++ 17 files changed, 78 insertions(+), 60 deletions(-) create mode 100644 src/cloudflare/types/zero_trust/access/decision.py diff --git a/.stats.yml b/.stats.yml index 46bc4446e53..180c43d61b4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c29a8e5a4a9b932030192272e03404b274e9119c670d493d19150b93d01c2b51.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-60b75a573109cad5aa0149c739c7e355f3e2571b3a71fced4c8848e44b8c334f.yml diff --git a/api.md b/api.md index 33d264c0615..fbcb03a1702 100644 --- a/api.md +++ b/api.md @@ -5090,6 +5090,7 @@ from cloudflare.types.zero_trust.access import ( Application, ApplicationType, CORSHeaders, + Decision, SaaSAppNameFormat, SaaSAppNameIDFormat, SaaSAppSource, diff --git a/src/cloudflare/resources/zero_trust/access/applications/policies.py b/src/cloudflare/resources/zero_trust/access/applications/policies.py index 9c7b8824bd3..b5c9f110dee 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/policies.py +++ b/src/cloudflare/resources/zero_trust/access/applications/policies.py @@ -3,7 +3,6 @@ from __future__ import annotations from typing import Type, Iterable, Optional, cast -from typing_extensions import Literal import httpx @@ -26,6 +25,8 @@ AsyncPaginator, make_request_options, ) +from .....types.zero_trust.access import Decision +from .....types.zero_trust.access.decision import Decision from .....types.zero_trust.access_rule_param import AccessRuleParam from .....types.zero_trust.access.applications import policy_create_params, policy_update_params from .....types.zero_trust.access.applications.policy_get_response import PolicyGetResponse @@ -51,7 +52,7 @@ def create( self, uuid: str, *, - decision: Literal["allow", "deny", "non_identity", "bypass"], + decision: Decision, include: Iterable[AccessRuleParam], name: str, account_id: str | NotGiven = NOT_GIVEN, @@ -174,7 +175,7 @@ def update( uuid: str, *, uuid1: str, - decision: Literal["allow", "deny", "non_identity", "bypass"], + decision: Decision, include: Iterable[AccessRuleParam], name: str, account_id: str | NotGiven = NOT_GIVEN, @@ -493,7 +494,7 @@ async def create( self, uuid: str, *, - decision: Literal["allow", "deny", "non_identity", "bypass"], + decision: Decision, include: Iterable[AccessRuleParam], name: str, account_id: str | NotGiven = NOT_GIVEN, @@ -616,7 +617,7 @@ async def update( uuid: str, *, uuid1: str, - decision: Literal["allow", "deny", "non_identity", "bypass"], + decision: Decision, include: Iterable[AccessRuleParam], name: str, account_id: str | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/types/zero_trust/access/__init__.py b/src/cloudflare/types/zero_trust/access/__init__.py index fb96bfc62bc..8b8d5c829cf 100644 --- a/src/cloudflare/types/zero_trust/access/__init__.py +++ b/src/cloudflare/types/zero_trust/access/__init__.py @@ -4,6 +4,7 @@ from .tag import Tag as Tag from .bookmark import Bookmark as Bookmark +from .decision import Decision as Decision from .access_user import AccessUser as AccessUser from .certificate import Certificate as Certificate from .custom_page import CustomPage as CustomPage diff --git a/src/cloudflare/types/zero_trust/access/application_create_params.py b/src/cloudflare/types/zero_trust/access/application_create_params.py index f29914b123b..d9df78112c3 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_params.py +++ b/src/cloudflare/types/zero_trust/access/application_create_params.py @@ -5,6 +5,7 @@ from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict +from .decision import Decision from .allowed_idps import AllowedIdPs from .application_type import ApplicationType from ..access_rule_param import AccessRuleParam @@ -254,7 +255,7 @@ class SelfHostedApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -514,7 +515,7 @@ class SaaSApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class SaaSApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -929,7 +930,7 @@ class BrowserSSHApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -1268,7 +1269,7 @@ class BrowserVncApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -1515,7 +1516,7 @@ class AppLauncherApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -1762,7 +1763,7 @@ class DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -2015,7 +2016,7 @@ class BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] diff --git a/src/cloudflare/types/zero_trust/access/application_create_response.py b/src/cloudflare/types/zero_trust/access/application_create_response.py index 359191a2ae9..40097b24575 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_response.py +++ b/src/cloudflare/types/zero_trust/access/application_create_response.py @@ -6,6 +6,7 @@ from pydantic import Field as FieldInfo +from .decision import Decision from ...._models import BaseModel from ..access_rule import AccessRule from .allowed_idps import AllowedIdPs @@ -111,7 +112,7 @@ class SelfHostedApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -435,7 +436,7 @@ class SaaSApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -764,7 +765,7 @@ class BrowserSSHApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1088,7 +1089,7 @@ class BrowserVncApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1412,7 +1413,7 @@ class AppLauncherApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1654,7 +1655,7 @@ class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1898,7 +1899,7 @@ class BrowserIsolationPermissionsApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None diff --git a/src/cloudflare/types/zero_trust/access/application_get_response.py b/src/cloudflare/types/zero_trust/access/application_get_response.py index eff006cb5b3..7b3c0f9a014 100644 --- a/src/cloudflare/types/zero_trust/access/application_get_response.py +++ b/src/cloudflare/types/zero_trust/access/application_get_response.py @@ -6,6 +6,7 @@ from pydantic import Field as FieldInfo +from .decision import Decision from ...._models import BaseModel from ..access_rule import AccessRule from .allowed_idps import AllowedIdPs @@ -111,7 +112,7 @@ class SelfHostedApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -435,7 +436,7 @@ class SaaSApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -764,7 +765,7 @@ class BrowserSSHApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1088,7 +1089,7 @@ class BrowserVncApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1412,7 +1413,7 @@ class AppLauncherApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1654,7 +1655,7 @@ class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1898,7 +1899,7 @@ class BrowserIsolationPermissionsApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None diff --git a/src/cloudflare/types/zero_trust/access/application_list_response.py b/src/cloudflare/types/zero_trust/access/application_list_response.py index 6572267f545..ece348346d2 100644 --- a/src/cloudflare/types/zero_trust/access/application_list_response.py +++ b/src/cloudflare/types/zero_trust/access/application_list_response.py @@ -6,6 +6,7 @@ from pydantic import Field as FieldInfo +from .decision import Decision from ...._models import BaseModel from ..access_rule import AccessRule from .allowed_idps import AllowedIdPs @@ -111,7 +112,7 @@ class SelfHostedApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -435,7 +436,7 @@ class SaaSApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -764,7 +765,7 @@ class BrowserSSHApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1088,7 +1089,7 @@ class BrowserVncApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1412,7 +1413,7 @@ class AppLauncherApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1654,7 +1655,7 @@ class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1898,7 +1899,7 @@ class BrowserIsolationPermissionsApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None diff --git a/src/cloudflare/types/zero_trust/access/application_update_params.py b/src/cloudflare/types/zero_trust/access/application_update_params.py index c1eebf75350..d4777baab75 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_params.py +++ b/src/cloudflare/types/zero_trust/access/application_update_params.py @@ -5,6 +5,7 @@ from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict +from .decision import Decision from .allowed_idps import AllowedIdPs from .application_type import ApplicationType from ..access_rule_param import AccessRuleParam @@ -254,7 +255,7 @@ class SelfHostedApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -514,7 +515,7 @@ class SaaSApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class SaaSApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -929,7 +930,7 @@ class BrowserSSHApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -1268,7 +1269,7 @@ class BrowserVncApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -1515,7 +1516,7 @@ class AppLauncherApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -1762,7 +1763,7 @@ class DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] @@ -2015,7 +2016,7 @@ class BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] diff --git a/src/cloudflare/types/zero_trust/access/application_update_response.py b/src/cloudflare/types/zero_trust/access/application_update_response.py index 56900e32eec..eb34f2f3f49 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_response.py +++ b/src/cloudflare/types/zero_trust/access/application_update_response.py @@ -6,6 +6,7 @@ from pydantic import Field as FieldInfo +from .decision import Decision from ...._models import BaseModel from ..access_rule import AccessRule from .allowed_idps import AllowedIdPs @@ -111,7 +112,7 @@ class SelfHostedApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -435,7 +436,7 @@ class SaaSApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -764,7 +765,7 @@ class BrowserSSHApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1088,7 +1089,7 @@ class BrowserVncApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1412,7 +1413,7 @@ class AppLauncherApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1654,7 +1655,7 @@ class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None @@ -1898,7 +1899,7 @@ class BrowserIsolationPermissionsApplicationPolicy(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py index 275ff4562b6..358425ac3f4 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py @@ -3,8 +3,9 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Required, TypedDict +from ..decision import Decision from ...access_rule_param import AccessRuleParam from .approval_group_param import ApprovalGroupParam @@ -12,7 +13,7 @@ class PolicyCreateParams(TypedDict, total=False): - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py index dc60336edb5..4b8e4a6d329 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py @@ -2,8 +2,8 @@ from typing import List, Optional from datetime import datetime -from typing_extensions import Literal +from ..decision import Decision from ....._models import BaseModel from ...access_rule import AccessRule from .approval_group import ApprovalGroup @@ -26,7 +26,7 @@ class PolicyCreateResponse(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py index 0e236f6d6e4..8f6eac8cf3f 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py @@ -2,8 +2,8 @@ from typing import List, Optional from datetime import datetime -from typing_extensions import Literal +from ..decision import Decision from ....._models import BaseModel from ...access_rule import AccessRule from .approval_group import ApprovalGroup @@ -26,7 +26,7 @@ class PolicyGetResponse(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py index 26df53cf1e6..176b10bf16d 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py @@ -2,8 +2,8 @@ from typing import List, Optional from datetime import datetime -from typing_extensions import Literal +from ..decision import Decision from ....._models import BaseModel from ...access_rule import AccessRule from .approval_group import ApprovalGroup @@ -26,7 +26,7 @@ class PolicyListResponse(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py index 31a9c3952b4..eab91a04759 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py @@ -3,8 +3,9 @@ from __future__ import annotations from typing import Iterable -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Required, TypedDict +from ..decision import Decision from ...access_rule_param import AccessRuleParam from .approval_group_param import ApprovalGroupParam @@ -15,7 +16,7 @@ class PolicyUpdateParams(TypedDict, total=False): uuid1: Required[str] """UUID""" - decision: Required[Literal["allow", "deny", "non_identity", "bypass"]] + decision: Required[Decision] """The action Access will take if a user matches this policy.""" include: Required[Iterable[AccessRuleParam]] diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py index 0e34d6c8c05..b5c91e2230c 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py @@ -2,8 +2,8 @@ from typing import List, Optional from datetime import datetime -from typing_extensions import Literal +from ..decision import Decision from ....._models import BaseModel from ...access_rule import AccessRule from .approval_group import ApprovalGroup @@ -26,7 +26,7 @@ class PolicyUpdateResponse(BaseModel): created_at: Optional[datetime] = None - decision: Optional[Literal["allow", "deny", "non_identity", "bypass"]] = None + decision: Optional[Decision] = None """The action Access will take if a user matches this policy.""" exclude: Optional[List[AccessRule]] = None diff --git a/src/cloudflare/types/zero_trust/access/decision.py b/src/cloudflare/types/zero_trust/access/decision.py new file mode 100644 index 00000000000..25de36df150 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/decision.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +__all__ = ["Decision"] + +Decision = Literal["allow", "deny", "non_identity", "bypass"] From 8f99fa1e3096b7b2d615cdf1b53683a66e0185a9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 19:20:55 +0000 Subject: [PATCH 013/532] feat(api): OpenAPI spec update via Stainless API (#494) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 180c43d61b4..46bc4446e53 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-60b75a573109cad5aa0149c739c7e355f3e2571b3a71fced4c8848e44b8c334f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c29a8e5a4a9b932030192272e03404b274e9119c670d493d19150b93d01c2b51.yml From acd3c505a041fe95bb37669959bec1c26beb648e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 19:23:34 +0000 Subject: [PATCH 014/532] feat(api): OpenAPI spec update via Stainless API (#495) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 46bc4446e53..d3f7578d0d1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c29a8e5a4a9b932030192272e03404b274e9119c670d493d19150b93d01c2b51.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-09cd12c71c1bf4d47a96a1b013ea92dfdfbac4647336dd53fdda685632b3c43a.yml diff --git a/api.md b/api.md index fbcb03a1702..7f1dda06e5e 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7433,14 +7433,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7456,10 +7456,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7476,11 +7476,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 31e8cd3e99631d158632edb22ce30e987c3669d0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 13:43:59 +0000 Subject: [PATCH 015/532] feat(api): OpenAPI spec update via Stainless API (#496) --- .stats.yml | 2 +- SECURITY.md | 27 +++++ api.md | 28 ++--- requirements-dev.lock | 4 +- requirements.lock | 4 +- src/cloudflare/_models.py | 20 +++- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- tests/test_models.py | 8 +- tests/test_transform.py | 22 ++-- 19 files changed, 335 insertions(+), 315 deletions(-) create mode 100644 SECURITY.md diff --git a/.stats.yml b/.stats.yml index d3f7578d0d1..63842570e7a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-09cd12c71c1bf4d47a96a1b013ea92dfdfbac4647336dd53fdda685632b3c43a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-233400c5ae165d478f6a8ca3dfc099961cbca90f3b175f1e14b631a7cb298f41.yml diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..8cd70e5e93b --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainlessapi.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Cloudflare please follow the respective company's security reporting guidelines. + +### Cloudflare Terms and Policies + +Please contact api@cloudflare.com for any questions or concerns regarding security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/api.md b/api.md index 7f1dda06e5e..fbcb03a1702 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7433,14 +7433,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7456,10 +7456,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7476,11 +7476,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/requirements-dev.lock b/requirements-dev.lock index 736dff54fa6..938a9f70eae 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -59,9 +59,9 @@ pluggy==1.3.0 # via pytest py==1.11.0 # via pytest -pydantic==2.4.2 +pydantic==2.7.1 # via cloudflare -pydantic-core==2.10.1 +pydantic-core==2.18.2 # via pydantic pyright==1.1.359 pytest==7.1.1 diff --git a/requirements.lock b/requirements.lock index 69b72930885..ec0db0c5222 100644 --- a/requirements.lock +++ b/requirements.lock @@ -29,9 +29,9 @@ httpx==0.25.2 idna==3.4 # via anyio # via httpx -pydantic==2.4.2 +pydantic==2.7.1 # via cloudflare -pydantic-core==2.10.1 +pydantic-core==2.18.2 # via pydantic sniffio==1.3.0 # via anyio diff --git a/src/cloudflare/_models.py b/src/cloudflare/_models.py index ff3f54e2cdc..75c68cc7302 100644 --- a/src/cloudflare/_models.py +++ b/src/cloudflare/_models.py @@ -62,7 +62,7 @@ from ._constants import RAW_RESPONSE_HEADER if TYPE_CHECKING: - from pydantic_core.core_schema import ModelField, ModelFieldsSchema + from pydantic_core.core_schema import ModelField, LiteralSchema, ModelFieldsSchema __all__ = ["BaseModel", "GenericModel"] @@ -251,7 +251,9 @@ def model_dump( exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, - warnings: bool = True, + warnings: bool | Literal["none", "warn", "error"] = True, + context: dict[str, Any] | None = None, + serialize_as_any: bool = False, ) -> dict[str, Any]: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump @@ -279,6 +281,10 @@ def model_dump( raise ValueError("round_trip is only supported in Pydantic v2") if warnings != True: raise ValueError("warnings is only supported in Pydantic v2") + if context is not None: + raise ValueError("context is only supported in Pydantic v2") + if serialize_as_any != False: + raise ValueError("serialize_as_any is only supported in Pydantic v2") return super().dict( # pyright: ignore[reportDeprecated] include=include, exclude=exclude, @@ -300,7 +306,9 @@ def model_dump_json( exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, - warnings: bool = True, + warnings: bool | Literal["none", "warn", "error"] = True, + context: dict[str, Any] | None = None, + serialize_as_any: bool = False, ) -> str: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json @@ -324,6 +332,10 @@ def model_dump_json( raise ValueError("round_trip is only supported in Pydantic v2") if warnings != True: raise ValueError("warnings is only supported in Pydantic v2") + if context is not None: + raise ValueError("context is only supported in Pydantic v2") + if serialize_as_any != False: + raise ValueError("serialize_as_any is only supported in Pydantic v2") return super().json( # type: ignore[reportDeprecated] indent=indent, include=include, @@ -550,7 +562,7 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, field_schema = field["schema"] if field_schema["type"] == "literal": - for entry in field_schema["expected"]: + for entry in cast("LiteralSchema", field_schema)["expected"]: if isinstance(entry, str): mapping[entry] = variant else: diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/test_models.py b/tests/test_models.py index 3e07792f3b5..799673b5caa 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -31,7 +31,7 @@ class NestedModel(BaseModel): # mismatched types m = NestedModel.construct(nested="hello!") - assert m.nested == "hello!" + assert cast(Any, m.nested) == "hello!" def test_optional_nested_model() -> None: @@ -48,7 +48,7 @@ class NestedModel(BaseModel): # mismatched types m3 = NestedModel.construct(nested={"foo"}) assert isinstance(cast(Any, m3.nested), set) - assert m3.nested == {"foo"} + assert cast(Any, m3.nested) == {"foo"} def test_list_nested_model() -> None: @@ -323,7 +323,7 @@ class Model(BaseModel): assert len(m.items) == 2 assert isinstance(m.items[0], Submodel1) assert m.items[0].level == -1 - assert m.items[1] == 156 + assert cast(Any, m.items[1]) == 156 def test_union_of_lists() -> None: @@ -355,7 +355,7 @@ class Model(BaseModel): assert len(m.items) == 2 assert isinstance(m.items[0], SubModel1) assert m.items[0].level == -1 - assert m.items[1] == 156 + assert cast(Any, m.items[1]) == 156 def test_dict_of_union() -> None: diff --git a/tests/test_transform.py b/tests/test_transform.py index 15abb39172e..bc21b7cdb00 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -260,20 +260,22 @@ class MyModel(BaseModel): @parametrize @pytest.mark.asyncio async def test_pydantic_model_to_dictionary(use_async: bool) -> None: - assert await transform(MyModel(foo="hi!"), Any, use_async) == {"foo": "hi!"} - assert await transform(MyModel.construct(foo="hi!"), Any, use_async) == {"foo": "hi!"} + assert cast(Any, await transform(MyModel(foo="hi!"), Any, use_async)) == {"foo": "hi!"} + assert cast(Any, await transform(MyModel.construct(foo="hi!"), Any, use_async)) == {"foo": "hi!"} @parametrize @pytest.mark.asyncio async def test_pydantic_empty_model(use_async: bool) -> None: - assert await transform(MyModel.construct(), Any, use_async) == {} + assert cast(Any, await transform(MyModel.construct(), Any, use_async)) == {} @parametrize @pytest.mark.asyncio async def test_pydantic_unknown_field(use_async: bool) -> None: - assert await transform(MyModel.construct(my_untyped_field=True), Any, use_async) == {"my_untyped_field": True} + assert cast(Any, await transform(MyModel.construct(my_untyped_field=True), Any, use_async)) == { + "my_untyped_field": True + } @parametrize @@ -285,7 +287,7 @@ async def test_pydantic_mismatched_types(use_async: bool) -> None: params = await transform(model, Any, use_async) else: params = await transform(model, Any, use_async) - assert params == {"foo": True} + assert cast(Any, params) == {"foo": True} @parametrize @@ -297,7 +299,7 @@ async def test_pydantic_mismatched_object_type(use_async: bool) -> None: params = await transform(model, Any, use_async) else: params = await transform(model, Any, use_async) - assert params == {"foo": {"hello": "world"}} + assert cast(Any, params) == {"foo": {"hello": "world"}} class ModelNestedObjects(BaseModel): @@ -309,7 +311,7 @@ class ModelNestedObjects(BaseModel): async def test_pydantic_nested_objects(use_async: bool) -> None: model = ModelNestedObjects.construct(nested={"foo": "stainless"}) assert isinstance(model.nested, MyModel) - assert await transform(model, Any, use_async) == {"nested": {"foo": "stainless"}} + assert cast(Any, await transform(model, Any, use_async)) == {"nested": {"foo": "stainless"}} class ModelWithDefaultField(BaseModel): @@ -325,19 +327,19 @@ async def test_pydantic_default_field(use_async: bool) -> None: model = ModelWithDefaultField.construct() assert model.with_none_default is None assert model.with_str_default == "foo" - assert await transform(model, Any, use_async) == {} + assert cast(Any, await transform(model, Any, use_async)) == {} # should be included when the default value is explicitly given model = ModelWithDefaultField.construct(with_none_default=None, with_str_default="foo") assert model.with_none_default is None assert model.with_str_default == "foo" - assert await transform(model, Any, use_async) == {"with_none_default": None, "with_str_default": "foo"} + assert cast(Any, await transform(model, Any, use_async)) == {"with_none_default": None, "with_str_default": "foo"} # should be included when a non-default value is explicitly given model = ModelWithDefaultField.construct(with_none_default="bar", with_str_default="baz") assert model.with_none_default == "bar" assert model.with_str_default == "baz" - assert await transform(model, Any, use_async) == {"with_none_default": "bar", "with_str_default": "baz"} + assert cast(Any, await transform(model, Any, use_async)) == {"with_none_default": "bar", "with_str_default": "baz"} class TypedDictIterableUnion(TypedDict): From 63fed97d6f1553003dad4c3e0222e847f254f5b9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 13:46:27 +0000 Subject: [PATCH 016/532] feat(api): OpenAPI spec update via Stainless API (#497) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 63842570e7a..d3f7578d0d1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-233400c5ae165d478f6a8ca3dfc099961cbca90f3b175f1e14b631a7cb298f41.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-09cd12c71c1bf4d47a96a1b013ea92dfdfbac4647336dd53fdda685632b3c43a.yml diff --git a/api.md b/api.md index fbcb03a1702..7f1dda06e5e 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7433,14 +7433,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7456,10 +7456,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7476,11 +7476,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From b17ea8ad063fdc5851c9906305fa48f0452d4483 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 13:55:02 +0000 Subject: [PATCH 017/532] feat(api): OpenAPI spec update via Stainless API (#498) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index d3f7578d0d1..63842570e7a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-09cd12c71c1bf4d47a96a1b013ea92dfdfbac4647336dd53fdda685632b3c43a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-233400c5ae165d478f6a8ca3dfc099961cbca90f3b175f1e14b631a7cb298f41.yml diff --git a/api.md b/api.md index 7f1dda06e5e..fbcb03a1702 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7433,14 +7433,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7456,10 +7456,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7476,11 +7476,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 48450deaf77856a2b681946fbb138a5c19943f34 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 13:57:26 +0000 Subject: [PATCH 018/532] feat(api): OpenAPI spec update via Stainless API (#499) --- .stats.yml | 2 +- .../resources/ai_gateway/ai_gateway.py | 40 ++++--- src/cloudflare/resources/ai_gateway/logs.py | 4 + .../ai_gateway/ai_gateway_create_params.py | 7 +- .../ai_gateway/ai_gateway_create_response.py | 5 +- .../ai_gateway/ai_gateway_delete_response.py | 5 +- .../ai_gateway/ai_gateway_get_response.py | 5 +- .../ai_gateway/ai_gateway_list_params.py | 1 + .../ai_gateway/ai_gateway_list_response.py | 5 +- .../ai_gateway/ai_gateway_update_params.py | 4 - .../ai_gateway/ai_gateway_update_response.py | 5 +- tests/api_resources/ai_gateway/test_logs.py | 20 ++-- tests/api_resources/test_ai_gateway.py | 110 ++++++------------ 13 files changed, 86 insertions(+), 127 deletions(-) diff --git a/.stats.yml b/.stats.yml index 63842570e7a..df3052cd59f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-233400c5ae165d478f6a8ca3dfc099961cbca90f3b175f1e14b631a7cb298f41.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e9768930aab7041f58b5f317137699bbd040d5be0864adcee08df4a026b99300.yml diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 44734436ea9..7c08856dc34 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -60,11 +60,10 @@ def create( self, *, account_id: str, + id: str, cache_invalidate_on_update: bool, cache_ttl: int, collect_logs: bool, - name: str, - slug: str, rate_limiting_interval: int | NotGiven = NOT_GIVEN, rate_limiting_limit: int | NotGiven = NOT_GIVEN, rate_limiting_technique: str | NotGiven = NOT_GIVEN, @@ -79,6 +78,8 @@ def create( Create a new Gateway Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -93,11 +94,10 @@ def create( f"/accounts/{account_id}/ai-gateway/gateways", body=maybe_transform( { + "id": id, "cache_invalidate_on_update": cache_invalidate_on_update, "cache_ttl": cache_ttl, "collect_logs": collect_logs, - "name": name, - "slug": slug, "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, @@ -122,8 +122,6 @@ def update( cache_invalidate_on_update: bool, cache_ttl: int, collect_logs: bool, - name: str, - slug: str, rate_limiting_interval: int | NotGiven = NOT_GIVEN, rate_limiting_limit: int | NotGiven = NOT_GIVEN, rate_limiting_technique: str | NotGiven = NOT_GIVEN, @@ -138,6 +136,8 @@ def update( Update a Gateway Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -157,8 +157,6 @@ def update( "cache_invalidate_on_update": cache_invalidate_on_update, "cache_ttl": cache_ttl, "collect_logs": collect_logs, - "name": name, - "slug": slug, "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, @@ -194,6 +192,8 @@ def list( List Gateway's Args: + id: gateway slug + order_by: Order By Column Name extra_headers: Send extra headers @@ -243,6 +243,8 @@ def delete( Delete a Gateway Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -283,6 +285,8 @@ def get( Fetch a Gateway Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -325,11 +329,10 @@ async def create( self, *, account_id: str, + id: str, cache_invalidate_on_update: bool, cache_ttl: int, collect_logs: bool, - name: str, - slug: str, rate_limiting_interval: int | NotGiven = NOT_GIVEN, rate_limiting_limit: int | NotGiven = NOT_GIVEN, rate_limiting_technique: str | NotGiven = NOT_GIVEN, @@ -344,6 +347,8 @@ async def create( Create a new Gateway Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -358,11 +363,10 @@ async def create( f"/accounts/{account_id}/ai-gateway/gateways", body=await async_maybe_transform( { + "id": id, "cache_invalidate_on_update": cache_invalidate_on_update, "cache_ttl": cache_ttl, "collect_logs": collect_logs, - "name": name, - "slug": slug, "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, @@ -387,8 +391,6 @@ async def update( cache_invalidate_on_update: bool, cache_ttl: int, collect_logs: bool, - name: str, - slug: str, rate_limiting_interval: int | NotGiven = NOT_GIVEN, rate_limiting_limit: int | NotGiven = NOT_GIVEN, rate_limiting_technique: str | NotGiven = NOT_GIVEN, @@ -403,6 +405,8 @@ async def update( Update a Gateway Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -422,8 +426,6 @@ async def update( "cache_invalidate_on_update": cache_invalidate_on_update, "cache_ttl": cache_ttl, "collect_logs": collect_logs, - "name": name, - "slug": slug, "rate_limiting_interval": rate_limiting_interval, "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, @@ -459,6 +461,8 @@ def list( List Gateway's Args: + id: gateway slug + order_by: Order By Column Name extra_headers: Send extra headers @@ -508,6 +512,8 @@ async def delete( Delete a Gateway Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -548,6 +554,8 @@ async def get( Fetch a Gateway Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py index 11b66892f08..d993d455796 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -65,6 +65,8 @@ def get( List Gateway Logs Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -138,6 +140,8 @@ async def get( List Gateway Logs Args: + id: gateway slug + extra_headers: Send extra headers extra_query: Add additional query parameters to the request diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py index c961028df1c..2695453e91d 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py @@ -10,16 +10,15 @@ class AIGatewayCreateParams(TypedDict, total=False): account_id: Required[str] + id: Required[str] + """gateway slug""" + cache_invalidate_on_update: Required[bool] cache_ttl: Required[int] collect_logs: Required[bool] - name: Required[str] - - slug: Required[str] - rate_limiting_interval: int rate_limiting_limit: int diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py index d64bb08d610..2497e62cf30 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py @@ -10,6 +10,7 @@ class Task(BaseModel): id: str + """gateway slug""" cache_invalidate_on_update: bool @@ -21,10 +22,6 @@ class Task(BaseModel): modified_at: datetime - name: str - - slug: str - rate_limiting_interval: Optional[int] = None rate_limiting_limit: Optional[int] = None diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py index ded796d9e59..0c0c3708b26 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py @@ -10,6 +10,7 @@ class AIGatewayDeleteResponse(BaseModel): id: str + """gateway slug""" cache_invalidate_on_update: bool @@ -21,10 +22,6 @@ class AIGatewayDeleteResponse(BaseModel): modified_at: datetime - name: str - - slug: str - rate_limiting_interval: Optional[int] = None rate_limiting_limit: Optional[int] = None diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py index e8a52224fee..3cae0803a57 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py @@ -10,6 +10,7 @@ class AIGatewayGetResponse(BaseModel): id: str + """gateway slug""" cache_invalidate_on_update: bool @@ -21,10 +22,6 @@ class AIGatewayGetResponse(BaseModel): modified_at: datetime - name: str - - slug: str - rate_limiting_interval: Optional[int] = None rate_limiting_limit: Optional[int] = None diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py index 183008d94a3..494ebd39541 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py @@ -11,6 +11,7 @@ class AIGatewayListParams(TypedDict, total=False): account_id: Required[str] id: str + """gateway slug""" order_by: str """Order By Column Name""" diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py index 701d72dd550..9dc08f49b77 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py @@ -10,6 +10,7 @@ class AIGatewayListResponse(BaseModel): id: str + """gateway slug""" cache_invalidate_on_update: bool @@ -21,10 +22,6 @@ class AIGatewayListResponse(BaseModel): modified_at: datetime - name: str - - slug: str - rate_limiting_interval: Optional[int] = None rate_limiting_limit: Optional[int] = None diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py index 0e8898de606..df3676b3b77 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py @@ -16,10 +16,6 @@ class AIGatewayUpdateParams(TypedDict, total=False): collect_logs: Required[bool] - name: Required[str] - - slug: Required[str] - rate_limiting_interval: int rate_limiting_limit: int diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py index 89e6238af2d..425aaac572b 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py @@ -10,6 +10,7 @@ class AIGatewayUpdateResponse(BaseModel): id: str + """gateway slug""" cache_invalidate_on_update: bool @@ -21,10 +22,6 @@ class AIGatewayUpdateResponse(BaseModel): modified_at: datetime - name: str - - slug: str - rate_limiting_interval: Optional[int] = None rate_limiting_limit: Optional[int] = None diff --git a/tests/api_resources/ai_gateway/test_logs.py b/tests/api_resources/ai_gateway/test_logs.py index f6dc3fd63d1..78439db3a89 100644 --- a/tests/api_resources/ai_gateway/test_logs.py +++ b/tests/api_resources/ai_gateway/test_logs.py @@ -21,7 +21,7 @@ class TestLogs: @parametrize def test_method_get(self, client: Cloudflare) -> None: log = client.ai_gateway.logs.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) assert_matches_type(LogGetResponse, log, path=["response"]) @@ -29,7 +29,7 @@ def test_method_get(self, client: Cloudflare) -> None: @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: log = client.ai_gateway.logs.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cached=True, direction="asc", @@ -46,7 +46,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.ai_gateway.logs.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) @@ -58,7 +58,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.ai_gateway.logs.with_streaming_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) as response: assert not response.is_closed @@ -73,7 +73,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: 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.ai_gateway.logs.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="", ) @@ -90,7 +90,7 @@ class TestAsyncLogs: @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: log = await async_client.ai_gateway.logs.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) assert_matches_type(LogGetResponse, log, path=["response"]) @@ -98,7 +98,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: log = await async_client.ai_gateway.logs.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cached=True, direction="asc", @@ -115,7 +115,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.ai_gateway.logs.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) @@ -127,7 +127,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.ai_gateway.logs.with_streaming_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) as response: assert not response.is_closed @@ -142,7 +142,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No 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.ai_gateway.logs.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="", ) diff --git a/tests/api_resources/test_ai_gateway.py b/tests/api_resources/test_ai_gateway.py index 2ea4b31548c..53a7a8ddee2 100644 --- a/tests/api_resources/test_ai_gateway.py +++ b/tests/api_resources/test_ai_gateway.py @@ -28,11 +28,10 @@ class TestAIGateway: def test_method_create(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"]) @@ -40,11 +39,10 @@ def test_method_create(self, client: Cloudflare) -> None: def test_method_create_with_all_params(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", rate_limiting_interval=0, rate_limiting_limit=0, rate_limiting_technique="string", @@ -55,11 +53,10 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_create(self, client: Cloudflare) -> None: response = client.ai_gateway.with_raw_response.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) assert response.is_closed is True @@ -71,11 +68,10 @@ def test_raw_response_create(self, client: Cloudflare) -> None: def test_streaming_response_create(self, client: Cloudflare) -> None: with client.ai_gateway.with_streaming_response.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -90,36 +86,31 @@ 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.ai_gateway.with_raw_response.create( account_id="", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) @parametrize def test_method_update(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", rate_limiting_interval=0, rate_limiting_limit=0, rate_limiting_technique="string", @@ -129,13 +120,11 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.ai_gateway.with_raw_response.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) assert response.is_closed is True @@ -146,13 +135,11 @@ def test_raw_response_update(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.ai_gateway.with_streaming_response.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -166,13 +153,11 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: 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.ai_gateway.with_raw_response.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -182,8 +167,6 @@ def test_path_params_update(self, client: Cloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) @parametrize @@ -197,7 +180,7 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.list( account_id="0d37909e38d3e99c29fa2cd343ac421a", - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="my-gateway", order_by="string", page=1, per_page=5, @@ -238,7 +221,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: @parametrize def test_method_delete(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"]) @@ -246,7 +229,7 @@ def test_method_delete(self, client: Cloudflare) -> None: @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.ai_gateway.with_raw_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) @@ -258,7 +241,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.ai_gateway.with_streaming_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) as response: assert not response.is_closed @@ -273,7 +256,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: 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.ai_gateway.with_raw_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="", ) @@ -286,7 +269,7 @@ def test_path_params_delete(self, client: Cloudflare) -> None: @parametrize def test_method_get(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) assert_matches_type(AIGatewayGetResponse, ai_gateway, path=["response"]) @@ -294,7 +277,7 @@ def test_method_get(self, client: Cloudflare) -> None: @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.ai_gateway.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) @@ -306,7 +289,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.ai_gateway.with_streaming_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) as response: assert not response.is_closed @@ -321,7 +304,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: 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.ai_gateway.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="", ) @@ -339,11 +322,10 @@ class TestAsyncAIGateway: async def test_method_create(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"]) @@ -351,11 +333,10 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", rate_limiting_interval=0, rate_limiting_limit=0, rate_limiting_technique="string", @@ -366,11 +347,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.ai_gateway.with_raw_response.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) assert response.is_closed is True @@ -382,11 +362,10 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.ai_gateway.with_streaming_response.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -401,36 +380,31 @@ 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.ai_gateway.with_raw_response.create( account_id="", + id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", rate_limiting_interval=0, rate_limiting_limit=0, rate_limiting_technique="string", @@ -440,13 +414,11 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.ai_gateway.with_raw_response.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) assert response.is_closed is True @@ -457,13 +429,11 @@ 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.ai_gateway.with_streaming_response.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -477,13 +447,11 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> 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.ai_gateway.with_raw_response.update( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -493,8 +461,6 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, - name="string", - slug="string", ) @parametrize @@ -508,7 +474,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.list( account_id="0d37909e38d3e99c29fa2cd343ac421a", - id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + id="my-gateway", order_by="string", page=1, per_page=5, @@ -549,7 +515,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"]) @@ -557,7 +523,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.ai_gateway.with_raw_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) @@ -569,7 +535,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.ai_gateway.with_streaming_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) as response: assert not response.is_closed @@ -584,7 +550,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> 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.ai_gateway.with_raw_response.delete( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="", ) @@ -597,7 +563,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) assert_matches_type(AIGatewayGetResponse, ai_gateway, path=["response"]) @@ -605,7 +571,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.ai_gateway.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) @@ -617,7 +583,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.ai_gateway.with_streaming_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) as response: assert not response.is_closed @@ -632,7 +598,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No 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.ai_gateway.with_raw_response.get( - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + "my-gateway", account_id="", ) From 6ebc422b597330c7a39c1d7f0f5a77a9a42e552a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 14:01:06 +0000 Subject: [PATCH 019/532] feat(api): OpenAPI spec update via Stainless API (#500) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index df3052cd59f..7265ef528d6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e9768930aab7041f58b5f317137699bbd040d5be0864adcee08df4a026b99300.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e148a50116381bddb9ef72b3a05b476394c7779eb327ea8abd69de4a04fa9e65.yml diff --git a/api.md b/api.md index fbcb03a1702..7f1dda06e5e 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7433,14 +7433,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7456,10 +7456,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7476,11 +7476,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From fb329860990896225dc70945e5b7183c2ed0773f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 15:03:07 +0000 Subject: [PATCH 020/532] feat(api): OpenAPI spec update via Stainless API (#501) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7265ef528d6..2bd6410820f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e148a50116381bddb9ef72b3a05b476394c7779eb327ea8abd69de4a04fa9e65.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d2235d448eaf798042945bdd265a7c0ec1a6d761475165e410bd3aae6fc2d61a.yml diff --git a/api.md b/api.md index 7f1dda06e5e..fbcb03a1702 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7433,14 +7433,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7456,10 +7456,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7476,11 +7476,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 6d314fa08d915d9f009568102395e0775a379fbd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 17:45:45 +0000 Subject: [PATCH 021/532] feat(api): OpenAPI spec update via Stainless API (#502) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2bd6410820f..df3052cd59f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d2235d448eaf798042945bdd265a7c0ec1a6d761475165e410bd3aae6fc2d61a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e9768930aab7041f58b5f317137699bbd040d5be0864adcee08df4a026b99300.yml From 39a3341f5b02adb002b0f0a716c81fd737427014 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 18:14:40 +0000 Subject: [PATCH 022/532] feat(api): OpenAPI spec update via Stainless API (#503) --- .stats.yml | 2 +- src/cloudflare/types/zero_trust/access/service_token.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index df3052cd59f..cd62ae71321 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e9768930aab7041f58b5f317137699bbd040d5be0864adcee08df4a026b99300.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-839600a13efe864362aeb0940c721ebf4bbace7a23853dc24da23e029dc06116.yml diff --git a/src/cloudflare/types/zero_trust/access/service_token.py b/src/cloudflare/types/zero_trust/access/service_token.py index 97ffd3bcdeb..a1e4338cb6f 100644 --- a/src/cloudflare/types/zero_trust/access/service_token.py +++ b/src/cloudflare/types/zero_trust/access/service_token.py @@ -9,7 +9,7 @@ class ServiceToken(BaseModel): - id: Optional[object] = None + id: Optional[str] = None """The ID of the service token.""" client_id: Optional[str] = None From 55ec2a2732fa01f348728da2f6ee95ed569ee6d8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 23:29:15 +0000 Subject: [PATCH 023/532] feat(api): OpenAPI spec update via Stainless API (#504) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index cd62ae71321..54ae3291933 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1281 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-839600a13efe864362aeb0940c721ebf4bbace7a23853dc24da23e029dc06116.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a8e3aedb1193065fd84ae0b74a4a4c2d217ff2a821096f825a7798bbb921d76.yml diff --git a/api.md b/api.md index fbcb03a1702..7f1dda06e5e 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7433,14 +7433,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7456,10 +7456,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7476,11 +7476,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 7aedba0895618649e930ec1b440994270435c1a4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 23:52:15 +0000 Subject: [PATCH 024/532] feat(api): update via SDK Studio (#505) --- .stats.yml | 2 +- api.md | 21 + .../resources/magic_transit/__init__.py | 14 + .../resources/magic_transit/connectors.py | 478 ++++++++++++++++++ .../resources/magic_transit/magic_transit.py | 32 ++ .../zero_trust/access/service_tokens.py | 126 +++++ .../types/magic_transit/__init__.py | 6 + .../magic_transit/connector_edit_params.py | 21 + .../magic_transit/connector_edit_response.py | 35 ++ .../magic_transit/connector_get_response.py | 35 ++ .../magic_transit/connector_list_response.py | 35 ++ .../magic_transit/connector_update_params.py | 21 + .../connector_update_response.py | 35 ++ .../magic_transit/test_connectors.py | 394 +++++++++++++++ .../zero_trust/access/test_service_tokens.py | 134 +++++ 15 files changed, 1388 insertions(+), 1 deletion(-) create mode 100644 src/cloudflare/resources/magic_transit/connectors.py create mode 100644 src/cloudflare/types/magic_transit/connector_edit_params.py create mode 100644 src/cloudflare/types/magic_transit/connector_edit_response.py create mode 100644 src/cloudflare/types/magic_transit/connector_get_response.py create mode 100644 src/cloudflare/types/magic_transit/connector_list_response.py create mode 100644 src/cloudflare/types/magic_transit/connector_update_params.py create mode 100644 src/cloudflare/types/magic_transit/connector_update_response.py create mode 100644 tests/api_resources/magic_transit/test_connectors.py diff --git a/.stats.yml b/.stats.yml index 54ae3291933..9c05255519b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1281 +configured_endpoints: 1286 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a8e3aedb1193065fd84ae0b74a4a4c2d217ff2a821096f825a7798bbb921d76.yml diff --git a/api.md b/api.md index 7f1dda06e5e..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3931,6 +3931,26 @@ Methods: - client.magic_transit.sites.wans.delete(wan_id, \*, account_id, site_id) -> WAN - client.magic_transit.sites.wans.get(wan_id, \*, account_id, site_id) -> WAN +## Connectors + +Types: + +```python +from cloudflare.types.magic_transit import ( + ConnectorUpdateResponse, + ConnectorListResponse, + ConnectorEditResponse, + ConnectorGetResponse, +) +``` + +Methods: + +- client.magic_transit.connectors.update(connector_id, \*, account_id, \*\*params) -> ConnectorUpdateResponse +- client.magic_transit.connectors.list(\*, account_id) -> SyncSinglePage[ConnectorListResponse] +- client.magic_transit.connectors.edit(connector_id, \*, account_id, \*\*params) -> ConnectorEditResponse +- client.magic_transit.connectors.get(connector_id, \*, account_id) -> ConnectorGetResponse + # MagicNetworkMonitoring ## Configs @@ -5244,6 +5264,7 @@ Methods: - client.zero_trust.access.service_tokens.update(uuid, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.service_tokens.list(\*, account_id, zone_id) -> SyncSinglePage[ServiceToken] - client.zero_trust.access.service_tokens.delete(uuid, \*, account_id, zone_id) -> Optional +- client.zero_trust.access.service_tokens.get(uuid, \*, account_id, zone_id) -> Optional - client.zero_trust.access.service_tokens.refresh(uuid, \*, identifier) -> Optional - client.zero_trust.access.service_tokens.rotate(uuid, \*, identifier) -> Optional diff --git a/src/cloudflare/resources/magic_transit/__init__.py b/src/cloudflare/resources/magic_transit/__init__.py index c954e23e46a..842f6cfd86a 100644 --- a/src/cloudflare/resources/magic_transit/__init__.py +++ b/src/cloudflare/resources/magic_transit/__init__.py @@ -16,6 +16,14 @@ RoutesResourceWithStreamingResponse, AsyncRoutesResourceWithStreamingResponse, ) +from .connectors import ( + ConnectorsResource, + AsyncConnectorsResource, + ConnectorsResourceWithRawResponse, + AsyncConnectorsResourceWithRawResponse, + ConnectorsResourceWithStreamingResponse, + AsyncConnectorsResourceWithStreamingResponse, +) from .gre_tunnels import ( GRETunnelsResource, AsyncGRETunnelsResource, @@ -80,6 +88,12 @@ "AsyncSitesResourceWithRawResponse", "SitesResourceWithStreamingResponse", "AsyncSitesResourceWithStreamingResponse", + "ConnectorsResource", + "AsyncConnectorsResource", + "ConnectorsResourceWithRawResponse", + "AsyncConnectorsResourceWithRawResponse", + "ConnectorsResourceWithStreamingResponse", + "AsyncConnectorsResourceWithStreamingResponse", "MagicTransitResource", "AsyncMagicTransitResource", "MagicTransitResourceWithRawResponse", diff --git a/src/cloudflare/resources/magic_transit/connectors.py b/src/cloudflare/resources/magic_transit/connectors.py new file mode 100644 index 00000000000..684917dbcc3 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/connectors.py @@ -0,0 +1,478 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import ( + AsyncPaginator, + make_request_options, +) +from ...types.magic_transit import connector_edit_params, connector_update_params +from ...types.magic_transit.connector_get_response import ConnectorGetResponse +from ...types.magic_transit.connector_edit_response import ConnectorEditResponse +from ...types.magic_transit.connector_list_response import ConnectorListResponse +from ...types.magic_transit.connector_update_response import ConnectorUpdateResponse + +__all__ = ["ConnectorsResource", "AsyncConnectorsResource"] + + +class ConnectorsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ConnectorsResourceWithRawResponse: + return ConnectorsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ConnectorsResourceWithStreamingResponse: + return ConnectorsResourceWithStreamingResponse(self) + + def update( + self, + connector_id: str, + *, + account_id: float, + activated: bool | NotGiven = NOT_GIVEN, + interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, + interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, + notes: str | NotGiven = NOT_GIVEN, + timezone: 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, + ) -> ConnectorUpdateResponse: + """ + Replace Connector + + 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 connector_id: + raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") + return self._put( + f"/accounts/{account_id}/magic/connectors/{connector_id}", + body=maybe_transform( + { + "activated": activated, + "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_hour_of_day": interrupt_window_hour_of_day, + "notes": notes, + "timezone": timezone, + }, + connector_update_params.ConnectorUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ConnectorUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[ConnectorUpdateResponse], ResultWrapper[ConnectorUpdateResponse]), + ) + + def list( + self, + *, + account_id: float, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[ConnectorListResponse]: + """ + List Connectors + + 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 + """ + return self._get_api_list( + f"/accounts/{account_id}/magic/connectors", + page=SyncSinglePage[ConnectorListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ConnectorListResponse, + ) + + def edit( + self, + connector_id: str, + *, + account_id: float, + activated: bool | NotGiven = NOT_GIVEN, + interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, + interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, + notes: str | NotGiven = NOT_GIVEN, + timezone: 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, + ) -> ConnectorEditResponse: + """ + Update Connector + + 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 connector_id: + raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") + return self._patch( + f"/accounts/{account_id}/magic/connectors/{connector_id}", + body=maybe_transform( + { + "activated": activated, + "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_hour_of_day": interrupt_window_hour_of_day, + "notes": notes, + "timezone": timezone, + }, + connector_edit_params.ConnectorEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ConnectorEditResponse]._unwrapper, + ), + cast_to=cast(Type[ConnectorEditResponse], ResultWrapper[ConnectorEditResponse]), + ) + + def get( + self, + connector_id: str, + *, + account_id: float, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ConnectorGetResponse: + """ + Fetch Connector + + 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 connector_id: + raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") + return self._get( + f"/accounts/{account_id}/magic/connectors/{connector_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ConnectorGetResponse]._unwrapper, + ), + cast_to=cast(Type[ConnectorGetResponse], ResultWrapper[ConnectorGetResponse]), + ) + + +class AsyncConnectorsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncConnectorsResourceWithRawResponse: + return AsyncConnectorsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncConnectorsResourceWithStreamingResponse: + return AsyncConnectorsResourceWithStreamingResponse(self) + + async def update( + self, + connector_id: str, + *, + account_id: float, + activated: bool | NotGiven = NOT_GIVEN, + interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, + interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, + notes: str | NotGiven = NOT_GIVEN, + timezone: 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, + ) -> ConnectorUpdateResponse: + """ + Replace Connector + + 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 connector_id: + raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/connectors/{connector_id}", + body=await async_maybe_transform( + { + "activated": activated, + "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_hour_of_day": interrupt_window_hour_of_day, + "notes": notes, + "timezone": timezone, + }, + connector_update_params.ConnectorUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ConnectorUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[ConnectorUpdateResponse], ResultWrapper[ConnectorUpdateResponse]), + ) + + def list( + self, + *, + account_id: float, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[ConnectorListResponse, AsyncSinglePage[ConnectorListResponse]]: + """ + List Connectors + + 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 + """ + return self._get_api_list( + f"/accounts/{account_id}/magic/connectors", + page=AsyncSinglePage[ConnectorListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ConnectorListResponse, + ) + + async def edit( + self, + connector_id: str, + *, + account_id: float, + activated: bool | NotGiven = NOT_GIVEN, + interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, + interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, + notes: str | NotGiven = NOT_GIVEN, + timezone: 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, + ) -> ConnectorEditResponse: + """ + Update Connector + + 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 connector_id: + raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") + return await self._patch( + f"/accounts/{account_id}/magic/connectors/{connector_id}", + body=await async_maybe_transform( + { + "activated": activated, + "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_hour_of_day": interrupt_window_hour_of_day, + "notes": notes, + "timezone": timezone, + }, + connector_edit_params.ConnectorEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ConnectorEditResponse]._unwrapper, + ), + cast_to=cast(Type[ConnectorEditResponse], ResultWrapper[ConnectorEditResponse]), + ) + + async def get( + self, + connector_id: str, + *, + account_id: float, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ConnectorGetResponse: + """ + Fetch Connector + + 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 connector_id: + raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") + return await self._get( + f"/accounts/{account_id}/magic/connectors/{connector_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ConnectorGetResponse]._unwrapper, + ), + cast_to=cast(Type[ConnectorGetResponse], ResultWrapper[ConnectorGetResponse]), + ) + + +class ConnectorsResourceWithRawResponse: + def __init__(self, connectors: ConnectorsResource) -> None: + self._connectors = connectors + + self.update = to_raw_response_wrapper( + connectors.update, + ) + self.list = to_raw_response_wrapper( + connectors.list, + ) + self.edit = to_raw_response_wrapper( + connectors.edit, + ) + self.get = to_raw_response_wrapper( + connectors.get, + ) + + +class AsyncConnectorsResourceWithRawResponse: + def __init__(self, connectors: AsyncConnectorsResource) -> None: + self._connectors = connectors + + self.update = async_to_raw_response_wrapper( + connectors.update, + ) + self.list = async_to_raw_response_wrapper( + connectors.list, + ) + self.edit = async_to_raw_response_wrapper( + connectors.edit, + ) + self.get = async_to_raw_response_wrapper( + connectors.get, + ) + + +class ConnectorsResourceWithStreamingResponse: + def __init__(self, connectors: ConnectorsResource) -> None: + self._connectors = connectors + + self.update = to_streamed_response_wrapper( + connectors.update, + ) + self.list = to_streamed_response_wrapper( + connectors.list, + ) + self.edit = to_streamed_response_wrapper( + connectors.edit, + ) + self.get = to_streamed_response_wrapper( + connectors.get, + ) + + +class AsyncConnectorsResourceWithStreamingResponse: + def __init__(self, connectors: AsyncConnectorsResource) -> None: + self._connectors = connectors + + self.update = async_to_streamed_response_wrapper( + connectors.update, + ) + self.list = async_to_streamed_response_wrapper( + connectors.list, + ) + self.edit = async_to_streamed_response_wrapper( + connectors.edit, + ) + self.get = async_to_streamed_response_wrapper( + connectors.get, + ) diff --git a/src/cloudflare/resources/magic_transit/magic_transit.py b/src/cloudflare/resources/magic_transit/magic_transit.py index 1cce72b3cfa..26c772232f2 100644 --- a/src/cloudflare/resources/magic_transit/magic_transit.py +++ b/src/cloudflare/resources/magic_transit/magic_transit.py @@ -19,6 +19,14 @@ AsyncRoutesResourceWithStreamingResponse, ) from ..._compat import cached_property +from .connectors import ( + ConnectorsResource, + AsyncConnectorsResource, + ConnectorsResourceWithRawResponse, + AsyncConnectorsResourceWithRawResponse, + ConnectorsResourceWithStreamingResponse, + AsyncConnectorsResourceWithStreamingResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource from .gre_tunnels import ( GRETunnelsResource, @@ -70,6 +78,10 @@ def routes(self) -> RoutesResource: def sites(self) -> SitesResource: return SitesResource(self._client) + @cached_property + def connectors(self) -> ConnectorsResource: + return ConnectorsResource(self._client) + @cached_property def with_raw_response(self) -> MagicTransitResourceWithRawResponse: return MagicTransitResourceWithRawResponse(self) @@ -100,6 +112,10 @@ def routes(self) -> AsyncRoutesResource: def sites(self) -> AsyncSitesResource: return AsyncSitesResource(self._client) + @cached_property + def connectors(self) -> AsyncConnectorsResource: + return AsyncConnectorsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncMagicTransitResourceWithRawResponse: return AsyncMagicTransitResourceWithRawResponse(self) @@ -133,6 +149,10 @@ def routes(self) -> RoutesResourceWithRawResponse: def sites(self) -> SitesResourceWithRawResponse: return SitesResourceWithRawResponse(self._magic_transit.sites) + @cached_property + def connectors(self) -> ConnectorsResourceWithRawResponse: + return ConnectorsResourceWithRawResponse(self._magic_transit.connectors) + class AsyncMagicTransitResourceWithRawResponse: def __init__(self, magic_transit: AsyncMagicTransitResource) -> None: @@ -158,6 +178,10 @@ def routes(self) -> AsyncRoutesResourceWithRawResponse: def sites(self) -> AsyncSitesResourceWithRawResponse: return AsyncSitesResourceWithRawResponse(self._magic_transit.sites) + @cached_property + def connectors(self) -> AsyncConnectorsResourceWithRawResponse: + return AsyncConnectorsResourceWithRawResponse(self._magic_transit.connectors) + class MagicTransitResourceWithStreamingResponse: def __init__(self, magic_transit: MagicTransitResource) -> None: @@ -183,6 +207,10 @@ def routes(self) -> RoutesResourceWithStreamingResponse: def sites(self) -> SitesResourceWithStreamingResponse: return SitesResourceWithStreamingResponse(self._magic_transit.sites) + @cached_property + def connectors(self) -> ConnectorsResourceWithStreamingResponse: + return ConnectorsResourceWithStreamingResponse(self._magic_transit.connectors) + class AsyncMagicTransitResourceWithStreamingResponse: def __init__(self, magic_transit: AsyncMagicTransitResource) -> None: @@ -207,3 +235,7 @@ def routes(self) -> AsyncRoutesResourceWithStreamingResponse: @cached_property def sites(self) -> AsyncSitesResourceWithStreamingResponse: return AsyncSitesResourceWithStreamingResponse(self._magic_transit.sites) + + @cached_property + def connectors(self) -> AsyncConnectorsResourceWithStreamingResponse: + return AsyncConnectorsResourceWithStreamingResponse(self._magic_transit.connectors) diff --git a/src/cloudflare/resources/zero_trust/access/service_tokens.py b/src/cloudflare/resources/zero_trust/access/service_tokens.py index 716761647d3..99c07117732 100644 --- a/src/cloudflare/resources/zero_trust/access/service_tokens.py +++ b/src/cloudflare/resources/zero_trust/access/service_tokens.py @@ -290,6 +290,63 @@ def delete( cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), ) + def get( + self, + uuid: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ServiceToken]: + """ + Fetches a single service token. + + Args: + uuid: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not uuid: + raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{uuid}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + def refresh( self, uuid: str, @@ -636,6 +693,63 @@ async def delete( cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), ) + async def get( + self, + uuid: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ServiceToken]: + """ + Fetches a single service token. + + Args: + uuid: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not uuid: + raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{uuid}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + async def refresh( self, uuid: str, @@ -741,6 +855,9 @@ def __init__(self, service_tokens: ServiceTokensResource) -> None: self.delete = to_raw_response_wrapper( service_tokens.delete, ) + self.get = to_raw_response_wrapper( + service_tokens.get, + ) self.refresh = to_raw_response_wrapper( service_tokens.refresh, ) @@ -765,6 +882,9 @@ def __init__(self, service_tokens: AsyncServiceTokensResource) -> None: self.delete = async_to_raw_response_wrapper( service_tokens.delete, ) + self.get = async_to_raw_response_wrapper( + service_tokens.get, + ) self.refresh = async_to_raw_response_wrapper( service_tokens.refresh, ) @@ -789,6 +909,9 @@ def __init__(self, service_tokens: ServiceTokensResource) -> None: self.delete = to_streamed_response_wrapper( service_tokens.delete, ) + self.get = to_streamed_response_wrapper( + service_tokens.get, + ) self.refresh = to_streamed_response_wrapper( service_tokens.refresh, ) @@ -813,6 +936,9 @@ def __init__(self, service_tokens: AsyncServiceTokensResource) -> None: self.delete = async_to_streamed_response_wrapper( service_tokens.delete, ) + self.get = async_to_streamed_response_wrapper( + service_tokens.get, + ) self.refresh = async_to_streamed_response_wrapper( service_tokens.refresh, ) diff --git a/src/cloudflare/types/magic_transit/__init__.py b/src/cloudflare/types/magic_transit/__init__.py index 98e253df212..1ef7d35b957 100644 --- a/src/cloudflare/types/magic_transit/__init__.py +++ b/src/cloudflare/types/magic_transit/__init__.py @@ -20,13 +20,19 @@ from .route_update_params import RouteUpdateParams as RouteUpdateParams from .site_location_param import SiteLocationParam as SiteLocationParam from .route_empty_response import RouteEmptyResponse as RouteEmptyResponse +from .connector_edit_params import ConnectorEditParams as ConnectorEditParams from .route_create_response import RouteCreateResponse as RouteCreateResponse from .route_delete_response import RouteDeleteResponse as RouteDeleteResponse from .route_update_response import RouteUpdateResponse as RouteUpdateResponse +from .connector_get_response import ConnectorGetResponse as ConnectorGetResponse +from .connector_edit_response import ConnectorEditResponse as ConnectorEditResponse +from .connector_list_response import ConnectorListResponse as ConnectorListResponse +from .connector_update_params import ConnectorUpdateParams as ConnectorUpdateParams from .gre_tunnel_get_response import GRETunnelGetResponse as GRETunnelGetResponse from .gre_tunnel_create_params import GRETunnelCreateParams as GRETunnelCreateParams from .gre_tunnel_list_response import GRETunnelListResponse as GRETunnelListResponse from .gre_tunnel_update_params import GRETunnelUpdateParams as GRETunnelUpdateParams +from .connector_update_response import ConnectorUpdateResponse as ConnectorUpdateResponse from .ipsec_tunnel_get_response import IPSECTunnelGetResponse as IPSECTunnelGetResponse from .gre_tunnel_create_response import GRETunnelCreateResponse as GRETunnelCreateResponse from .gre_tunnel_delete_response import GRETunnelDeleteResponse as GRETunnelDeleteResponse diff --git a/src/cloudflare/types/magic_transit/connector_edit_params.py b/src/cloudflare/types/magic_transit/connector_edit_params.py new file mode 100644 index 00000000000..1dc36abdc0f --- /dev/null +++ b/src/cloudflare/types/magic_transit/connector_edit_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ConnectorEditParams"] + + +class ConnectorEditParams(TypedDict, total=False): + account_id: Required[float] + + activated: bool + + interrupt_window_duration_hours: float + + interrupt_window_hour_of_day: float + + notes: str + + timezone: str diff --git a/src/cloudflare/types/magic_transit/connector_edit_response.py b/src/cloudflare/types/magic_transit/connector_edit_response.py new file mode 100644 index 00000000000..47d29cef4a4 --- /dev/null +++ b/src/cloudflare/types/magic_transit/connector_edit_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["ConnectorEditResponse", "Device"] + + +class Device(BaseModel): + id: str + + serial_number: Optional[str] = None + + +class ConnectorEditResponse(BaseModel): + id: str + + activated: bool + + interrupt_window_duration_hours: float + + interrupt_window_hour_of_day: float + + last_updated: str + + notes: str + + timezone: str + + device: Optional[Device] = None + + last_heartbeat: Optional[str] = None + + last_seen_version: Optional[str] = None diff --git a/src/cloudflare/types/magic_transit/connector_get_response.py b/src/cloudflare/types/magic_transit/connector_get_response.py new file mode 100644 index 00000000000..6b36ed76687 --- /dev/null +++ b/src/cloudflare/types/magic_transit/connector_get_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["ConnectorGetResponse", "Device"] + + +class Device(BaseModel): + id: str + + serial_number: Optional[str] = None + + +class ConnectorGetResponse(BaseModel): + id: str + + activated: bool + + interrupt_window_duration_hours: float + + interrupt_window_hour_of_day: float + + last_updated: str + + notes: str + + timezone: str + + device: Optional[Device] = None + + last_heartbeat: Optional[str] = None + + last_seen_version: Optional[str] = None diff --git a/src/cloudflare/types/magic_transit/connector_list_response.py b/src/cloudflare/types/magic_transit/connector_list_response.py new file mode 100644 index 00000000000..abad515443c --- /dev/null +++ b/src/cloudflare/types/magic_transit/connector_list_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["ConnectorListResponse", "Device"] + + +class Device(BaseModel): + id: str + + serial_number: Optional[str] = None + + +class ConnectorListResponse(BaseModel): + id: str + + activated: bool + + interrupt_window_duration_hours: float + + interrupt_window_hour_of_day: float + + last_updated: str + + notes: str + + timezone: str + + device: Optional[Device] = None + + last_heartbeat: Optional[str] = None + + last_seen_version: Optional[str] = None diff --git a/src/cloudflare/types/magic_transit/connector_update_params.py b/src/cloudflare/types/magic_transit/connector_update_params.py new file mode 100644 index 00000000000..f70f4a4dda8 --- /dev/null +++ b/src/cloudflare/types/magic_transit/connector_update_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ConnectorUpdateParams"] + + +class ConnectorUpdateParams(TypedDict, total=False): + account_id: Required[float] + + activated: bool + + interrupt_window_duration_hours: float + + interrupt_window_hour_of_day: float + + notes: str + + timezone: str diff --git a/src/cloudflare/types/magic_transit/connector_update_response.py b/src/cloudflare/types/magic_transit/connector_update_response.py new file mode 100644 index 00000000000..80f6a6a5198 --- /dev/null +++ b/src/cloudflare/types/magic_transit/connector_update_response.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["ConnectorUpdateResponse", "Device"] + + +class Device(BaseModel): + id: str + + serial_number: Optional[str] = None + + +class ConnectorUpdateResponse(BaseModel): + id: str + + activated: bool + + interrupt_window_duration_hours: float + + interrupt_window_hour_of_day: float + + last_updated: str + + notes: str + + timezone: str + + device: Optional[Device] = None + + last_heartbeat: Optional[str] = None + + last_seen_version: Optional[str] = None diff --git a/tests/api_resources/magic_transit/test_connectors.py b/tests/api_resources/magic_transit/test_connectors.py new file mode 100644 index 00000000000..45dcd465181 --- /dev/null +++ b/tests/api_resources/magic_transit/test_connectors.py @@ -0,0 +1,394 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.magic_transit import ( + ConnectorGetResponse, + ConnectorEditResponse, + ConnectorListResponse, + ConnectorUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestConnectors: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + connector = client.magic_transit.connectors.update( + "string", + account_id=0, + ) + assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + connector = client.magic_transit.connectors.update( + "string", + account_id=0, + activated=True, + interrupt_window_duration_hours=0, + interrupt_window_hour_of_day=0, + notes="string", + timezone="string", + ) + assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.magic_transit.connectors.with_raw_response.update( + "string", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connector = response.parse() + assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.magic_transit.connectors.with_streaming_response.update( + "string", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + connector = response.parse() + assert_matches_type(ConnectorUpdateResponse, connector, 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 `connector_id` but received ''"): + client.magic_transit.connectors.with_raw_response.update( + "", + account_id=0, + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + connector = client.magic_transit.connectors.list( + account_id=0, + ) + assert_matches_type(SyncSinglePage[ConnectorListResponse], connector, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.connectors.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connector = response.parse() + assert_matches_type(SyncSinglePage[ConnectorListResponse], connector, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.connectors.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + connector = response.parse() + assert_matches_type(SyncSinglePage[ConnectorListResponse], connector, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + connector = client.magic_transit.connectors.edit( + "string", + account_id=0, + ) + assert_matches_type(ConnectorEditResponse, connector, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + connector = client.magic_transit.connectors.edit( + "string", + account_id=0, + activated=True, + interrupt_window_duration_hours=0, + interrupt_window_hour_of_day=0, + notes="string", + timezone="string", + ) + assert_matches_type(ConnectorEditResponse, connector, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.magic_transit.connectors.with_raw_response.edit( + "string", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connector = response.parse() + assert_matches_type(ConnectorEditResponse, connector, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.magic_transit.connectors.with_streaming_response.edit( + "string", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + connector = response.parse() + assert_matches_type(ConnectorEditResponse, connector, 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 `connector_id` but received ''"): + client.magic_transit.connectors.with_raw_response.edit( + "", + account_id=0, + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + connector = client.magic_transit.connectors.get( + "string", + account_id=0, + ) + assert_matches_type(ConnectorGetResponse, connector, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.magic_transit.connectors.with_raw_response.get( + "string", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connector = response.parse() + assert_matches_type(ConnectorGetResponse, connector, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.magic_transit.connectors.with_streaming_response.get( + "string", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + connector = response.parse() + assert_matches_type(ConnectorGetResponse, connector, 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 `connector_id` but received ''"): + client.magic_transit.connectors.with_raw_response.get( + "", + account_id=0, + ) + + +class TestAsyncConnectors: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + connector = await async_client.magic_transit.connectors.update( + "string", + account_id=0, + ) + assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + connector = await async_client.magic_transit.connectors.update( + "string", + account_id=0, + activated=True, + interrupt_window_duration_hours=0, + interrupt_window_hour_of_day=0, + notes="string", + timezone="string", + ) + assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.connectors.with_raw_response.update( + "string", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connector = await response.parse() + assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.connectors.with_streaming_response.update( + "string", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + connector = await response.parse() + assert_matches_type(ConnectorUpdateResponse, connector, 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 `connector_id` but received ''"): + await async_client.magic_transit.connectors.with_raw_response.update( + "", + account_id=0, + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + connector = await async_client.magic_transit.connectors.list( + account_id=0, + ) + assert_matches_type(AsyncSinglePage[ConnectorListResponse], connector, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.connectors.with_raw_response.list( + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connector = await response.parse() + assert_matches_type(AsyncSinglePage[ConnectorListResponse], connector, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.connectors.with_streaming_response.list( + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + connector = await response.parse() + assert_matches_type(AsyncSinglePage[ConnectorListResponse], connector, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + connector = await async_client.magic_transit.connectors.edit( + "string", + account_id=0, + ) + assert_matches_type(ConnectorEditResponse, connector, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + connector = await async_client.magic_transit.connectors.edit( + "string", + account_id=0, + activated=True, + interrupt_window_duration_hours=0, + interrupt_window_hour_of_day=0, + notes="string", + timezone="string", + ) + assert_matches_type(ConnectorEditResponse, connector, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.connectors.with_raw_response.edit( + "string", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connector = await response.parse() + assert_matches_type(ConnectorEditResponse, connector, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.connectors.with_streaming_response.edit( + "string", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + connector = await response.parse() + assert_matches_type(ConnectorEditResponse, connector, 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 `connector_id` but received ''"): + await async_client.magic_transit.connectors.with_raw_response.edit( + "", + account_id=0, + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + connector = await async_client.magic_transit.connectors.get( + "string", + account_id=0, + ) + assert_matches_type(ConnectorGetResponse, connector, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.connectors.with_raw_response.get( + "string", + account_id=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + connector = await response.parse() + assert_matches_type(ConnectorGetResponse, connector, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.connectors.with_streaming_response.get( + "string", + account_id=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + connector = await response.parse() + assert_matches_type(ConnectorGetResponse, connector, 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 `connector_id` but received ''"): + await async_client.magic_transit.connectors.with_raw_response.get( + "", + account_id=0, + ) diff --git a/tests/api_resources/zero_trust/access/test_service_tokens.py b/tests/api_resources/zero_trust/access/test_service_tokens.py index 1eb404eb5ef..61c913a70aa 100644 --- a/tests/api_resources/zero_trust/access/test_service_tokens.py +++ b/tests/api_resources/zero_trust/access/test_service_tokens.py @@ -275,6 +275,73 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.service_tokens.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + @parametrize def test_method_refresh(self, client: Cloudflare) -> None: service_token = client.zero_trust.access.service_tokens.refresh( @@ -628,6 +695,73 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, 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.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, 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.access.service_tokens.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + @parametrize async def test_method_refresh(self, async_client: AsyncCloudflare) -> None: service_token = await async_client.zero_trust.access.service_tokens.refresh( From 7407ff306980da0339b6955653ae3a066dc141f8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 10:27:52 +0000 Subject: [PATCH 025/532] feat(api): OpenAPI spec update via Stainless API (#506) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9c05255519b..7dfe322054a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a8e3aedb1193065fd84ae0b74a4a4c2d217ff2a821096f825a7798bbb921d76.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-839600a13efe864362aeb0940c721ebf4bbace7a23853dc24da23e029dc06116.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 44a567485649668bb272794d7b823199d96434e3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 10:32:40 +0000 Subject: [PATCH 026/532] feat(api): OpenAPI spec update via Stainless API (#507) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7dfe322054a..df7001ada9b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-839600a13efe864362aeb0940c721ebf4bbace7a23853dc24da23e029dc06116.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-692cc74e438a991e1707d4b34506e3e8a0427a396d4d48be41f8cc979b2ac63b.yml From c48abbf30879efd8a48984c785c7a42616dae9d1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 10:55:44 +0000 Subject: [PATCH 027/532] feat(api): OpenAPI spec update via Stainless API (#508) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index df7001ada9b..9c05255519b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-692cc74e438a991e1707d4b34506e3e8a0427a396d4d48be41f8cc979b2ac63b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a8e3aedb1193065fd84ae0b74a4a4c2d217ff2a821096f825a7798bbb921d76.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From a65350b2902039b065e404ab98778e3099135651 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 11:30:21 +0000 Subject: [PATCH 028/532] feat(api): OpenAPI spec update via Stainless API (#509) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9c05255519b..7dfe322054a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a8e3aedb1193065fd84ae0b74a4a4c2d217ff2a821096f825a7798bbb921d76.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-839600a13efe864362aeb0940c721ebf4bbace7a23853dc24da23e029dc06116.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 2a6e10c1df3d73a9b343a6d3fe4cc3fe76292ae6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 13:56:11 +0000 Subject: [PATCH 029/532] feat(api): OpenAPI spec update via Stainless API (#510) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7dfe322054a..35ae45dbcc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-839600a13efe864362aeb0940c721ebf4bbace7a23853dc24da23e029dc06116.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b643703b1659c3d33bcd4e748112bf350949fb6b15f6b6a8844785a8b938fd42.yml From caab85ac07d7ff7f4a4b876ce4f14cabc7df94e2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 15:04:56 +0000 Subject: [PATCH 030/532] feat(api): OpenAPI spec update via Stainless API (#511) --- .github/workflows/ci.yml | 16 +-- .stats.yml | 2 +- api.md | 28 ++--- scripts/format | 2 +- scripts/lint | 4 + scripts/test | 1 - .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 17 files changed, 301 insertions(+), 287 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc0298ed9e7..caedad093be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,20 +25,10 @@ jobs: RYE_INSTALL_OPTION: '--yes' - name: Install dependencies - run: | - rye sync --all-features - - - name: Run ruff - run: | - rye run check:ruff + run: rye sync --all-features - - name: Run type checking - run: | - rye run typecheck - - - name: Ensure importable - run: | - rye run python -c 'import cloudflare' + - name: Run lints + run: ./scripts/lint test: name: test runs-on: ubuntu-latest diff --git a/.stats.yml b/.stats.yml index 35ae45dbcc9..32196e35739 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b643703b1659c3d33bcd4e748112bf350949fb6b15f6b6a8844785a8b938fd42.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6629e066ac9e64b63617ec7ff5282f92c8ca3418ca069ab7cdc26786f14a7d96.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/scripts/format b/scripts/format index 2a9ea4664bf..667ec2d7af0 100755 --- a/scripts/format +++ b/scripts/format @@ -4,5 +4,5 @@ set -e cd "$(dirname "$0")/.." +echo "==> Running formatters" rye run format - diff --git a/scripts/lint b/scripts/lint index 0cc68b51578..aa39f69ffbd 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,5 +4,9 @@ set -e cd "$(dirname "$0")/.." +echo "==> Running lints" rye run lint +echo "==> Making sure it imports" +rye run python -c 'import cloudflare' + diff --git a/scripts/test b/scripts/test index be01d044734..b3ace9013bd 100755 --- a/scripts/test +++ b/scripts/test @@ -52,6 +52,5 @@ else echo fi -# Run tests echo "==> Running tests" rye run pytest "$@" diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From a93c30bb4f073c2c2d6ce1b925bc247a423b255b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 15:48:37 +0000 Subject: [PATCH 031/532] feat(api): OpenAPI spec update via Stainless API (#512) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 32196e35739..9423f835870 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6629e066ac9e64b63617ec7ff5282f92c8ca3418ca069ab7cdc26786f14a7d96.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69dd99f11f147729f5d95e3bcdee62057f64921f5f034ffac45948c8402697d2.yml From 4bdc3313806a4fdd990260f9a624b4633e06a9fa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 15:51:00 +0000 Subject: [PATCH 032/532] feat(api): OpenAPI spec update via Stainless API (#513) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9423f835870..17d7da2f44e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69dd99f11f147729f5d95e3bcdee62057f64921f5f034ffac45948c8402697d2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 20ca08ad8db76bf8aaa0a6f0619ce0bbf1d31a29 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 17:21:16 +0000 Subject: [PATCH 033/532] feat(api): OpenAPI spec update via Stainless API (#514) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 17d7da2f44e..9423f835870 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69dd99f11f147729f5d95e3bcdee62057f64921f5f034ffac45948c8402697d2.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 20eab356622afe0463f384eef780f7e641d89a73 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 17:23:39 +0000 Subject: [PATCH 034/532] feat(api): OpenAPI spec update via Stainless API (#515) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9423f835870..17d7da2f44e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69dd99f11f147729f5d95e3bcdee62057f64921f5f034ffac45948c8402697d2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 6d84dacd9b74280ec82cee7f6623a7f1e3086614 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 17:34:21 +0000 Subject: [PATCH 035/532] feat(api): OpenAPI spec update via Stainless API (#516) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 17d7da2f44e..60bf5d749b6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-52d9a2dc9d0868cab21ab7ca8255cacb967da100c31438203c397d7fefd5288c.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 76ec27f34e98527870ca2409e05cf8179f97cc33 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 18:11:29 +0000 Subject: [PATCH 036/532] feat(api): OpenAPI spec update via Stainless API (#517) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 60bf5d749b6..91a7572bfc8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-52d9a2dc9d0868cab21ab7ca8255cacb967da100c31438203c397d7fefd5288c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-99bd90b0a0f2472ad98f07bb87bf426278428a9891436afd8b355c8f57df5122.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From ed1fc9739406b198973d6ae6e1f1a8311eea88c9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 18:51:51 +0000 Subject: [PATCH 037/532] feat(api): OpenAPI spec update via Stainless API (#518) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 91a7572bfc8..60bf5d749b6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-99bd90b0a0f2472ad98f07bb87bf426278428a9891436afd8b355c8f57df5122.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-52d9a2dc9d0868cab21ab7ca8255cacb967da100c31438203c397d7fefd5288c.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From dcd56bfbef78e4878e9bbefd511959500c6c7a7b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 19:22:46 +0000 Subject: [PATCH 038/532] feat(api): OpenAPI spec update via Stainless API (#519) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 60bf5d749b6..17d7da2f44e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-52d9a2dc9d0868cab21ab7ca8255cacb967da100c31438203c397d7fefd5288c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From bc45d38985368c6401b6b990a66e9159b3a75486 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 19:25:12 +0000 Subject: [PATCH 039/532] feat(api): OpenAPI spec update via Stainless API (#520) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 17d7da2f44e..60bf5d749b6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-52d9a2dc9d0868cab21ab7ca8255cacb967da100c31438203c397d7fefd5288c.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From ec01cd00554336c10b6229bb5d7910120fd7330c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 21:48:34 +0000 Subject: [PATCH 040/532] feat(api): OpenAPI spec update via Stainless API (#521) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 60bf5d749b6..17d7da2f44e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-52d9a2dc9d0868cab21ab7ca8255cacb967da100c31438203c397d7fefd5288c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From c9404ef717942d08ff5c19776e2bdd382e2cc23d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 21:50:52 +0000 Subject: [PATCH 041/532] feat(api): OpenAPI spec update via Stainless API (#522) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 17d7da2f44e..91a7572bfc8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-99bd90b0a0f2472ad98f07bb87bf426278428a9891436afd8b355c8f57df5122.yml From a46239e37ffba33e1af667c881bc1fe050c08bed Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 09:45:14 +0000 Subject: [PATCH 042/532] feat(api): OpenAPI spec update via Stainless API (#523) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 91a7572bfc8..9423f835870 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-99bd90b0a0f2472ad98f07bb87bf426278428a9891436afd8b355c8f57df5122.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69dd99f11f147729f5d95e3bcdee62057f64921f5f034ffac45948c8402697d2.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From a60a6726b42a2af3217bba63c2a7edd93bb3b5ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 14:35:22 +0000 Subject: [PATCH 043/532] feat(api): OpenAPI spec update via Stainless API (#524) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9423f835870..60bf5d749b6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69dd99f11f147729f5d95e3bcdee62057f64921f5f034ffac45948c8402697d2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-52d9a2dc9d0868cab21ab7ca8255cacb967da100c31438203c397d7fefd5288c.yml From 164bac4e0aabe602ae2e0c219b8e9638cffdc851 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 16:28:51 +0000 Subject: [PATCH 044/532] feat(api): OpenAPI spec update via Stainless API (#525) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 60bf5d749b6..9423f835870 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-52d9a2dc9d0868cab21ab7ca8255cacb967da100c31438203c397d7fefd5288c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69dd99f11f147729f5d95e3bcdee62057f64921f5f034ffac45948c8402697d2.yml From 64f7884c78c671bb9dcf215f4d2956ea790f2a48 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 17:45:44 +0000 Subject: [PATCH 045/532] feat(api): OpenAPI spec update via Stainless API (#526) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9423f835870..17d7da2f44e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69dd99f11f147729f5d95e3bcdee62057f64921f5f034ffac45948c8402697d2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 6337e4591fc841365f4f1b899209b1dfd73681a2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 May 2024 22:35:23 +0000 Subject: [PATCH 046/532] feat(api): OpenAPI spec update via Stainless API (#527) --- src/cloudflare/resources/vectorize/indexes.py | 18 ++++++--- .../types/vectorize/index_insert_params.py | 5 ++- .../types/vectorize/index_upsert_params.py | 5 ++- tests/api_resources/vectorize/test_indexes.py | 40 +++++++++---------- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/cloudflare/resources/vectorize/indexes.py b/src/cloudflare/resources/vectorize/indexes.py index b58a753d658..fb9cdaeb7f0 100644 --- a/src/cloudflare/resources/vectorize/indexes.py +++ b/src/cloudflare/resources/vectorize/indexes.py @@ -6,7 +6,7 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes from ..._utils import ( maybe_transform, async_maybe_transform, @@ -375,7 +375,7 @@ def insert( index_name: str, *, account_id: str, - body: object, + body: FileTypes, # 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, @@ -390,6 +390,8 @@ def insert( Args: account_id: Identifier + body: ndjson file containing vectors to insert. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -487,7 +489,7 @@ def upsert( index_name: str, *, account_id: str, - body: object, + body: FileTypes, # 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, @@ -502,6 +504,8 @@ def upsert( Args: account_id: Identifier + body: ndjson file containing vectors to upsert. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -859,7 +863,7 @@ async def insert( index_name: str, *, account_id: str, - body: object, + body: FileTypes, # 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, @@ -874,6 +878,8 @@ async def insert( Args: account_id: Identifier + body: ndjson file containing vectors to insert. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -971,7 +977,7 @@ async def upsert( index_name: str, *, account_id: str, - body: object, + body: FileTypes, # 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, @@ -986,6 +992,8 @@ async def upsert( Args: account_id: Identifier + body: ndjson file containing vectors to upsert. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request diff --git a/src/cloudflare/types/vectorize/index_insert_params.py b/src/cloudflare/types/vectorize/index_insert_params.py index d5a829f9ee3..5498a47074e 100644 --- a/src/cloudflare/types/vectorize/index_insert_params.py +++ b/src/cloudflare/types/vectorize/index_insert_params.py @@ -4,6 +4,8 @@ from typing_extensions import Required, TypedDict +from ..._types import FileTypes + __all__ = ["IndexInsertParams"] @@ -11,4 +13,5 @@ class IndexInsertParams(TypedDict, total=False): account_id: Required[str] """Identifier""" - body: Required[object] + body: Required[FileTypes] + """ndjson file containing vectors to insert.""" diff --git a/src/cloudflare/types/vectorize/index_upsert_params.py b/src/cloudflare/types/vectorize/index_upsert_params.py index 6b187a77059..f9cd3161b36 100644 --- a/src/cloudflare/types/vectorize/index_upsert_params.py +++ b/src/cloudflare/types/vectorize/index_upsert_params.py @@ -4,6 +4,8 @@ from typing_extensions import Required, TypedDict +from ..._types import FileTypes + __all__ = ["IndexUpsertParams"] @@ -11,4 +13,5 @@ class IndexUpsertParams(TypedDict, total=False): account_id: Required[str] """Identifier""" - body: Required[object] + body: Required[FileTypes] + """ndjson file containing vectors to upsert.""" diff --git a/tests/api_resources/vectorize/test_indexes.py b/tests/api_resources/vectorize/test_indexes.py index d0a4beb4ea0..a4873ac1510 100644 --- a/tests/api_resources/vectorize/test_indexes.py +++ b/tests/api_resources/vectorize/test_indexes.py @@ -403,7 +403,7 @@ def test_method_insert(self, client: Cloudflare) -> None: index = client.vectorize.indexes.insert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) assert_matches_type(Optional[IndexInsert], index, path=["response"]) @@ -413,7 +413,7 @@ def test_raw_response_insert(self, client: Cloudflare) -> None: response = client.vectorize.indexes.with_raw_response.insert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) assert response.is_closed is True @@ -427,7 +427,7 @@ def test_streaming_response_insert(self, client: Cloudflare) -> None: with client.vectorize.indexes.with_streaming_response.insert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -444,14 +444,14 @@ def test_path_params_insert(self, client: Cloudflare) -> None: client.vectorize.indexes.with_raw_response.insert( "example-index", account_id="", - body={}, + body=b"raw file contents", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"): client.vectorize.indexes.with_raw_response.insert( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) @parametrize @@ -529,7 +529,7 @@ def test_method_upsert(self, client: Cloudflare) -> None: index = client.vectorize.indexes.upsert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) assert_matches_type(Optional[IndexUpsert], index, path=["response"]) @@ -539,7 +539,7 @@ def test_raw_response_upsert(self, client: Cloudflare) -> None: response = client.vectorize.indexes.with_raw_response.upsert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) assert response.is_closed is True @@ -553,7 +553,7 @@ def test_streaming_response_upsert(self, client: Cloudflare) -> None: with client.vectorize.indexes.with_streaming_response.upsert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -570,14 +570,14 @@ def test_path_params_upsert(self, client: Cloudflare) -> None: client.vectorize.indexes.with_raw_response.upsert( "example-index", account_id="", - body={}, + body=b"raw file contents", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"): client.vectorize.indexes.with_raw_response.upsert( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) @@ -962,7 +962,7 @@ async def test_method_insert(self, async_client: AsyncCloudflare) -> None: index = await async_client.vectorize.indexes.insert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) assert_matches_type(Optional[IndexInsert], index, path=["response"]) @@ -972,7 +972,7 @@ async def test_raw_response_insert(self, async_client: AsyncCloudflare) -> None: response = await async_client.vectorize.indexes.with_raw_response.insert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) assert response.is_closed is True @@ -986,7 +986,7 @@ async def test_streaming_response_insert(self, async_client: AsyncCloudflare) -> async with async_client.vectorize.indexes.with_streaming_response.insert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1003,14 +1003,14 @@ async def test_path_params_insert(self, async_client: AsyncCloudflare) -> None: await async_client.vectorize.indexes.with_raw_response.insert( "example-index", account_id="", - body={}, + body=b"raw file contents", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"): await async_client.vectorize.indexes.with_raw_response.insert( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) @parametrize @@ -1088,7 +1088,7 @@ async def test_method_upsert(self, async_client: AsyncCloudflare) -> None: index = await async_client.vectorize.indexes.upsert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) assert_matches_type(Optional[IndexUpsert], index, path=["response"]) @@ -1098,7 +1098,7 @@ async def test_raw_response_upsert(self, async_client: AsyncCloudflare) -> None: response = await async_client.vectorize.indexes.with_raw_response.upsert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) assert response.is_closed is True @@ -1112,7 +1112,7 @@ async def test_streaming_response_upsert(self, async_client: AsyncCloudflare) -> async with async_client.vectorize.indexes.with_streaming_response.upsert( "example-index", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1129,12 +1129,12 @@ async def test_path_params_upsert(self, async_client: AsyncCloudflare) -> None: await async_client.vectorize.indexes.with_raw_response.upsert( "example-index", account_id="", - body={}, + body=b"raw file contents", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"): await async_client.vectorize.indexes.with_raw_response.upsert( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, + body=b"raw file contents", ) From 0faf20d71dcc640a8c3b551fa554ce841a98ed02 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 07:21:23 +0000 Subject: [PATCH 047/532] feat(api): OpenAPI spec update via Stainless API (#528) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 17d7da2f44e..91a7572bfc8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a44a591dcd3f86f8878df473e944d1aa38570cfd6fe4d3b0d2129daa5d94fb0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-99bd90b0a0f2472ad98f07bb87bf426278428a9891436afd8b355c8f57df5122.yml From f2ed2d4dd490dacce938561f890338f0df1c8366 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 08:28:45 +0000 Subject: [PATCH 048/532] feat(api): OpenAPI spec update via Stainless API (#529) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- src/cloudflare/resources/radar/bgp/bgp.py | 6 +- .../resources/radar/bgp/hijacks/events.py | 4 +- src/cloudflare/resources/radar/bgp/routes.py | 8 +- .../resources/radar/bgp/top/ases.py | 6 +- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../radar/bgp/hijacks/event_list_params.py | 2 +- .../types/radar/bgp/route_moas_params.py | 2 +- .../types/radar/bgp/route_pfx2as_params.py | 2 +- .../types/radar/bgp/top/ase_get_params.py | 17 ++- .../types/radar/bgp_timeseries_params.py | 17 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- .../radar/bgp/hijacks/test_events.py | 4 +- tests/api_resources/radar/bgp/test_routes.py | 4 +- .../api_resources/radar/bgp/top/test_ases.py | 36 +++++- tests/api_resources/radar/test_bgp.py | 36 +++++- 26 files changed, 406 insertions(+), 303 deletions(-) diff --git a/.stats.yml b/.stats.yml index 91a7572bfc8..c9e1a8e746f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-99bd90b0a0f2472ad98f07bb87bf426278428a9891436afd8b355c8f57df5122.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e0c654af9fa84e81609b00c616ca5bbdcd5dc66ac4e5b2c185cc167ee6569d00.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/radar/bgp/bgp.py b/src/cloudflare/resources/radar/bgp/bgp.py index 2eb211139be..1db4a996c30 100644 --- a/src/cloudflare/resources/radar/bgp/bgp.py +++ b/src/cloudflare/resources/radar/bgp/bgp.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Union, cast +from typing import List, Type, Union, Iterable, cast from datetime import datetime from typing_extensions import Literal @@ -120,7 +120,7 @@ def timeseries( date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, name: List[str] | NotGiven = NOT_GIVEN, - prefix: List[str] | NotGiven = NOT_GIVEN, + prefix: Iterable[bgp_timeseries_params.Prefix] | NotGiven = NOT_GIVEN, update_type: List[Literal["ANNOUNCEMENT", "WITHDRAWAL"]] | 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. @@ -249,7 +249,7 @@ async def timeseries( date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, name: List[str] | NotGiven = NOT_GIVEN, - prefix: List[str] | NotGiven = NOT_GIVEN, + prefix: Iterable[bgp_timeseries_params.Prefix] | NotGiven = NOT_GIVEN, update_type: List[Literal["ANNOUNCEMENT", "WITHDRAWAL"]] | 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. diff --git a/src/cloudflare/resources/radar/bgp/hijacks/events.py b/src/cloudflare/resources/radar/bgp/hijacks/events.py index 6844c5c06d6..6700a064beb 100644 --- a/src/cloudflare/resources/radar/bgp/hijacks/events.py +++ b/src/cloudflare/resources/radar/bgp/hijacks/events.py @@ -111,7 +111,7 @@ def list( per_page: Number of entries per page - prefix: The prefix hijacked during a BGP hijack event + prefix: Network prefix, IPv4 or IPv6. sort_by: Sort events by field @@ -243,7 +243,7 @@ def list( per_page: Number of entries per page - prefix: The prefix hijacked during a BGP hijack event + prefix: Network prefix, IPv4 or IPv6. sort_by: Sort events by field diff --git a/src/cloudflare/resources/radar/bgp/routes.py b/src/cloudflare/resources/radar/bgp/routes.py index cdb54f244f5..e1fcef5229a 100644 --- a/src/cloudflare/resources/radar/bgp/routes.py +++ b/src/cloudflare/resources/radar/bgp/routes.py @@ -67,7 +67,7 @@ def moas( origin: Lookup MOASes originated by the given ASN - prefix: Lookup MOASes by prefix + prefix: Network prefix, IPv4 or IPv6. extra_headers: Send extra headers @@ -124,7 +124,7 @@ def pfx2as( origin: Lookup prefixes originated by the given ASN - prefix: Lookup origin ASNs of the given prefix + prefix: Network prefix, IPv4 or IPv6. rpki_status: Return only results with matching rpki status: valid, invalid or unknown @@ -329,7 +329,7 @@ async def moas( origin: Lookup MOASes originated by the given ASN - prefix: Lookup MOASes by prefix + prefix: Network prefix, IPv4 or IPv6. extra_headers: Send extra headers @@ -386,7 +386,7 @@ async def pfx2as( origin: Lookup prefixes originated by the given ASN - prefix: Lookup origin ASNs of the given prefix + prefix: Network prefix, IPv4 or IPv6. rpki_status: Return only results with matching rpki status: valid, invalid or unknown diff --git a/src/cloudflare/resources/radar/bgp/top/ases.py b/src/cloudflare/resources/radar/bgp/top/ases.py index 6a9a0994b59..c0b8db153c0 100644 --- a/src/cloudflare/resources/radar/bgp/top/ases.py +++ b/src/cloudflare/resources/radar/bgp/top/ases.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Union, cast +from typing import List, Type, Union, Iterable, cast from datetime import datetime from typing_extensions import Literal @@ -70,7 +70,7 @@ def get( format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, limit: int | NotGiven = NOT_GIVEN, name: List[str] | NotGiven = NOT_GIVEN, - prefix: List[str] | NotGiven = NOT_GIVEN, + prefix: Iterable[ase_get_params.Prefix] | NotGiven = NOT_GIVEN, update_type: List[Literal["ANNOUNCEMENT", "WITHDRAWAL"]] | 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. @@ -233,7 +233,7 @@ async def get( format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, limit: int | NotGiven = NOT_GIVEN, name: List[str] | NotGiven = NOT_GIVEN, - prefix: List[str] | NotGiven = NOT_GIVEN, + prefix: Iterable[ase_get_params.Prefix] | NotGiven = NOT_GIVEN, update_type: List[Literal["ANNOUNCEMENT", "WITHDRAWAL"]] | 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. diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/radar/bgp/hijacks/event_list_params.py b/src/cloudflare/types/radar/bgp/hijacks/event_list_params.py index 8bceb23cf4f..d4508e86b11 100644 --- a/src/cloudflare/types/radar/bgp/hijacks/event_list_params.py +++ b/src/cloudflare/types/radar/bgp/hijacks/event_list_params.py @@ -71,7 +71,7 @@ class EventListParams(TypedDict, total=False): """Number of entries per page""" prefix: str - """The prefix hijacked during a BGP hijack event""" + """Network prefix, IPv4 or IPv6.""" sort_by: Annotated[Literal["ID", "TIME", "CONFIDENCE"], PropertyInfo(alias="sortBy")] """Sort events by field""" diff --git a/src/cloudflare/types/radar/bgp/route_moas_params.py b/src/cloudflare/types/radar/bgp/route_moas_params.py index f4aff772fa5..8bf9d86d6c6 100644 --- a/src/cloudflare/types/radar/bgp/route_moas_params.py +++ b/src/cloudflare/types/radar/bgp/route_moas_params.py @@ -18,4 +18,4 @@ class RouteMoasParams(TypedDict, total=False): """Lookup MOASes originated by the given ASN""" prefix: str - """Lookup MOASes by prefix""" + """Network prefix, IPv4 or IPv6.""" diff --git a/src/cloudflare/types/radar/bgp/route_pfx2as_params.py b/src/cloudflare/types/radar/bgp/route_pfx2as_params.py index c3f84837f6d..caa3a87e8b0 100644 --- a/src/cloudflare/types/radar/bgp/route_pfx2as_params.py +++ b/src/cloudflare/types/radar/bgp/route_pfx2as_params.py @@ -23,7 +23,7 @@ class RoutePfx2asParams(TypedDict, total=False): """Lookup prefixes originated by the given ASN""" prefix: str - """Lookup origin ASNs of the given prefix""" + """Network prefix, IPv4 or IPv6.""" rpki_status: Annotated[Literal["VALID", "INVALID", "UNKNOWN"], PropertyInfo(alias="rpkiStatus")] """Return only results with matching rpki status: valid, invalid or unknown""" diff --git a/src/cloudflare/types/radar/bgp/top/ase_get_params.py b/src/cloudflare/types/radar/bgp/top/ase_get_params.py index c6d396e84ee..f24fe9c65e8 100644 --- a/src/cloudflare/types/radar/bgp/top/ase_get_params.py +++ b/src/cloudflare/types/radar/bgp/top/ase_get_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing import List, Union +from typing import List, Union, Iterable from datetime import datetime -from typing_extensions import Literal, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypedDict from ....._utils import PropertyInfo -__all__ = ["AseGetParams"] +__all__ = ["AseGetParams", "Prefix"] class AseGetParams(TypedDict, total=False): @@ -62,8 +62,17 @@ class AseGetParams(TypedDict, total=False): name: List[str] """Array of names that will be used to name the series in responses.""" - prefix: List[str] + prefix: Iterable[Prefix] """Array of BGP network prefixes.""" update_type: Annotated[List[Literal["ANNOUNCEMENT", "WITHDRAWAL"]], PropertyInfo(alias="updateType")] """Array of BGP update types.""" + + +class Prefix(TypedDict, total=False): + location: Required[str] + + name: Required[str] + + type: str + """Network prefix, IPv4 or IPv6.""" diff --git a/src/cloudflare/types/radar/bgp_timeseries_params.py b/src/cloudflare/types/radar/bgp_timeseries_params.py index 084c0cf5a5a..53697dd7bf2 100644 --- a/src/cloudflare/types/radar/bgp_timeseries_params.py +++ b/src/cloudflare/types/radar/bgp_timeseries_params.py @@ -2,13 +2,13 @@ from __future__ import annotations -from typing import List, Union +from typing import List, Union, Iterable from datetime import datetime -from typing_extensions import Literal, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypedDict from ..._utils import PropertyInfo -__all__ = ["BGPTimeseriesParams"] +__all__ = ["BGPTimeseriesParams", "Prefix"] class BGPTimeseriesParams(TypedDict, total=False): @@ -66,8 +66,17 @@ class BGPTimeseriesParams(TypedDict, total=False): name: List[str] """Array of names that will be used to name the series in responses.""" - prefix: List[str] + prefix: Iterable[Prefix] """Array of BGP network prefixes.""" update_type: Annotated[List[Literal["ANNOUNCEMENT", "WITHDRAWAL"]], PropertyInfo(alias="updateType")] """Array of BGP update types.""" + + +class Prefix(TypedDict, total=False): + location: Required[str] + + name: Required[str] + + type: str + """Network prefix, IPv4 or IPv6.""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/radar/bgp/hijacks/test_events.py b/tests/api_resources/radar/bgp/hijacks/test_events.py index f0f7fa02ebe..806bea3adbe 100644 --- a/tests/api_resources/radar/bgp/hijacks/test_events.py +++ b/tests/api_resources/radar/bgp/hijacks/test_events.py @@ -39,7 +39,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: min_confidence=0, page=0, per_page=0, - prefix="string", + prefix="1.1.1.0/24", sort_by="TIME", sort_order="DESC", victim_asn=0, @@ -90,7 +90,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) min_confidence=0, page=0, per_page=0, - prefix="string", + prefix="1.1.1.0/24", sort_by="TIME", sort_order="DESC", victim_asn=0, diff --git a/tests/api_resources/radar/bgp/test_routes.py b/tests/api_resources/radar/bgp/test_routes.py index a1bf66bc655..aeec1f26421 100644 --- a/tests/api_resources/radar/bgp/test_routes.py +++ b/tests/api_resources/radar/bgp/test_routes.py @@ -34,7 +34,7 @@ def test_method_moas_with_all_params(self, client: Cloudflare) -> None: format="JSON", invalid_only=True, origin=0, - prefix="string", + prefix="1.1.1.0/24", ) assert_matches_type(RouteMoasResponse, route, path=["response"]) @@ -181,7 +181,7 @@ async def test_method_moas_with_all_params(self, async_client: AsyncCloudflare) format="JSON", invalid_only=True, origin=0, - prefix="string", + prefix="1.1.1.0/24", ) assert_matches_type(RouteMoasResponse, route, path=["response"]) diff --git a/tests/api_resources/radar/bgp/top/test_ases.py b/tests/api_resources/radar/bgp/top/test_ases.py index 0eb51280b0a..137f86bd408 100644 --- a/tests/api_resources/radar/bgp/top/test_ases.py +++ b/tests/api_resources/radar/bgp/top/test_ases.py @@ -41,7 +41,23 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: format="JSON", limit=5, name=["string", "string", "string"], - prefix=["string", "string", "string"], + prefix=[ + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + ], update_type=["ANNOUNCEMENT", "WITHDRAWAL"], ) assert_matches_type(AseGetResponse, ase, path=["response"]) @@ -127,7 +143,23 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - format="JSON", limit=5, name=["string", "string", "string"], - prefix=["string", "string", "string"], + prefix=[ + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + ], update_type=["ANNOUNCEMENT", "WITHDRAWAL"], ) assert_matches_type(AseGetResponse, ase, path=["response"]) diff --git a/tests/api_resources/radar/test_bgp.py b/tests/api_resources/radar/test_bgp.py index b896b31f649..2b50ea81066 100644 --- a/tests/api_resources/radar/test_bgp.py +++ b/tests/api_resources/radar/test_bgp.py @@ -41,7 +41,23 @@ def test_method_timeseries_with_all_params(self, client: Cloudflare) -> None: ], format="JSON", name=["string", "string", "string"], - prefix=["string", "string", "string"], + prefix=[ + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + ], update_type=["ANNOUNCEMENT", "WITHDRAWAL"], ) assert_matches_type(BGPTimeseriesResponse, bgp, path=["response"]) @@ -93,7 +109,23 @@ async def test_method_timeseries_with_all_params(self, async_client: AsyncCloudf ], format="JSON", name=["string", "string", "string"], - prefix=["string", "string", "string"], + prefix=[ + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + { + "location": "query", + "name": "prefix", + "type": "1.1.1.0/24", + }, + ], update_type=["ANNOUNCEMENT", "WITHDRAWAL"], ) assert_matches_type(BGPTimeseriesResponse, bgp, path=["response"]) From 9eac477b52b5bdbe6951a1f912d60aa72eb724a6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 09:12:23 +0000 Subject: [PATCH 049/532] feat(api): OpenAPI spec update via Stainless API (#530) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../types/ai_gateway/log_get_response.py | 4 +- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 14 files changed, 275 insertions(+), 294 deletions(-) diff --git a/.stats.yml b/.stats.yml index c9e1a8e746f..908d46bb7af 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e0c654af9fa84e81609b00c616ca5bbdcd5dc66ac4e5b2c185cc167ee6569d00.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/ai_gateway/log_get_response.py b/src/cloudflare/types/ai_gateway/log_get_response.py index 052d5d9d921..c7d5c35580f 100644 --- a/src/cloudflare/types/ai_gateway/log_get_response.py +++ b/src/cloudflare/types/ai_gateway/log_get_response.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List +from typing import List, Optional from datetime import datetime from ..._models import BaseModel @@ -33,5 +33,7 @@ class LogGetResponseItem(BaseModel): tokens_out: int + status_code: Optional[int] = None + LogGetResponse = List[LogGetResponseItem] diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 263542437d04993d0b36bae92d4050a8ec88be5f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 10:02:10 +0000 Subject: [PATCH 050/532] feat(api): OpenAPI spec update via Stainless API (#531) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 908d46bb7af..c2219e29e58 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml From 352f1721b2d819cccdc5ab36dcf39accc469777a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 10:44:53 +0000 Subject: [PATCH 051/532] feat(api): OpenAPI spec update via Stainless API (#532) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c2219e29e58..908d46bb7af 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml From 4713afb1d263a01eb2f24fc25a2a9f9ee7082606 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 11:18:40 +0000 Subject: [PATCH 052/532] feat(api): OpenAPI spec update via Stainless API (#533) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 908d46bb7af..c2219e29e58 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml From 9cd6a9b9641d4c21a923fc74bd677ff75d3d493b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 11:21:28 +0000 Subject: [PATCH 053/532] feat(api): OpenAPI spec update via Stainless API (#534) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index c2219e29e58..91651da7fa5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-191bc622535f6b2079b5b94b330df7766fc0940d9faf8adf4e3b6a185d2d1353.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From ac8b5b52e91d3c52a1aba445eca5557e725cb48d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 12:02:51 +0000 Subject: [PATCH 054/532] feat(api): OpenAPI spec update via Stainless API (#535) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 91651da7fa5..c2219e29e58 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-191bc622535f6b2079b5b94b330df7766fc0940d9faf8adf4e3b6a185d2d1353.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From aa8eab15fd2a48d2d66797af5fb56416efee9821 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 12:05:22 +0000 Subject: [PATCH 055/532] feat(api): OpenAPI spec update via Stainless API (#536) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c2219e29e58..908d46bb7af 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml From ae8abbd4602eba273f55b9240c2d5aaef7a1f31f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 13:20:13 +0000 Subject: [PATCH 056/532] feat(api): OpenAPI spec update via Stainless API (#537) --- .stats.yml | 2 +- tests/test_client.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 908d46bb7af..c2219e29e58 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml diff --git a/tests/test_client.py b/tests/test_client.py index e16d2dc4612..ebfafa47bf1 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -372,6 +372,7 @@ def test_validate_headers(self) -> None: assert request.headers.get("X-Auth-Key") == api_key client2 = Cloudflare(base_url=base_url, api_key=None, api_email=None, _strict_response_validation=True) + with pytest.raises( TypeError, match="Could not resolve authentication method. Expected one of api_email, api_key, api_token or user_service_key to be set. Or for one of the `X-Auth-Email`, `X-Auth-Key`, `Authorization` or `X-Auth-User-Service-Key` headers to be explicitly omitted", @@ -1142,6 +1143,7 @@ def test_validate_headers(self) -> None: assert request.headers.get("X-Auth-Key") == api_key client2 = AsyncCloudflare(base_url=base_url, api_key=None, api_email=None, _strict_response_validation=True) + with pytest.raises( TypeError, match="Could not resolve authentication method. Expected one of api_email, api_key, api_token or user_service_key to be set. Or for one of the `X-Auth-Email`, `X-Auth-Key`, `Authorization` or `X-Auth-User-Service-Key` headers to be explicitly omitted", From 58f96214ccd8d1a8811bde77d8dae04142447312 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 13:41:40 +0000 Subject: [PATCH 057/532] feat(api): OpenAPI spec update via Stainless API (#538) --- .stats.yml | 2 +- src/cloudflare/pagination.py | 44 +++++++----------------------------- 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/.stats.yml b/.stats.yml index c2219e29e58..908d46bb7af 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml diff --git a/src/cloudflare/pagination.py b/src/cloudflare/pagination.py index 37e133da6f6..7d52fed691a 100644 --- a/src/cloudflare/pagination.py +++ b/src/cloudflare/pagination.py @@ -52,16 +52,9 @@ def _get_page_items(self) -> List[_T]: @override def next_page_info(self) -> Optional[PageInfo]: - current_page = cast("int | None", self._options.params.get("page")) - if current_page is None: - current_page = 1 + last_page = cast("int | None", self._options.params.get("page")) or 1 - last_page = cast("int | None", self._options.params.get("page")) - if last_page is not None and current_page <= last_page: - # The API didn't return a new page in the last request - return None - - return PageInfo(params={"page": current_page + 1}) + return PageInfo(params={"page": last_page + 1}) class AsyncV4PagePagination(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): @@ -79,16 +72,9 @@ def _get_page_items(self) -> List[_T]: @override def next_page_info(self) -> Optional[PageInfo]: - current_page = cast("int | None", self._options.params.get("page")) - if current_page is None: - current_page = 1 - - last_page = cast("int | None", self._options.params.get("page")) - if last_page is not None and current_page <= last_page: - # The API didn't return a new page in the last request - return None + last_page = cast("int | None", self._options.params.get("page")) or 1 - return PageInfo(params={"page": current_page + 1}) + return PageInfo(params={"page": last_page + 1}) class V4PagePaginationArrayResultInfo(BaseModel): @@ -110,16 +96,9 @@ def _get_page_items(self) -> List[_T]: @override def next_page_info(self) -> Optional[PageInfo]: - current_page = cast("int | None", self._options.params.get("page")) - if current_page is None: - current_page = 1 + last_page = cast("int | None", self._options.params.get("page")) or 1 - last_page = cast("int | None", self._options.params.get("page")) - if last_page is not None and current_page <= last_page: - # The API didn't return a new page in the last request - return None - - return PageInfo(params={"page": current_page + 1}) + return PageInfo(params={"page": last_page + 1}) class AsyncV4PagePaginationArray(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): @@ -135,16 +114,9 @@ def _get_page_items(self) -> List[_T]: @override def next_page_info(self) -> Optional[PageInfo]: - current_page = cast("int | None", self._options.params.get("page")) - if current_page is None: - current_page = 1 - - last_page = cast("int | None", self._options.params.get("page")) - if last_page is not None and current_page <= last_page: - # The API didn't return a new page in the last request - return None + last_page = cast("int | None", self._options.params.get("page")) or 1 - return PageInfo(params={"page": current_page + 1}) + return PageInfo(params={"page": last_page + 1}) class CursorPaginationResultInfo(BaseModel): From c7988e0f9d17bda06492d17c6f0d066c0db69ff8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 13:47:19 +0000 Subject: [PATCH 058/532] feat(api): OpenAPI spec update via Stainless API (#539) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 908d46bb7af..6fc17c6d588 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9c9cdda0a86077d8bb70f538448d4cfc7558b40c55c7d1c28f68854b913f7c41.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 36b6d70587982d175c876ad2bb041cd0064bff95 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 14:15:50 +0000 Subject: [PATCH 059/532] feat(api): OpenAPI spec update via Stainless API (#540) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6fc17c6d588..c2219e29e58 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9c9cdda0a86077d8bb70f538448d4cfc7558b40c55c7d1c28f68854b913f7c41.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 93440abad3376e5025e1d7ff774406fbf86280bb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 14:18:19 +0000 Subject: [PATCH 060/532] feat(api): OpenAPI spec update via Stainless API (#541) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index c2219e29e58..6fc17c6d588 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9c9cdda0a86077d8bb70f538448d4cfc7558b40c55c7d1c28f68854b913f7c41.yml diff --git a/api.md b/api.md index 5846ed823de..196e434efb8 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 672a3cbeb4e063815c450f1c3048bbdf53617a2e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 14:20:52 +0000 Subject: [PATCH 061/532] feat(api): OpenAPI spec update via Stainless API (#542) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6fc17c6d588..c2219e29e58 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9c9cdda0a86077d8bb70f538448d4cfc7558b40c55c7d1c28f68854b913f7c41.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml diff --git a/api.md b/api.md index 196e434efb8..5846ed823de 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7454,14 +7454,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7477,10 +7477,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7497,11 +7497,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From aaba269e9027b9c77063983b010202eecd3f1312 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 14:23:20 +0000 Subject: [PATCH 062/532] feat(api): OpenAPI spec update via Stainless API (#543) --- .stats.yml | 4 +- api.md | 39 +- .../cloudforce_one/requests/message.py | 76 ++-- .../cloudforce_one/requests/priority.py | 88 +++-- .../cloudforce_one/requests/requests.py | 112 +++--- src/cloudflare/resources/d1/database.py | 335 +----------------- src/cloudflare/resources/intel/whois.py | 14 +- .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- src/cloudflare/types/d1/__init__.py | 4 - .../types/d1/database_delete_response.py | 7 - .../types/d1/database_query_params.py | 17 - .../types/d1/database_query_response.py | 9 - src/cloudflare/types/d1/query_result.py | 31 -- .../cloudforce_one/requests/test_message.py | 50 +-- .../cloudforce_one/requests/test_priority.py | 50 +-- .../cloudforce_one/test_requests.py | 82 ++--- tests/api_resources/d1/test_database.py | 321 ----------------- tests/api_resources/intel/test_whois.py | 18 +- 20 files changed, 297 insertions(+), 1005 deletions(-) delete mode 100644 src/cloudflare/types/d1/database_delete_response.py delete mode 100644 src/cloudflare/types/d1/database_query_params.py delete mode 100644 src/cloudflare/types/d1/database_query_response.py delete mode 100644 src/cloudflare/types/d1/query_result.py diff --git a/.stats.yml b/.stats.yml index c2219e29e58..c136090cc37 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1286 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-03573240641a2c0ec81ecd650a4e8be921d8cf797acfa5bcb504300e254a9ce3.yml +configured_endpoints: 1283 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-19826fa2034ab86674d8dfba6d0db4e84b60161e42867c90ca7e177751d28962.yml diff --git a/api.md b/api.md index 5846ed823de..204b5af3418 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -4601,22 +4601,13 @@ from cloudflare.types.d1 import D1 Types: ```python -from cloudflare.types.d1 import ( - QueryResult, - DatabaseCreateResponse, - DatabaseListResponse, - DatabaseDeleteResponse, - DatabaseQueryResponse, -) +from cloudflare.types.d1 import QueryResult, DatabaseCreateResponse, DatabaseListResponse ``` Methods: - client.d1.database.create(\*, account_id, \*\*params) -> DatabaseCreateResponse - client.d1.database.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DatabaseListResponse] -- client.d1.database.delete(database_identifier, \*, account_identifier) -> DatabaseDeleteResponse -- client.d1.database.get(database_identifier, \*, account_identifier) -> D1 -- client.d1.database.query(database_identifier, \*, account_identifier, \*\*params) -> DatabaseQueryResponse # R2 @@ -7454,14 +7445,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7477,10 +7468,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7497,11 +7488,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/d1/database.py b/src/cloudflare/resources/d1/database.py index fbdcdffd1f5..9dcab589d15 100644 --- a/src/cloudflare/resources/d1/database.py +++ b/src/cloudflare/resources/d1/database.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import Type, cast import httpx @@ -12,7 +12,7 @@ async_maybe_transform, ) from ..._compat import cached_property -from ...types.d1 import database_list_params, database_query_params, database_create_params +from ...types.d1 import database_list_params, database_create_params from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, @@ -22,15 +22,12 @@ ) from ..._wrappers import ResultWrapper from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ...types.d1.d1 import D1 from ..._base_client import ( AsyncPaginator, make_request_options, ) from ...types.d1.database_list_response import DatabaseListResponse -from ...types.d1.database_query_response import DatabaseQueryResponse from ...types.d1.database_create_response import DatabaseCreateResponse -from ...types.d1.database_delete_response import DatabaseDeleteResponse __all__ = ["DatabaseResource", "AsyncDatabaseResource"] @@ -141,152 +138,6 @@ def list( model=DatabaseListResponse, ) - def delete( - self, - database_identifier: str, - *, - account_identifier: 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, - ) -> DatabaseDeleteResponse: - """ - Deletes the specified D1 database. - - Args: - account_identifier: Account identifier tag. - - 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_identifier: - raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") - if not database_identifier: - raise ValueError( - f"Expected a non-empty value for `database_identifier` but received {database_identifier!r}" - ) - return cast( - DatabaseDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/d1/database/{database_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[DatabaseDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[DatabaseDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def get( - self, - database_identifier: str, - *, - account_identifier: 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, - ) -> D1: - """ - Returns the specified D1 database. - - Args: - account_identifier: Account identifier tag. - - 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_identifier: - raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") - if not database_identifier: - raise ValueError( - f"Expected a non-empty value for `database_identifier` but received {database_identifier!r}" - ) - return self._get( - f"/accounts/{account_identifier}/d1/database/{database_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[D1]._unwrapper, - ), - cast_to=cast(Type[D1], ResultWrapper[D1]), - ) - - def query( - self, - database_identifier: str, - *, - account_identifier: str, - sql: str, - params: List[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, - ) -> DatabaseQueryResponse: - """ - Returns the query result. - - Args: - account_identifier: Account identifier tag. - - 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_identifier: - raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") - if not database_identifier: - raise ValueError( - f"Expected a non-empty value for `database_identifier` but received {database_identifier!r}" - ) - return self._post( - f"/accounts/{account_identifier}/d1/database/{database_identifier}/query", - body=maybe_transform( - { - "sql": sql, - "params": params, - }, - database_query_params.DatabaseQueryParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[DatabaseQueryResponse]._unwrapper, - ), - cast_to=cast(Type[DatabaseQueryResponse], ResultWrapper[DatabaseQueryResponse]), - ) - class AsyncDatabaseResource(AsyncAPIResource): @cached_property @@ -394,152 +245,6 @@ def list( model=DatabaseListResponse, ) - async def delete( - self, - database_identifier: str, - *, - account_identifier: 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, - ) -> DatabaseDeleteResponse: - """ - Deletes the specified D1 database. - - Args: - account_identifier: Account identifier tag. - - 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_identifier: - raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") - if not database_identifier: - raise ValueError( - f"Expected a non-empty value for `database_identifier` but received {database_identifier!r}" - ) - return cast( - DatabaseDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/d1/database/{database_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[DatabaseDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[DatabaseDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - async def get( - self, - database_identifier: str, - *, - account_identifier: 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, - ) -> D1: - """ - Returns the specified D1 database. - - Args: - account_identifier: Account identifier tag. - - 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_identifier: - raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") - if not database_identifier: - raise ValueError( - f"Expected a non-empty value for `database_identifier` but received {database_identifier!r}" - ) - return await self._get( - f"/accounts/{account_identifier}/d1/database/{database_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[D1]._unwrapper, - ), - cast_to=cast(Type[D1], ResultWrapper[D1]), - ) - - async def query( - self, - database_identifier: str, - *, - account_identifier: str, - sql: str, - params: List[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, - ) -> DatabaseQueryResponse: - """ - Returns the query result. - - Args: - account_identifier: Account identifier tag. - - 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_identifier: - raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") - if not database_identifier: - raise ValueError( - f"Expected a non-empty value for `database_identifier` but received {database_identifier!r}" - ) - return await self._post( - f"/accounts/{account_identifier}/d1/database/{database_identifier}/query", - body=await async_maybe_transform( - { - "sql": sql, - "params": params, - }, - database_query_params.DatabaseQueryParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[DatabaseQueryResponse]._unwrapper, - ), - cast_to=cast(Type[DatabaseQueryResponse], ResultWrapper[DatabaseQueryResponse]), - ) - class DatabaseResourceWithRawResponse: def __init__(self, database: DatabaseResource) -> None: @@ -551,15 +256,6 @@ def __init__(self, database: DatabaseResource) -> None: self.list = to_raw_response_wrapper( database.list, ) - self.delete = to_raw_response_wrapper( - database.delete, - ) - self.get = to_raw_response_wrapper( - database.get, - ) - self.query = to_raw_response_wrapper( - database.query, - ) class AsyncDatabaseResourceWithRawResponse: @@ -572,15 +268,6 @@ def __init__(self, database: AsyncDatabaseResource) -> None: self.list = async_to_raw_response_wrapper( database.list, ) - self.delete = async_to_raw_response_wrapper( - database.delete, - ) - self.get = async_to_raw_response_wrapper( - database.get, - ) - self.query = async_to_raw_response_wrapper( - database.query, - ) class DatabaseResourceWithStreamingResponse: @@ -593,15 +280,6 @@ def __init__(self, database: DatabaseResource) -> None: self.list = to_streamed_response_wrapper( database.list, ) - self.delete = to_streamed_response_wrapper( - database.delete, - ) - self.get = to_streamed_response_wrapper( - database.get, - ) - self.query = to_streamed_response_wrapper( - database.query, - ) class AsyncDatabaseResourceWithStreamingResponse: @@ -614,12 +292,3 @@ def __init__(self, database: AsyncDatabaseResource) -> None: self.list = async_to_streamed_response_wrapper( database.list, ) - self.delete = async_to_streamed_response_wrapper( - database.delete, - ) - self.get = async_to_streamed_response_wrapper( - database.get, - ) - self.query = async_to_streamed_response_wrapper( - database.query, - ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/d1/__init__.py b/src/cloudflare/types/d1/__init__.py index 2c77c7a96e5..e46c7ede08c 100644 --- a/src/cloudflare/types/d1/__init__.py +++ b/src/cloudflare/types/d1/__init__.py @@ -3,11 +3,7 @@ from __future__ import annotations from .d1 import D1 as D1 -from .query_result import QueryResult as QueryResult from .database_list_params import DatabaseListParams as DatabaseListParams -from .database_query_params import DatabaseQueryParams as DatabaseQueryParams from .database_create_params import DatabaseCreateParams as DatabaseCreateParams from .database_list_response import DatabaseListResponse as DatabaseListResponse -from .database_query_response import DatabaseQueryResponse as DatabaseQueryResponse from .database_create_response import DatabaseCreateResponse as DatabaseCreateResponse -from .database_delete_response import DatabaseDeleteResponse as DatabaseDeleteResponse diff --git a/src/cloudflare/types/d1/database_delete_response.py b/src/cloudflare/types/d1/database_delete_response.py deleted file mode 100644 index 53e10cdd237..00000000000 --- a/src/cloudflare/types/d1/database_delete_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["DatabaseDeleteResponse"] - -DatabaseDeleteResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/d1/database_query_params.py b/src/cloudflare/types/d1/database_query_params.py deleted file mode 100644 index c76047eb12b..00000000000 --- a/src/cloudflare/types/d1/database_query_params.py +++ /dev/null @@ -1,17 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List -from typing_extensions import Required, TypedDict - -__all__ = ["DatabaseQueryParams"] - - -class DatabaseQueryParams(TypedDict, total=False): - account_identifier: Required[str] - """Account identifier tag.""" - - sql: Required[str] - - params: List[str] diff --git a/src/cloudflare/types/d1/database_query_response.py b/src/cloudflare/types/d1/database_query_response.py deleted file mode 100644 index 4e2d7a949cd..00000000000 --- a/src/cloudflare/types/d1/database_query_response.py +++ /dev/null @@ -1,9 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List - -from .query_result import QueryResult - -__all__ = ["DatabaseQueryResponse"] - -DatabaseQueryResponse = List[QueryResult] diff --git a/src/cloudflare/types/d1/query_result.py b/src/cloudflare/types/d1/query_result.py deleted file mode 100644 index 7b6447cd084..00000000000 --- a/src/cloudflare/types/d1/query_result.py +++ /dev/null @@ -1,31 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional - -from ..._models import BaseModel - -__all__ = ["QueryResult", "Meta"] - - -class Meta(BaseModel): - changed_db: Optional[bool] = None - - changes: Optional[float] = None - - duration: Optional[float] = None - - last_row_id: Optional[float] = None - - rows_read: Optional[float] = None - - rows_written: Optional[float] = None - - size_after: Optional[float] = None - - -class QueryResult(BaseModel): - meta: Optional[Meta] = None - - results: Optional[List[object]] = None - - success: Optional[bool] = None diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/d1/test_database.py b/tests/api_resources/d1/test_database.py index 30697981791..a27420dbd1e 100644 --- a/tests/api_resources/d1/test_database.py +++ b/tests/api_resources/d1/test_database.py @@ -10,11 +10,8 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.types.d1 import ( - D1, DatabaseListResponse, - DatabaseQueryResponse, DatabaseCreateResponse, - DatabaseDeleteResponse, ) from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray @@ -114,165 +111,6 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - database = client.d1.database.delete( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(DatabaseDeleteResponse, database, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.d1.database.with_raw_response.delete( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - database = response.parse() - assert_matches_type(DatabaseDeleteResponse, database, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.d1.database.with_streaming_response.delete( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - database = response.parse() - assert_matches_type(DatabaseDeleteResponse, database, 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_identifier` but received ''"): - client.d1.database.with_raw_response.delete( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_identifier` but received ''"): - client.d1.database.with_raw_response.delete( - "", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - database = client.d1.database.get( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(D1, database, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.d1.database.with_raw_response.get( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - database = response.parse() - assert_matches_type(D1, database, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.d1.database.with_streaming_response.get( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - database = response.parse() - assert_matches_type(D1, database, 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_identifier` but received ''"): - client.d1.database.with_raw_response.get( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_identifier` but received ''"): - client.d1.database.with_raw_response.get( - "", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_query(self, client: Cloudflare) -> None: - database = client.d1.database.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) - assert_matches_type(DatabaseQueryResponse, database, path=["response"]) - - @parametrize - def test_method_query_with_all_params(self, client: Cloudflare) -> None: - database = client.d1.database.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - params=["firstParam", "secondParam"], - ) - assert_matches_type(DatabaseQueryResponse, database, path=["response"]) - - @parametrize - def test_raw_response_query(self, client: Cloudflare) -> None: - response = client.d1.database.with_raw_response.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - database = response.parse() - assert_matches_type(DatabaseQueryResponse, database, path=["response"]) - - @parametrize - def test_streaming_response_query(self, client: Cloudflare) -> None: - with client.d1.database.with_streaming_response.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - database = response.parse() - assert_matches_type(DatabaseQueryResponse, database, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_query(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): - client.d1.database.with_raw_response.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_identifier` but received ''"): - client.d1.database.with_raw_response.query( - "", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) - class TestAsyncDatabase: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -366,162 +204,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.d1.database.with_raw_response.list( account_id="", ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - database = await async_client.d1.database.delete( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(DatabaseDeleteResponse, database, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.d1.database.with_raw_response.delete( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - database = await response.parse() - assert_matches_type(DatabaseDeleteResponse, database, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.d1.database.with_streaming_response.delete( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - database = await response.parse() - assert_matches_type(DatabaseDeleteResponse, database, 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_identifier` but received ''"): - await async_client.d1.database.with_raw_response.delete( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_identifier` but received ''"): - await async_client.d1.database.with_raw_response.delete( - "", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - database = await async_client.d1.database.get( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(D1, database, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.d1.database.with_raw_response.get( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - database = await response.parse() - assert_matches_type(D1, database, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.d1.database.with_streaming_response.get( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - database = await response.parse() - assert_matches_type(D1, database, 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_identifier` but received ''"): - await async_client.d1.database.with_raw_response.get( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_identifier` but received ''"): - await async_client.d1.database.with_raw_response.get( - "", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_query(self, async_client: AsyncCloudflare) -> None: - database = await async_client.d1.database.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) - assert_matches_type(DatabaseQueryResponse, database, path=["response"]) - - @parametrize - async def test_method_query_with_all_params(self, async_client: AsyncCloudflare) -> None: - database = await async_client.d1.database.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - params=["firstParam", "secondParam"], - ) - assert_matches_type(DatabaseQueryResponse, database, path=["response"]) - - @parametrize - async def test_raw_response_query(self, async_client: AsyncCloudflare) -> None: - response = await async_client.d1.database.with_raw_response.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - database = await response.parse() - assert_matches_type(DatabaseQueryResponse, database, path=["response"]) - - @parametrize - async def test_streaming_response_query(self, async_client: AsyncCloudflare) -> None: - async with async_client.d1.database.with_streaming_response.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - database = await response.parse() - assert_matches_type(DatabaseQueryResponse, database, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_query(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): - await async_client.d1.database.with_raw_response.query( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - account_identifier="", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_identifier` but received ''"): - await async_client.d1.database.with_raw_response.query( - "", - account_identifier="023e105f4ecef8ad9ca31a8372d0c353", - sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", - ) diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 0c946dd44cb21689da1d0154edfd8caf56932ad7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 14:40:46 +0000 Subject: [PATCH 063/532] feat(api): OpenAPI spec update via Stainless API (#544) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c136090cc37..a7778bce73e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-19826fa2034ab86674d8dfba6d0db4e84b60161e42867c90ca7e177751d28962.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9641d27447b6a4a83ab5fbf33bbb75d5ac480bf84d636db5a2f613b6c29a664b.yml From 6c9b54fe6f627a6e3e562cc9738fc9b84ae7cc75 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 15:04:29 +0000 Subject: [PATCH 064/532] feat(api): OpenAPI spec update via Stainless API (#545) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index a7778bce73e..d147eb1e672 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9641d27447b6a4a83ab5fbf33bbb75d5ac480bf84d636db5a2f613b6c29a664b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bb3bdb8322e9c9e14555e147429bc9616f83334e9eb3b5ff894ee1d8d6dd4644.yml diff --git a/api.md b/api.md index 204b5af3418..a31d3f8c881 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7445,14 +7445,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7468,10 +7468,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7488,11 +7488,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 9410b122f407e9b7a7ba7eca8453e90a23f55e62 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 15:12:01 +0000 Subject: [PATCH 065/532] feat(api): OpenAPI spec update via Stainless API (#546) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index d147eb1e672..c136090cc37 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bb3bdb8322e9c9e14555e147429bc9616f83334e9eb3b5ff894ee1d8d6dd4644.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-19826fa2034ab86674d8dfba6d0db4e84b60161e42867c90ca7e177751d28962.yml diff --git a/api.md b/api.md index a31d3f8c881..204b5af3418 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7445,14 +7445,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7468,10 +7468,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7488,11 +7488,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 7e086e79b62a28358da1bce0d0d36cfe44c37f31 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 16:13:10 +0000 Subject: [PATCH 066/532] feat(api): OpenAPI spec update via Stainless API (#547) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c136090cc37..a7778bce73e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-19826fa2034ab86674d8dfba6d0db4e84b60161e42867c90ca7e177751d28962.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9641d27447b6a4a83ab5fbf33bbb75d5ac480bf84d636db5a2f613b6c29a664b.yml From edfd83972a34464739ffc4b2c0af728ec9b38846 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 17:54:33 +0000 Subject: [PATCH 067/532] feat(api): OpenAPI spec update via Stainless API (#548) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a7778bce73e..c136090cc37 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9641d27447b6a4a83ab5fbf33bbb75d5ac480bf84d636db5a2f613b6c29a664b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-19826fa2034ab86674d8dfba6d0db4e84b60161e42867c90ca7e177751d28962.yml From a73e978ca5f5d5747c54b547e13c208443e4729b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 17:58:41 +0000 Subject: [PATCH 068/532] feat(api): OpenAPI spec update via Stainless API (#549) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index c136090cc37..d147eb1e672 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-19826fa2034ab86674d8dfba6d0db4e84b60161e42867c90ca7e177751d28962.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bb3bdb8322e9c9e14555e147429bc9616f83334e9eb3b5ff894ee1d8d6dd4644.yml diff --git a/api.md b/api.md index 204b5af3418..a31d3f8c881 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7445,14 +7445,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7468,10 +7468,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7488,11 +7488,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From e636b068e7c1697656885bb5b89e6b26419f2a1f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 18:39:53 +0000 Subject: [PATCH 069/532] feat(api): OpenAPI spec update via Stainless API (#550) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index d147eb1e672..1220b9bfc4d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bb3bdb8322e9c9e14555e147429bc9616f83334e9eb3b5ff894ee1d8d6dd4644.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd056d9703c11b6fca49ee290875ea3affc22bf02b29a63959f64c669ada354.yml diff --git a/api.md b/api.md index a31d3f8c881..204b5af3418 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7445,14 +7445,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7468,10 +7468,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7488,11 +7488,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 0b6f56b17aea592e5a9c7289711f7530d3803a78 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 19:08:29 +0000 Subject: [PATCH 070/532] feat(api): OpenAPI spec update via Stainless API (#551) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1220b9bfc4d..be95bf8bbf8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd056d9703c11b6fca49ee290875ea3affc22bf02b29a63959f64c669ada354.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-241f970730129e553d466806420a1cf2f6d665abec11667004cb9cf070932a1e.yml From ab39ea3971f428dc42a3418b67b1ce0f61cbbbd6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 19:10:59 +0000 Subject: [PATCH 071/532] feat(api): OpenAPI spec update via Stainless API (#552) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index be95bf8bbf8..1220b9bfc4d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-241f970730129e553d466806420a1cf2f6d665abec11667004cb9cf070932a1e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd056d9703c11b6fca49ee290875ea3affc22bf02b29a63959f64c669ada354.yml From 730d034ce7b8f78dfee470e9f89eba82e393c0e8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 19:21:26 +0000 Subject: [PATCH 072/532] feat(api): OpenAPI spec update via Stainless API (#553) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1220b9bfc4d..be95bf8bbf8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1283 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd056d9703c11b6fca49ee290875ea3affc22bf02b29a63959f64c669ada354.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-241f970730129e553d466806420a1cf2f6d665abec11667004cb9cf070932a1e.yml From b4edfaefca67c651509ba681f6bda3dcd1754606 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 00:23:23 +0000 Subject: [PATCH 073/532] feat(api): update via SDK Studio (#554) --- .stats.yml | 2 +- api.md | 49 +- src/cloudflare/resources/d1/database.py | 323 ++++++++- .../resources/magic_transit/sites/acls.py | 164 ++++- .../resources/magic_transit/sites/lans.py | 162 ++++- .../resources/magic_transit/sites/sites.py | 153 ++++- .../resources/magic_transit/sites/wans.py | 152 ++++- .../zero_trust/risk_scoring/__init__.py | 14 + .../risk_scoring/integrations/__init__.py | 33 + .../risk_scoring/integrations/integrations.py | 631 ++++++++++++++++++ .../risk_scoring/integrations/references.py | 160 +++++ .../zero_trust/risk_scoring/risk_scoring.py | 33 + src/cloudflare/types/d1/__init__.py | 4 + .../types/d1/database_delete_response.py | 7 + .../types/d1/database_query_params.py | 17 + .../types/d1/database_query_response.py | 9 + src/cloudflare/types/d1/query_result.py | 31 + .../types/magic_transit/__init__.py | 1 + .../types/magic_transit/site_edit_params.py | 28 + .../types/magic_transit/sites/__init__.py | 3 + .../magic_transit/sites/acl_edit_params.py | 39 ++ .../magic_transit/sites/lan_edit_params.py | 38 ++ .../magic_transit/sites/wan_edit_params.py | 32 + .../types/zero_trust/risk_scoring/__init__.py | 6 + .../risk_scoring/integration_create_params.py | 24 + .../integration_create_response.py | 34 + .../risk_scoring/integration_get_response.py | 34 + .../risk_scoring/integration_list_response.py | 34 + .../risk_scoring/integration_update_params.py | 28 + .../integration_update_response.py | 34 + .../risk_scoring/integrations/__init__.py | 5 + .../integrations/reference_get_response.py | 34 + tests/api_resources/d1/test_database.py | 321 +++++++++ .../magic_transit/sites/test_acls.py | 174 ++++- .../magic_transit/sites/test_lans.py | 210 ++++++ .../magic_transit/sites/test_wans.py | 156 +++++ .../api_resources/magic_transit/test_sites.py | 132 +++- .../risk_scoring/integrations/__init__.py | 1 + .../integrations/test_references.py | 118 ++++ .../risk_scoring/test_integrations.py | 546 +++++++++++++++ 40 files changed, 3966 insertions(+), 10 deletions(-) create mode 100644 src/cloudflare/resources/zero_trust/risk_scoring/integrations/__init__.py create mode 100644 src/cloudflare/resources/zero_trust/risk_scoring/integrations/integrations.py create mode 100644 src/cloudflare/resources/zero_trust/risk_scoring/integrations/references.py create mode 100644 src/cloudflare/types/d1/database_delete_response.py create mode 100644 src/cloudflare/types/d1/database_query_params.py create mode 100644 src/cloudflare/types/d1/database_query_response.py create mode 100644 src/cloudflare/types/d1/query_result.py create mode 100644 src/cloudflare/types/magic_transit/site_edit_params.py create mode 100644 src/cloudflare/types/magic_transit/sites/acl_edit_params.py create mode 100644 src/cloudflare/types/magic_transit/sites/lan_edit_params.py create mode 100644 src/cloudflare/types/magic_transit/sites/wan_edit_params.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/integration_create_params.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/integration_create_response.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/integration_get_response.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/integration_list_response.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/integration_update_params.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/integration_update_response.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/integrations/__init__.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/integrations/reference_get_response.py create mode 100644 tests/api_resources/zero_trust/risk_scoring/integrations/__init__.py create mode 100644 tests/api_resources/zero_trust/risk_scoring/integrations/test_references.py create mode 100644 tests/api_resources/zero_trust/risk_scoring/test_integrations.py diff --git a/.stats.yml b/.stats.yml index be95bf8bbf8..0346a89ff96 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1283 +configured_endpoints: 1296 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-241f970730129e553d466806420a1cf2f6d665abec11667004cb9cf070932a1e.yml diff --git a/api.md b/api.md index 204b5af3418..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3873,6 +3873,7 @@ Methods: - client.magic_transit.sites.update(site_id, \*, account_id, \*\*params) -> Site - client.magic_transit.sites.list(\*, account_id, \*\*params) -> SyncSinglePage[Site] - client.magic_transit.sites.delete(site_id, \*, account_id) -> Site +- client.magic_transit.sites.edit(site_id, \*, account_id, \*\*params) -> Site - client.magic_transit.sites.get(site_id, \*, account_id) -> Site ### ACLs @@ -3889,6 +3890,7 @@ Methods: - client.magic_transit.sites.acls.update(acl_identifier, \*, account_id, site_id, \*\*params) -> ACL - client.magic_transit.sites.acls.list(site_id, \*, account_id) -> SyncSinglePage[ACL] - client.magic_transit.sites.acls.delete(acl_identifier, \*, account_id, site_id) -> ACL +- client.magic_transit.sites.acls.edit(acl_identifier, \*, account_id, site_id, \*\*params) -> ACL - client.magic_transit.sites.acls.get(acl_identifier, \*, account_id, site_id) -> ACL ### LANs @@ -3913,6 +3915,7 @@ Methods: - client.magic_transit.sites.lans.update(lan_id, \*, account_id, site_id, \*\*params) -> LAN - client.magic_transit.sites.lans.list(site_id, \*, account_id) -> SyncSinglePage[LAN] - client.magic_transit.sites.lans.delete(lan_id, \*, account_id, site_id) -> LAN +- client.magic_transit.sites.lans.edit(lan_id, \*, account_id, site_id, \*\*params) -> LAN - client.magic_transit.sites.lans.get(lan_id, \*, account_id, site_id) -> LAN ### WANs @@ -3929,6 +3932,7 @@ Methods: - client.magic_transit.sites.wans.update(wan_id, \*, account_id, site_id, \*\*params) -> WAN - client.magic_transit.sites.wans.list(site_id, \*, account_id) -> SyncSinglePage[WAN] - client.magic_transit.sites.wans.delete(wan_id, \*, account_id, site_id) -> WAN +- client.magic_transit.sites.wans.edit(wan_id, \*, account_id, site_id, \*\*params) -> WAN - client.magic_transit.sites.wans.get(wan_id, \*, account_id, site_id) -> WAN ## Connectors @@ -4601,13 +4605,22 @@ from cloudflare.types.d1 import D1 Types: ```python -from cloudflare.types.d1 import QueryResult, DatabaseCreateResponse, DatabaseListResponse +from cloudflare.types.d1 import ( + QueryResult, + DatabaseCreateResponse, + DatabaseListResponse, + DatabaseDeleteResponse, + DatabaseQueryResponse, +) ``` Methods: - client.d1.database.create(\*, account_id, \*\*params) -> DatabaseCreateResponse - client.d1.database.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[DatabaseListResponse] +- client.d1.database.delete(database_id, \*, account_id) -> DatabaseDeleteResponse +- client.d1.database.get(database_id, \*, account_id) -> D1 +- client.d1.database.query(database_id, \*, account_id, \*\*params) -> DatabaseQueryResponse # R2 @@ -5996,6 +6009,40 @@ Methods: - client.zero_trust.risk_scoring.summary.get(account_identifier, \*\*params) -> SummaryGetResponse +### Integrations + +Types: + +```python +from cloudflare.types.zero_trust.risk_scoring import ( + IntegrationCreateResponse, + IntegrationUpdateResponse, + IntegrationListResponse, + IntegrationDeleteResponse, + IntegrationGetResponse, +) +``` + +Methods: + +- client.zero_trust.risk_scoring.integrations.create(\*, account_id, \*\*params) -> Optional +- client.zero_trust.risk_scoring.integrations.update(integration_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.risk_scoring.integrations.list(\*, account_id) -> SyncSinglePage[IntegrationListResponse] +- client.zero_trust.risk_scoring.integrations.delete(integration_id, \*, account_id) -> object +- client.zero_trust.risk_scoring.integrations.get(integration_id, \*, account_id) -> Optional + +#### References + +Types: + +```python +from cloudflare.types.zero_trust.risk_scoring.integrations import ReferenceGetResponse +``` + +Methods: + +- client.zero_trust.risk_scoring.integrations.references.get(reference_id, \*, account_id) -> Optional + # Challenges ## Widgets diff --git a/src/cloudflare/resources/d1/database.py b/src/cloudflare/resources/d1/database.py index 9dcab589d15..1c557c2e71e 100644 --- a/src/cloudflare/resources/d1/database.py +++ b/src/cloudflare/resources/d1/database.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Any, List, Type, cast import httpx @@ -12,7 +12,7 @@ async_maybe_transform, ) from ..._compat import cached_property -from ...types.d1 import database_list_params, database_create_params +from ...types.d1 import database_list_params, database_query_params, database_create_params from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, @@ -22,12 +22,15 @@ ) from ..._wrappers import ResultWrapper from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ...types.d1.d1 import D1 from ..._base_client import ( AsyncPaginator, make_request_options, ) from ...types.d1.database_list_response import DatabaseListResponse +from ...types.d1.database_query_response import DatabaseQueryResponse from ...types.d1.database_create_response import DatabaseCreateResponse +from ...types.d1.database_delete_response import DatabaseDeleteResponse __all__ = ["DatabaseResource", "AsyncDatabaseResource"] @@ -138,6 +141,146 @@ def list( model=DatabaseListResponse, ) + def delete( + self, + database_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, + ) -> DatabaseDeleteResponse: + """ + Deletes the specified D1 database. + + Args: + account_id: Account identifier tag. + + 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 database_id: + raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") + return cast( + DatabaseDeleteResponse, + self._delete( + f"/accounts/{account_id}/d1/database/{database_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatabaseDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[DatabaseDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + def get( + self, + database_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, + ) -> D1: + """ + Returns the specified D1 database. + + Args: + account_id: Account identifier tag. + + 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 database_id: + raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") + return self._get( + f"/accounts/{account_id}/d1/database/{database_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[D1]._unwrapper, + ), + cast_to=cast(Type[D1], ResultWrapper[D1]), + ) + + def query( + self, + database_id: str, + *, + account_id: str, + sql: str, + params: List[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, + ) -> DatabaseQueryResponse: + """ + Returns the query result. + + Args: + account_id: Account identifier tag. + + 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 database_id: + raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") + return self._post( + f"/accounts/{account_id}/d1/database/{database_id}/query", + body=maybe_transform( + { + "sql": sql, + "params": params, + }, + database_query_params.DatabaseQueryParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatabaseQueryResponse]._unwrapper, + ), + cast_to=cast(Type[DatabaseQueryResponse], ResultWrapper[DatabaseQueryResponse]), + ) + class AsyncDatabaseResource(AsyncAPIResource): @cached_property @@ -245,6 +388,146 @@ def list( model=DatabaseListResponse, ) + async def delete( + self, + database_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, + ) -> DatabaseDeleteResponse: + """ + Deletes the specified D1 database. + + Args: + account_id: Account identifier tag. + + 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 database_id: + raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") + return cast( + DatabaseDeleteResponse, + await self._delete( + f"/accounts/{account_id}/d1/database/{database_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatabaseDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[DatabaseDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + async def get( + self, + database_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, + ) -> D1: + """ + Returns the specified D1 database. + + Args: + account_id: Account identifier tag. + + 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 database_id: + raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") + return await self._get( + f"/accounts/{account_id}/d1/database/{database_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[D1]._unwrapper, + ), + cast_to=cast(Type[D1], ResultWrapper[D1]), + ) + + async def query( + self, + database_id: str, + *, + account_id: str, + sql: str, + params: List[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, + ) -> DatabaseQueryResponse: + """ + Returns the query result. + + Args: + account_id: Account identifier tag. + + 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 database_id: + raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") + return await self._post( + f"/accounts/{account_id}/d1/database/{database_id}/query", + body=await async_maybe_transform( + { + "sql": sql, + "params": params, + }, + database_query_params.DatabaseQueryParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatabaseQueryResponse]._unwrapper, + ), + cast_to=cast(Type[DatabaseQueryResponse], ResultWrapper[DatabaseQueryResponse]), + ) + class DatabaseResourceWithRawResponse: def __init__(self, database: DatabaseResource) -> None: @@ -256,6 +539,15 @@ def __init__(self, database: DatabaseResource) -> None: self.list = to_raw_response_wrapper( database.list, ) + self.delete = to_raw_response_wrapper( + database.delete, + ) + self.get = to_raw_response_wrapper( + database.get, + ) + self.query = to_raw_response_wrapper( + database.query, + ) class AsyncDatabaseResourceWithRawResponse: @@ -268,6 +560,15 @@ def __init__(self, database: AsyncDatabaseResource) -> None: self.list = async_to_raw_response_wrapper( database.list, ) + self.delete = async_to_raw_response_wrapper( + database.delete, + ) + self.get = async_to_raw_response_wrapper( + database.get, + ) + self.query = async_to_raw_response_wrapper( + database.query, + ) class DatabaseResourceWithStreamingResponse: @@ -280,6 +581,15 @@ def __init__(self, database: DatabaseResource) -> None: self.list = to_streamed_response_wrapper( database.list, ) + self.delete = to_streamed_response_wrapper( + database.delete, + ) + self.get = to_streamed_response_wrapper( + database.get, + ) + self.query = to_streamed_response_wrapper( + database.query, + ) class AsyncDatabaseResourceWithStreamingResponse: @@ -292,3 +602,12 @@ def __init__(self, database: AsyncDatabaseResource) -> None: self.list = async_to_streamed_response_wrapper( database.list, ) + self.delete = async_to_streamed_response_wrapper( + database.delete, + ) + self.get = async_to_streamed_response_wrapper( + database.get, + ) + self.query = async_to_streamed_response_wrapper( + database.query, + ) diff --git a/src/cloudflare/resources/magic_transit/sites/acls.py b/src/cloudflare/resources/magic_transit/sites/acls.py index 4d850273bdf..6a4b41711fb 100644 --- a/src/cloudflare/resources/magic_transit/sites/acls.py +++ b/src/cloudflare/resources/magic_transit/sites/acls.py @@ -25,7 +25,7 @@ AsyncPaginator, make_request_options, ) -from ....types.magic_transit.sites import acl_create_params, acl_update_params +from ....types.magic_transit.sites import acl_edit_params, acl_create_params, acl_update_params from ....types.magic_transit.sites.acl import ACL from ....types.magic_transit.sites.allowed_protocol import AllowedProtocol from ....types.magic_transit.sites.acl_configuration_param import ACLConfigurationParam @@ -277,6 +277,81 @@ def delete( cast_to=cast(Type[ACL], ResultWrapper[ACL]), ) + def edit( + self, + acl_identifier: str, + *, + account_id: str, + site_id: str, + description: str | NotGiven = NOT_GIVEN, + forward_locally: bool | NotGiven = NOT_GIVEN, + lan_1: ACLConfigurationParam | NotGiven = NOT_GIVEN, + lan_2: ACLConfigurationParam | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + protocols: List[AllowedProtocol] | 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, + ) -> ACL: + """ + Patch a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_identifier: Identifier + + description: Description for the ACL. + + forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy + will forward traffic to Cloudflare. If set to "true", the policy will forward + traffic locally on the Magic WAN Connector. If not included in request, will + default to false. + + name: The name of the ACL. + + 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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_identifier: + raise ValueError(f"Expected a non-empty value for `acl_identifier` but received {acl_identifier!r}") + return self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier}", + body=maybe_transform( + { + "description": description, + "forward_locally": forward_locally, + "lan_1": lan_1, + "lan_2": lan_2, + "name": name, + "protocols": protocols, + }, + acl_edit_params.ACLEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + def get( self, acl_identifier: str, @@ -571,6 +646,81 @@ async def delete( cast_to=cast(Type[ACL], ResultWrapper[ACL]), ) + async def edit( + self, + acl_identifier: str, + *, + account_id: str, + site_id: str, + description: str | NotGiven = NOT_GIVEN, + forward_locally: bool | NotGiven = NOT_GIVEN, + lan_1: ACLConfigurationParam | NotGiven = NOT_GIVEN, + lan_2: ACLConfigurationParam | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + protocols: List[AllowedProtocol] | 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, + ) -> ACL: + """ + Patch a specific Site ACL. + + Args: + account_id: Identifier + + site_id: Identifier + + acl_identifier: Identifier + + description: Description for the ACL. + + forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy + will forward traffic to Cloudflare. If set to "true", the policy will forward + traffic locally on the Magic WAN Connector. If not included in request, will + default to false. + + name: The name of the ACL. + + 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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not acl_identifier: + raise ValueError(f"Expected a non-empty value for `acl_identifier` but received {acl_identifier!r}") + return await self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier}", + body=await async_maybe_transform( + { + "description": description, + "forward_locally": forward_locally, + "lan_1": lan_1, + "lan_2": lan_2, + "name": name, + "protocols": protocols, + }, + acl_edit_params.ACLEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ACL]._unwrapper, + ), + cast_to=cast(Type[ACL], ResultWrapper[ACL]), + ) + async def get( self, acl_identifier: str, @@ -637,6 +787,9 @@ def __init__(self, acls: ACLsResource) -> None: self.delete = to_raw_response_wrapper( acls.delete, ) + self.edit = to_raw_response_wrapper( + acls.edit, + ) self.get = to_raw_response_wrapper( acls.get, ) @@ -658,6 +811,9 @@ def __init__(self, acls: AsyncACLsResource) -> None: self.delete = async_to_raw_response_wrapper( acls.delete, ) + self.edit = async_to_raw_response_wrapper( + acls.edit, + ) self.get = async_to_raw_response_wrapper( acls.get, ) @@ -679,6 +835,9 @@ def __init__(self, acls: ACLsResource) -> None: self.delete = to_streamed_response_wrapper( acls.delete, ) + self.edit = to_streamed_response_wrapper( + acls.edit, + ) self.get = to_streamed_response_wrapper( acls.get, ) @@ -700,6 +859,9 @@ def __init__(self, acls: AsyncACLsResource) -> None: self.delete = async_to_streamed_response_wrapper( acls.delete, ) + self.edit = async_to_streamed_response_wrapper( + acls.edit, + ) self.get = async_to_streamed_response_wrapper( acls.get, ) diff --git a/src/cloudflare/resources/magic_transit/sites/lans.py b/src/cloudflare/resources/magic_transit/sites/lans.py index cdb2d94456a..0bba7a450df 100644 --- a/src/cloudflare/resources/magic_transit/sites/lans.py +++ b/src/cloudflare/resources/magic_transit/sites/lans.py @@ -25,7 +25,11 @@ AsyncPaginator, make_request_options, ) -from ....types.magic_transit.sites import lan_create_params, lan_update_params +from ....types.magic_transit.sites import ( + lan_edit_params, + lan_create_params, + lan_update_params, +) from ....types.magic_transit.sites.lan import LAN from ....types.magic_transit.sites.nat_param import NatParam from ....types.magic_transit.sites.lan_create_response import LANCreateResponse @@ -280,6 +284,78 @@ def delete( cast_to=cast(Type[LAN], ResultWrapper[LAN]), ) + def edit( + self, + lan_id: str, + *, + account_id: str, + site_id: str, + name: str | NotGiven = NOT_GIVEN, + nat: NatParam | NotGiven = NOT_GIVEN, + physport: int | NotGiven = NOT_GIVEN, + routed_subnets: Iterable[RoutedSubnetParam] | NotGiven = NOT_GIVEN, + static_addressing: LANStaticAddressingParam | NotGiven = NOT_GIVEN, + vlan_tag: int | 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, + ) -> LAN: + """ + Patch a specific LAN. + + Args: + account_id: Identifier + + site_id: Identifier + + lan_id: Identifier + + static_addressing: If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + + vlan_tag: VLAN port number. + + 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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not lan_id: + raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") + return self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + body=maybe_transform( + { + "name": name, + "nat": nat, + "physport": physport, + "routed_subnets": routed_subnets, + "static_addressing": static_addressing, + "vlan_tag": vlan_tag, + }, + lan_edit_params.LANEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LAN]._unwrapper, + ), + cast_to=cast(Type[LAN], ResultWrapper[LAN]), + ) + def get( self, lan_id: str, @@ -575,6 +651,78 @@ async def delete( cast_to=cast(Type[LAN], ResultWrapper[LAN]), ) + async def edit( + self, + lan_id: str, + *, + account_id: str, + site_id: str, + name: str | NotGiven = NOT_GIVEN, + nat: NatParam | NotGiven = NOT_GIVEN, + physport: int | NotGiven = NOT_GIVEN, + routed_subnets: Iterable[RoutedSubnetParam] | NotGiven = NOT_GIVEN, + static_addressing: LANStaticAddressingParam | NotGiven = NOT_GIVEN, + vlan_tag: int | 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, + ) -> LAN: + """ + Patch a specific LAN. + + Args: + account_id: Identifier + + site_id: Identifier + + lan_id: Identifier + + static_addressing: If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + + vlan_tag: VLAN port number. + + 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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not lan_id: + raise ValueError(f"Expected a non-empty value for `lan_id` but received {lan_id!r}") + return await self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}", + body=await async_maybe_transform( + { + "name": name, + "nat": nat, + "physport": physport, + "routed_subnets": routed_subnets, + "static_addressing": static_addressing, + "vlan_tag": vlan_tag, + }, + lan_edit_params.LANEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[LAN]._unwrapper, + ), + cast_to=cast(Type[LAN], ResultWrapper[LAN]), + ) + async def get( self, lan_id: str, @@ -641,6 +789,9 @@ def __init__(self, lans: LANsResource) -> None: self.delete = to_raw_response_wrapper( lans.delete, ) + self.edit = to_raw_response_wrapper( + lans.edit, + ) self.get = to_raw_response_wrapper( lans.get, ) @@ -662,6 +813,9 @@ def __init__(self, lans: AsyncLANsResource) -> None: self.delete = async_to_raw_response_wrapper( lans.delete, ) + self.edit = async_to_raw_response_wrapper( + lans.edit, + ) self.get = async_to_raw_response_wrapper( lans.get, ) @@ -683,6 +837,9 @@ def __init__(self, lans: LANsResource) -> None: self.delete = to_streamed_response_wrapper( lans.delete, ) + self.edit = to_streamed_response_wrapper( + lans.edit, + ) self.get = to_streamed_response_wrapper( lans.get, ) @@ -704,6 +861,9 @@ def __init__(self, lans: AsyncLANsResource) -> None: self.delete = async_to_streamed_response_wrapper( lans.delete, ) + self.edit = async_to_streamed_response_wrapper( + lans.edit, + ) self.get = async_to_streamed_response_wrapper( lans.get, ) diff --git a/src/cloudflare/resources/magic_transit/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites.py index b36d0ef691e..6dd3b97bf65 100644 --- a/src/cloudflare/resources/magic_transit/sites/sites.py +++ b/src/cloudflare/resources/magic_transit/sites/sites.py @@ -49,7 +49,12 @@ AsyncPaginator, make_request_options, ) -from ....types.magic_transit import site_list_params, site_create_params, site_update_params +from ....types.magic_transit import ( + site_edit_params, + site_list_params, + site_create_params, + site_update_params, +) from ....types.magic_transit.site import Site from ....types.magic_transit.site_location_param import SiteLocationParam @@ -301,6 +306,73 @@ def delete( cast_to=cast(Type[Site], ResultWrapper[Site]), ) + def edit( + self, + site_id: str, + *, + account_id: str, + connector_id: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + location: SiteLocationParam | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + secondary_connector_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Site: + """ + Patch a specific Site. + + Args: + account_id: Identifier + + site_id: Identifier + + connector_id: Magic WAN Connector identifier tag. + + location: Location of site in latitude and longitude. + + name: The name of the site. + + secondary_connector_id: Magic WAN Connector identifier tag. Used when high availability mode is on. + + 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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}", + body=maybe_transform( + { + "connector_id": connector_id, + "description": description, + "location": location, + "name": name, + "secondary_connector_id": secondary_connector_id, + }, + site_edit_params.SiteEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Site]._unwrapper, + ), + cast_to=cast(Type[Site], ResultWrapper[Site]), + ) + def get( self, site_id: str, @@ -591,6 +663,73 @@ async def delete( cast_to=cast(Type[Site], ResultWrapper[Site]), ) + async def edit( + self, + site_id: str, + *, + account_id: str, + connector_id: str | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + location: SiteLocationParam | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + secondary_connector_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Site: + """ + Patch a specific Site. + + Args: + account_id: Identifier + + site_id: Identifier + + connector_id: Magic WAN Connector identifier tag. + + location: Location of site in latitude and longitude. + + name: The name of the site. + + secondary_connector_id: Magic WAN Connector identifier tag. Used when high availability mode is on. + + 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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}", + body=await async_maybe_transform( + { + "connector_id": connector_id, + "description": description, + "location": location, + "name": name, + "secondary_connector_id": secondary_connector_id, + }, + site_edit_params.SiteEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Site]._unwrapper, + ), + cast_to=cast(Type[Site], ResultWrapper[Site]), + ) + async def get( self, site_id: str, @@ -652,6 +791,9 @@ def __init__(self, sites: SitesResource) -> None: self.delete = to_raw_response_wrapper( sites.delete, ) + self.edit = to_raw_response_wrapper( + sites.edit, + ) self.get = to_raw_response_wrapper( sites.get, ) @@ -685,6 +827,9 @@ def __init__(self, sites: AsyncSitesResource) -> None: self.delete = async_to_raw_response_wrapper( sites.delete, ) + self.edit = async_to_raw_response_wrapper( + sites.edit, + ) self.get = async_to_raw_response_wrapper( sites.get, ) @@ -718,6 +863,9 @@ def __init__(self, sites: SitesResource) -> None: self.delete = to_streamed_response_wrapper( sites.delete, ) + self.edit = to_streamed_response_wrapper( + sites.edit, + ) self.get = to_streamed_response_wrapper( sites.get, ) @@ -751,6 +899,9 @@ def __init__(self, sites: AsyncSitesResource) -> None: self.delete = async_to_streamed_response_wrapper( sites.delete, ) + self.edit = async_to_streamed_response_wrapper( + sites.edit, + ) self.get = async_to_streamed_response_wrapper( sites.get, ) diff --git a/src/cloudflare/resources/magic_transit/sites/wans.py b/src/cloudflare/resources/magic_transit/sites/wans.py index c41c8985728..f11fa4ee520 100644 --- a/src/cloudflare/resources/magic_transit/sites/wans.py +++ b/src/cloudflare/resources/magic_transit/sites/wans.py @@ -25,7 +25,7 @@ AsyncPaginator, make_request_options, ) -from ....types.magic_transit.sites import wan_create_params, wan_update_params +from ....types.magic_transit.sites import wan_edit_params, wan_create_params, wan_update_params from ....types.magic_transit.sites.wan import WAN from ....types.magic_transit.sites.wan_create_response import WANCreateResponse from ....types.magic_transit.sites.wan_static_addressing_param import WANStaticAddressingParam @@ -265,6 +265,75 @@ def delete( cast_to=cast(Type[WAN], ResultWrapper[WAN]), ) + def edit( + self, + wan_id: str, + *, + account_id: str, + site_id: str, + name: str | NotGiven = NOT_GIVEN, + physport: int | NotGiven = NOT_GIVEN, + priority: int | NotGiven = NOT_GIVEN, + static_addressing: WANStaticAddressingParam | NotGiven = NOT_GIVEN, + vlan_tag: int | 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, + ) -> WAN: + """ + Patch a specific WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + wan_id: Identifier + + static_addressing: (optional) if omitted, use DHCP. Submit secondary_address when site is in high + availability mode. + + vlan_tag: VLAN port number. + + 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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not wan_id: + raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") + return self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + body=maybe_transform( + { + "name": name, + "physport": physport, + "priority": priority, + "static_addressing": static_addressing, + "vlan_tag": vlan_tag, + }, + wan_edit_params.WANEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[WAN]._unwrapper, + ), + cast_to=cast(Type[WAN], ResultWrapper[WAN]), + ) + def get( self, wan_id: str, @@ -547,6 +616,75 @@ async def delete( cast_to=cast(Type[WAN], ResultWrapper[WAN]), ) + async def edit( + self, + wan_id: str, + *, + account_id: str, + site_id: str, + name: str | NotGiven = NOT_GIVEN, + physport: int | NotGiven = NOT_GIVEN, + priority: int | NotGiven = NOT_GIVEN, + static_addressing: WANStaticAddressingParam | NotGiven = NOT_GIVEN, + vlan_tag: int | 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, + ) -> WAN: + """ + Patch a specific WAN. + + Args: + account_id: Identifier + + site_id: Identifier + + wan_id: Identifier + + static_addressing: (optional) if omitted, use DHCP. Submit secondary_address when site is in high + availability mode. + + vlan_tag: VLAN port number. + + 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 site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not wan_id: + raise ValueError(f"Expected a non-empty value for `wan_id` but received {wan_id!r}") + return await self._patch( + f"/accounts/{account_id}/magic/sites/{site_id}/wans/{wan_id}", + body=await async_maybe_transform( + { + "name": name, + "physport": physport, + "priority": priority, + "static_addressing": static_addressing, + "vlan_tag": vlan_tag, + }, + wan_edit_params.WANEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[WAN]._unwrapper, + ), + cast_to=cast(Type[WAN], ResultWrapper[WAN]), + ) + async def get( self, wan_id: str, @@ -613,6 +751,9 @@ def __init__(self, wans: WANsResource) -> None: self.delete = to_raw_response_wrapper( wans.delete, ) + self.edit = to_raw_response_wrapper( + wans.edit, + ) self.get = to_raw_response_wrapper( wans.get, ) @@ -634,6 +775,9 @@ def __init__(self, wans: AsyncWANsResource) -> None: self.delete = async_to_raw_response_wrapper( wans.delete, ) + self.edit = async_to_raw_response_wrapper( + wans.edit, + ) self.get = async_to_raw_response_wrapper( wans.get, ) @@ -655,6 +799,9 @@ def __init__(self, wans: WANsResource) -> None: self.delete = to_streamed_response_wrapper( wans.delete, ) + self.edit = to_streamed_response_wrapper( + wans.edit, + ) self.get = to_streamed_response_wrapper( wans.get, ) @@ -676,6 +823,9 @@ def __init__(self, wans: AsyncWANsResource) -> None: self.delete = async_to_streamed_response_wrapper( wans.delete, ) + self.edit = async_to_streamed_response_wrapper( + wans.edit, + ) self.get = async_to_streamed_response_wrapper( wans.get, ) diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/__init__.py b/src/cloudflare/resources/zero_trust/risk_scoring/__init__.py index 786697e73dd..444ef4d0a98 100644 --- a/src/cloudflare/resources/zero_trust/risk_scoring/__init__.py +++ b/src/cloudflare/resources/zero_trust/risk_scoring/__init__.py @@ -16,6 +16,14 @@ BehavioursResourceWithStreamingResponse, AsyncBehavioursResourceWithStreamingResponse, ) +from .integrations import ( + IntegrationsResource, + AsyncIntegrationsResource, + IntegrationsResourceWithRawResponse, + AsyncIntegrationsResourceWithRawResponse, + IntegrationsResourceWithStreamingResponse, + AsyncIntegrationsResourceWithStreamingResponse, +) from .risk_scoring import ( RiskScoringResource, AsyncRiskScoringResource, @@ -38,6 +46,12 @@ "AsyncSummaryResourceWithRawResponse", "SummaryResourceWithStreamingResponse", "AsyncSummaryResourceWithStreamingResponse", + "IntegrationsResource", + "AsyncIntegrationsResource", + "IntegrationsResourceWithRawResponse", + "AsyncIntegrationsResourceWithRawResponse", + "IntegrationsResourceWithStreamingResponse", + "AsyncIntegrationsResourceWithStreamingResponse", "RiskScoringResource", "AsyncRiskScoringResource", "RiskScoringResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/integrations/__init__.py b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/__init__.py new file mode 100644 index 00000000000..8de5cdc289c --- /dev/null +++ b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .references import ( + ReferencesResource, + AsyncReferencesResource, + ReferencesResourceWithRawResponse, + AsyncReferencesResourceWithRawResponse, + ReferencesResourceWithStreamingResponse, + AsyncReferencesResourceWithStreamingResponse, +) +from .integrations import ( + IntegrationsResource, + AsyncIntegrationsResource, + IntegrationsResourceWithRawResponse, + AsyncIntegrationsResourceWithRawResponse, + IntegrationsResourceWithStreamingResponse, + AsyncIntegrationsResourceWithStreamingResponse, +) + +__all__ = [ + "ReferencesResource", + "AsyncReferencesResource", + "ReferencesResourceWithRawResponse", + "AsyncReferencesResourceWithRawResponse", + "ReferencesResourceWithStreamingResponse", + "AsyncReferencesResourceWithStreamingResponse", + "IntegrationsResource", + "AsyncIntegrationsResource", + "IntegrationsResourceWithRawResponse", + "AsyncIntegrationsResourceWithRawResponse", + "IntegrationsResourceWithStreamingResponse", + "AsyncIntegrationsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/integrations/integrations.py b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/integrations.py new file mode 100644 index 00000000000..093cacc5ea2 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/integrations.py @@ -0,0 +1,631 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast +from typing_extensions import Literal + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) +from .references import ( + ReferencesResource, + AsyncReferencesResource, + ReferencesResourceWithRawResponse, + AsyncReferencesResourceWithRawResponse, + ReferencesResourceWithStreamingResponse, + AsyncReferencesResourceWithStreamingResponse, +) +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.risk_scoring import integration_create_params, integration_update_params +from .....types.zero_trust.risk_scoring.integration_get_response import IntegrationGetResponse +from .....types.zero_trust.risk_scoring.integration_list_response import IntegrationListResponse +from .....types.zero_trust.risk_scoring.integration_create_response import IntegrationCreateResponse +from .....types.zero_trust.risk_scoring.integration_update_response import IntegrationUpdateResponse + +__all__ = ["IntegrationsResource", "AsyncIntegrationsResource"] + + +class IntegrationsResource(SyncAPIResource): + @cached_property + def references(self) -> ReferencesResource: + return ReferencesResource(self._client) + + @cached_property + def with_raw_response(self) -> IntegrationsResourceWithRawResponse: + return IntegrationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IntegrationsResourceWithStreamingResponse: + return IntegrationsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + integration_type: Literal["Okta"], + tenant_url: str, + reference_id: Optional[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[IntegrationCreateResponse]: + """ + Create new risk score integration. + + Args: + tenant_url: The base url of the tenant, e.g. "https://tenant.okta.com" + + reference_id: A reference id that can be supplied by the client. Currently this should be set + to the Access-Okta IDP ID (a UUIDv4). + https://developers.cloudflare.com/api/operations/access-identity-providers-get-an-access-identity-provider + + 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}/zt_risk_scoring/integrations", + body=maybe_transform( + { + "integration_type": integration_type, + "tenant_url": tenant_url, + "reference_id": reference_id, + }, + integration_create_params.IntegrationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IntegrationCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IntegrationCreateResponse]], ResultWrapper[IntegrationCreateResponse]), + ) + + def update( + self, + integration_id: str, + *, + account_id: str, + active: bool, + tenant_url: str, + reference_id: Optional[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[IntegrationUpdateResponse]: + """ + Update a risk score integration. + + Overwrite the reference_id, tenant_url, and active values with the ones provided + + Args: + active: Whether this integration is enabled. If disabled, no risk changes will be + exported to the third-party. + + tenant_url: The base url of the tenant, e.g. "https://tenant.okta.com" + + reference_id: A reference id that can be supplied by the client. Currently this should be set + to the Access-Okta IDP ID (a UUIDv4). + https://developers.cloudflare.com/api/operations/access-identity-providers-get-an-access-identity-provider + + 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 integration_id: + raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") + return self._put( + f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + body=maybe_transform( + { + "active": active, + "tenant_url": tenant_url, + "reference_id": reference_id, + }, + integration_update_params.IntegrationUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IntegrationUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IntegrationUpdateResponse]], ResultWrapper[IntegrationUpdateResponse]), + ) + + 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[IntegrationListResponse]: + """ + List all risk score integrations for the 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}/zt_risk_scoring/integrations", + page=SyncSinglePage[IntegrationListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=IntegrationListResponse, + ) + + def delete( + self, + integration_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, + ) -> object: + """ + Delete a risk score integration. + + 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}") + if not integration_id: + raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") + return self._delete( + f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), + ) + + def get( + self, + integration_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[IntegrationGetResponse]: + """ + Get risk score integration by id. + + 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}") + if not integration_id: + raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") + return self._get( + f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IntegrationGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IntegrationGetResponse]], ResultWrapper[IntegrationGetResponse]), + ) + + +class AsyncIntegrationsResource(AsyncAPIResource): + @cached_property + def references(self) -> AsyncReferencesResource: + return AsyncReferencesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncIntegrationsResourceWithRawResponse: + return AsyncIntegrationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIntegrationsResourceWithStreamingResponse: + return AsyncIntegrationsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + integration_type: Literal["Okta"], + tenant_url: str, + reference_id: Optional[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[IntegrationCreateResponse]: + """ + Create new risk score integration. + + Args: + tenant_url: The base url of the tenant, e.g. "https://tenant.okta.com" + + reference_id: A reference id that can be supplied by the client. Currently this should be set + to the Access-Okta IDP ID (a UUIDv4). + https://developers.cloudflare.com/api/operations/access-identity-providers-get-an-access-identity-provider + + 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}/zt_risk_scoring/integrations", + body=await async_maybe_transform( + { + "integration_type": integration_type, + "tenant_url": tenant_url, + "reference_id": reference_id, + }, + integration_create_params.IntegrationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IntegrationCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IntegrationCreateResponse]], ResultWrapper[IntegrationCreateResponse]), + ) + + async def update( + self, + integration_id: str, + *, + account_id: str, + active: bool, + tenant_url: str, + reference_id: Optional[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[IntegrationUpdateResponse]: + """ + Update a risk score integration. + + Overwrite the reference_id, tenant_url, and active values with the ones provided + + Args: + active: Whether this integration is enabled. If disabled, no risk changes will be + exported to the third-party. + + tenant_url: The base url of the tenant, e.g. "https://tenant.okta.com" + + reference_id: A reference id that can be supplied by the client. Currently this should be set + to the Access-Okta IDP ID (a UUIDv4). + https://developers.cloudflare.com/api/operations/access-identity-providers-get-an-access-identity-provider + + 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 integration_id: + raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") + return await self._put( + f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + body=await async_maybe_transform( + { + "active": active, + "tenant_url": tenant_url, + "reference_id": reference_id, + }, + integration_update_params.IntegrationUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IntegrationUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IntegrationUpdateResponse]], ResultWrapper[IntegrationUpdateResponse]), + ) + + 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[IntegrationListResponse, AsyncSinglePage[IntegrationListResponse]]: + """ + List all risk score integrations for the 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}/zt_risk_scoring/integrations", + page=AsyncSinglePage[IntegrationListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=IntegrationListResponse, + ) + + async def delete( + self, + integration_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, + ) -> object: + """ + Delete a risk score integration. + + 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}") + if not integration_id: + raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") + return await self._delete( + f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), + ) + + async def get( + self, + integration_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[IntegrationGetResponse]: + """ + Get risk score integration by id. + + 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}") + if not integration_id: + raise ValueError(f"Expected a non-empty value for `integration_id` but received {integration_id!r}") + return await self._get( + f"/accounts/{account_id}/zt_risk_scoring/integrations/{integration_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IntegrationGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IntegrationGetResponse]], ResultWrapper[IntegrationGetResponse]), + ) + + +class IntegrationsResourceWithRawResponse: + def __init__(self, integrations: IntegrationsResource) -> None: + self._integrations = integrations + + self.create = to_raw_response_wrapper( + integrations.create, + ) + self.update = to_raw_response_wrapper( + integrations.update, + ) + self.list = to_raw_response_wrapper( + integrations.list, + ) + self.delete = to_raw_response_wrapper( + integrations.delete, + ) + self.get = to_raw_response_wrapper( + integrations.get, + ) + + @cached_property + def references(self) -> ReferencesResourceWithRawResponse: + return ReferencesResourceWithRawResponse(self._integrations.references) + + +class AsyncIntegrationsResourceWithRawResponse: + def __init__(self, integrations: AsyncIntegrationsResource) -> None: + self._integrations = integrations + + self.create = async_to_raw_response_wrapper( + integrations.create, + ) + self.update = async_to_raw_response_wrapper( + integrations.update, + ) + self.list = async_to_raw_response_wrapper( + integrations.list, + ) + self.delete = async_to_raw_response_wrapper( + integrations.delete, + ) + self.get = async_to_raw_response_wrapper( + integrations.get, + ) + + @cached_property + def references(self) -> AsyncReferencesResourceWithRawResponse: + return AsyncReferencesResourceWithRawResponse(self._integrations.references) + + +class IntegrationsResourceWithStreamingResponse: + def __init__(self, integrations: IntegrationsResource) -> None: + self._integrations = integrations + + self.create = to_streamed_response_wrapper( + integrations.create, + ) + self.update = to_streamed_response_wrapper( + integrations.update, + ) + self.list = to_streamed_response_wrapper( + integrations.list, + ) + self.delete = to_streamed_response_wrapper( + integrations.delete, + ) + self.get = to_streamed_response_wrapper( + integrations.get, + ) + + @cached_property + def references(self) -> ReferencesResourceWithStreamingResponse: + return ReferencesResourceWithStreamingResponse(self._integrations.references) + + +class AsyncIntegrationsResourceWithStreamingResponse: + def __init__(self, integrations: AsyncIntegrationsResource) -> None: + self._integrations = integrations + + self.create = async_to_streamed_response_wrapper( + integrations.create, + ) + self.update = async_to_streamed_response_wrapper( + integrations.update, + ) + self.list = async_to_streamed_response_wrapper( + integrations.list, + ) + self.delete = async_to_streamed_response_wrapper( + integrations.delete, + ) + self.get = async_to_streamed_response_wrapper( + integrations.get, + ) + + @cached_property + def references(self) -> AsyncReferencesResourceWithStreamingResponse: + return AsyncReferencesResourceWithStreamingResponse(self._integrations.references) diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/integrations/references.py b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/references.py new file mode 100644 index 00000000000..604fb052a84 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/risk_scoring/integrations/references.py @@ -0,0 +1,160 @@ +# 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.risk_scoring.integrations.reference_get_response import ReferenceGetResponse + +__all__ = ["ReferencesResource", "AsyncReferencesResource"] + + +class ReferencesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ReferencesResourceWithRawResponse: + return ReferencesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ReferencesResourceWithStreamingResponse: + return ReferencesResourceWithStreamingResponse(self) + + def get( + self, + reference_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[ReferenceGetResponse]: + """ + Get risk score integration by reference id. + + 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}") + if not reference_id: + raise ValueError(f"Expected a non-empty value for `reference_id` but received {reference_id!r}") + return self._get( + f"/accounts/{account_id}/zt_risk_scoring/integrations/reference_id/{reference_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ReferenceGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ReferenceGetResponse]], ResultWrapper[ReferenceGetResponse]), + ) + + +class AsyncReferencesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncReferencesResourceWithRawResponse: + return AsyncReferencesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncReferencesResourceWithStreamingResponse: + return AsyncReferencesResourceWithStreamingResponse(self) + + async def get( + self, + reference_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[ReferenceGetResponse]: + """ + Get risk score integration by reference id. + + 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}") + if not reference_id: + raise ValueError(f"Expected a non-empty value for `reference_id` but received {reference_id!r}") + return await self._get( + f"/accounts/{account_id}/zt_risk_scoring/integrations/reference_id/{reference_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ReferenceGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ReferenceGetResponse]], ResultWrapper[ReferenceGetResponse]), + ) + + +class ReferencesResourceWithRawResponse: + def __init__(self, references: ReferencesResource) -> None: + self._references = references + + self.get = to_raw_response_wrapper( + references.get, + ) + + +class AsyncReferencesResourceWithRawResponse: + def __init__(self, references: AsyncReferencesResource) -> None: + self._references = references + + self.get = async_to_raw_response_wrapper( + references.get, + ) + + +class ReferencesResourceWithStreamingResponse: + def __init__(self, references: ReferencesResource) -> None: + self._references = references + + self.get = to_streamed_response_wrapper( + references.get, + ) + + +class AsyncReferencesResourceWithStreamingResponse: + def __init__(self, references: AsyncReferencesResource) -> None: + self._references = references + + self.get = async_to_streamed_response_wrapper( + references.get, + ) diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py b/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py index fcf0c234dca..653f23f6bf0 100644 --- a/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py +++ b/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py @@ -37,10 +37,19 @@ async_to_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper +from .integrations import ( + IntegrationsResource, + AsyncIntegrationsResource, + IntegrationsResourceWithRawResponse, + AsyncIntegrationsResourceWithRawResponse, + IntegrationsResourceWithStreamingResponse, + AsyncIntegrationsResourceWithStreamingResponse, +) from ...._base_client import ( make_request_options, ) from ....types.zero_trust import risk_scoring_get_params +from .integrations.integrations import IntegrationsResource, AsyncIntegrationsResource from ....types.zero_trust.risk_scoring_get_response import RiskScoringGetResponse from ....types.zero_trust.risk_scoring_reset_response import RiskScoringResetResponse @@ -56,6 +65,10 @@ def behaviours(self) -> BehavioursResource: def summary(self) -> SummaryResource: return SummaryResource(self._client) + @cached_property + def integrations(self) -> IntegrationsResource: + return IntegrationsResource(self._client) + @cached_property def with_raw_response(self) -> RiskScoringResourceWithRawResponse: return RiskScoringResourceWithRawResponse(self) @@ -180,6 +193,10 @@ def behaviours(self) -> AsyncBehavioursResource: def summary(self) -> AsyncSummaryResource: return AsyncSummaryResource(self._client) + @cached_property + def integrations(self) -> AsyncIntegrationsResource: + return AsyncIntegrationsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncRiskScoringResourceWithRawResponse: return AsyncRiskScoringResourceWithRawResponse(self) @@ -314,6 +331,10 @@ def behaviours(self) -> BehavioursResourceWithRawResponse: def summary(self) -> SummaryResourceWithRawResponse: return SummaryResourceWithRawResponse(self._risk_scoring.summary) + @cached_property + def integrations(self) -> IntegrationsResourceWithRawResponse: + return IntegrationsResourceWithRawResponse(self._risk_scoring.integrations) + class AsyncRiskScoringResourceWithRawResponse: def __init__(self, risk_scoring: AsyncRiskScoringResource) -> None: @@ -334,6 +355,10 @@ def behaviours(self) -> AsyncBehavioursResourceWithRawResponse: def summary(self) -> AsyncSummaryResourceWithRawResponse: return AsyncSummaryResourceWithRawResponse(self._risk_scoring.summary) + @cached_property + def integrations(self) -> AsyncIntegrationsResourceWithRawResponse: + return AsyncIntegrationsResourceWithRawResponse(self._risk_scoring.integrations) + class RiskScoringResourceWithStreamingResponse: def __init__(self, risk_scoring: RiskScoringResource) -> None: @@ -354,6 +379,10 @@ def behaviours(self) -> BehavioursResourceWithStreamingResponse: def summary(self) -> SummaryResourceWithStreamingResponse: return SummaryResourceWithStreamingResponse(self._risk_scoring.summary) + @cached_property + def integrations(self) -> IntegrationsResourceWithStreamingResponse: + return IntegrationsResourceWithStreamingResponse(self._risk_scoring.integrations) + class AsyncRiskScoringResourceWithStreamingResponse: def __init__(self, risk_scoring: AsyncRiskScoringResource) -> None: @@ -373,3 +402,7 @@ def behaviours(self) -> AsyncBehavioursResourceWithStreamingResponse: @cached_property def summary(self) -> AsyncSummaryResourceWithStreamingResponse: return AsyncSummaryResourceWithStreamingResponse(self._risk_scoring.summary) + + @cached_property + def integrations(self) -> AsyncIntegrationsResourceWithStreamingResponse: + return AsyncIntegrationsResourceWithStreamingResponse(self._risk_scoring.integrations) diff --git a/src/cloudflare/types/d1/__init__.py b/src/cloudflare/types/d1/__init__.py index e46c7ede08c..2c77c7a96e5 100644 --- a/src/cloudflare/types/d1/__init__.py +++ b/src/cloudflare/types/d1/__init__.py @@ -3,7 +3,11 @@ from __future__ import annotations from .d1 import D1 as D1 +from .query_result import QueryResult as QueryResult from .database_list_params import DatabaseListParams as DatabaseListParams +from .database_query_params import DatabaseQueryParams as DatabaseQueryParams from .database_create_params import DatabaseCreateParams as DatabaseCreateParams from .database_list_response import DatabaseListResponse as DatabaseListResponse +from .database_query_response import DatabaseQueryResponse as DatabaseQueryResponse from .database_create_response import DatabaseCreateResponse as DatabaseCreateResponse +from .database_delete_response import DatabaseDeleteResponse as DatabaseDeleteResponse diff --git a/src/cloudflare/types/d1/database_delete_response.py b/src/cloudflare/types/d1/database_delete_response.py new file mode 100644 index 00000000000..53e10cdd237 --- /dev/null +++ b/src/cloudflare/types/d1/database_delete_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +__all__ = ["DatabaseDeleteResponse"] + +DatabaseDeleteResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/d1/database_query_params.py b/src/cloudflare/types/d1/database_query_params.py new file mode 100644 index 00000000000..5c33fb076cb --- /dev/null +++ b/src/cloudflare/types/d1/database_query_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, TypedDict + +__all__ = ["DatabaseQueryParams"] + + +class DatabaseQueryParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + sql: Required[str] + + params: List[str] diff --git a/src/cloudflare/types/d1/database_query_response.py b/src/cloudflare/types/d1/database_query_response.py new file mode 100644 index 00000000000..4e2d7a949cd --- /dev/null +++ b/src/cloudflare/types/d1/database_query_response.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .query_result import QueryResult + +__all__ = ["DatabaseQueryResponse"] + +DatabaseQueryResponse = List[QueryResult] diff --git a/src/cloudflare/types/d1/query_result.py b/src/cloudflare/types/d1/query_result.py new file mode 100644 index 00000000000..7b6447cd084 --- /dev/null +++ b/src/cloudflare/types/d1/query_result.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["QueryResult", "Meta"] + + +class Meta(BaseModel): + changed_db: Optional[bool] = None + + changes: Optional[float] = None + + duration: Optional[float] = None + + last_row_id: Optional[float] = None + + rows_read: Optional[float] = None + + rows_written: Optional[float] = None + + size_after: Optional[float] = None + + +class QueryResult(BaseModel): + meta: Optional[Meta] = None + + results: Optional[List[object]] = None + + success: Optional[bool] = None diff --git a/src/cloudflare/types/magic_transit/__init__.py b/src/cloudflare/types/magic_transit/__init__.py index 1ef7d35b957..298acb27b50 100644 --- a/src/cloudflare/types/magic_transit/__init__.py +++ b/src/cloudflare/types/magic_transit/__init__.py @@ -8,6 +8,7 @@ from .health_check import HealthCheck as HealthCheck from .psk_metadata import PSKMetadata as PSKMetadata from .site_location import SiteLocation as SiteLocation +from .site_edit_params import SiteEditParams as SiteEditParams from .site_list_params import SiteListParams as SiteListParams from .health_check_rate import HealthCheckRate as HealthCheckRate from .health_check_type import HealthCheckType as HealthCheckType diff --git a/src/cloudflare/types/magic_transit/site_edit_params.py b/src/cloudflare/types/magic_transit/site_edit_params.py new file mode 100644 index 00000000000..606d7e66c55 --- /dev/null +++ b/src/cloudflare/types/magic_transit/site_edit_params.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .site_location_param import SiteLocationParam + +__all__ = ["SiteEditParams"] + + +class SiteEditParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + connector_id: str + """Magic WAN Connector identifier tag.""" + + description: str + + location: SiteLocationParam + """Location of site in latitude and longitude.""" + + name: str + """The name of the site.""" + + secondary_connector_id: str + """Magic WAN Connector identifier tag. Used when high availability mode is on.""" diff --git a/src/cloudflare/types/magic_transit/sites/__init__.py b/src/cloudflare/types/magic_transit/sites/__init__.py index 5f61827b3cb..38f592bb4e6 100644 --- a/src/cloudflare/types/magic_transit/sites/__init__.py +++ b/src/cloudflare/types/magic_transit/sites/__init__.py @@ -12,6 +12,9 @@ from .dhcp_server import DHCPServer as DHCPServer from .subnet_param import SubnetParam as SubnetParam from .routed_subnet import RoutedSubnet as RoutedSubnet +from .acl_edit_params import ACLEditParams as ACLEditParams +from .lan_edit_params import LANEditParams as LANEditParams +from .wan_edit_params import WANEditParams as WANEditParams from .allowed_protocol import AllowedProtocol as AllowedProtocol from .dhcp_relay_param import DHCPRelayParam as DHCPRelayParam from .acl_configuration import ACLConfiguration as ACLConfiguration diff --git a/src/cloudflare/types/magic_transit/sites/acl_edit_params.py b/src/cloudflare/types/magic_transit/sites/acl_edit_params.py new file mode 100644 index 00000000000..a8808b1b868 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/acl_edit_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, TypedDict + +from .allowed_protocol import AllowedProtocol +from .acl_configuration_param import ACLConfigurationParam + +__all__ = ["ACLEditParams"] + + +class ACLEditParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + description: str + """Description for the ACL.""" + + forward_locally: bool + """The desired forwarding action for this ACL policy. + + If set to "false", the policy will forward traffic to Cloudflare. If set to + "true", the policy will forward traffic locally on the Magic WAN Connector. If + not included in request, will default to false. + """ + + lan_1: ACLConfigurationParam + + lan_2: ACLConfigurationParam + + name: str + """The name of the ACL.""" + + protocols: List[AllowedProtocol] diff --git a/src/cloudflare/types/magic_transit/sites/lan_edit_params.py b/src/cloudflare/types/magic_transit/sites/lan_edit_params.py new file mode 100644 index 00000000000..ca11b71b860 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/lan_edit_params.py @@ -0,0 +1,38 @@ +# 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 .nat_param import NatParam +from .routed_subnet_param import RoutedSubnetParam +from .lan_static_addressing_param import LANStaticAddressingParam + +__all__ = ["LANEditParams"] + + +class LANEditParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + name: str + + nat: NatParam + + physport: int + + routed_subnets: Iterable[RoutedSubnetParam] + + static_addressing: LANStaticAddressingParam + """ + If the site is not configured in high availability mode, this configuration is + optional (if omitted, use DHCP). However, if in high availability mode, + static_address is required along with secondary and virtual address. + """ + + vlan_tag: int + """VLAN port number.""" diff --git a/src/cloudflare/types/magic_transit/sites/wan_edit_params.py b/src/cloudflare/types/magic_transit/sites/wan_edit_params.py new file mode 100644 index 00000000000..fdd941a07b4 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/wan_edit_params.py @@ -0,0 +1,32 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +from .wan_static_addressing_param import WANStaticAddressingParam + +__all__ = ["WANEditParams"] + + +class WANEditParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + name: str + + physport: int + + priority: int + + static_addressing: WANStaticAddressingParam + """(optional) if omitted, use DHCP. + + Submit secondary_address when site is in high availability mode. + """ + + vlan_tag: int + """VLAN port number.""" diff --git a/src/cloudflare/types/zero_trust/risk_scoring/__init__.py b/src/cloudflare/types/zero_trust/risk_scoring/__init__.py index dce834add7c..8f787e32eb6 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/__init__.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/__init__.py @@ -6,4 +6,10 @@ from .summary_get_response import SummaryGetResponse as SummaryGetResponse from .behaviour_get_response import BehaviourGetResponse as BehaviourGetResponse from .behaviour_update_params import BehaviourUpdateParams as BehaviourUpdateParams +from .integration_get_response import IntegrationGetResponse as IntegrationGetResponse from .behaviour_update_response import BehaviourUpdateResponse as BehaviourUpdateResponse +from .integration_create_params import IntegrationCreateParams as IntegrationCreateParams +from .integration_list_response import IntegrationListResponse as IntegrationListResponse +from .integration_update_params import IntegrationUpdateParams as IntegrationUpdateParams +from .integration_create_response import IntegrationCreateResponse as IntegrationCreateResponse +from .integration_update_response import IntegrationUpdateResponse as IntegrationUpdateResponse diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_create_params.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_create_params.py new file mode 100644 index 00000000000..06b74f56012 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_create_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["IntegrationCreateParams"] + + +class IntegrationCreateParams(TypedDict, total=False): + account_id: Required[str] + + integration_type: Required[Literal["Okta"]] + + tenant_url: Required[str] + """The base url of the tenant, e.g. "https://tenant.okta.com" """ + + reference_id: Optional[str] + """A reference id that can be supplied by the client. + + Currently this should be set to the Access-Okta IDP ID (a UUIDv4). + https://developers.cloudflare.com/api/operations/access-identity-providers-get-an-access-identity-provider + """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_create_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_create_response.py new file mode 100644 index 00000000000..fe710d49e74 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_create_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["IntegrationCreateResponse"] + + +class IntegrationCreateResponse(BaseModel): + id: str + """The id of the integration, a UUIDv4.""" + + account_tag: str + """The Cloudflare account tag.""" + + active: bool + """Whether this integration is enabled and should export changes in risk score.""" + + created_at: datetime + """When the integration was created in RFC3339 format.""" + + integration_type: Literal["Okta"] + + reference_id: str + """ + A reference ID defined by the client. Should be set to the Access-Okta IDP + integration ID. Useful when the risk-score integration needs to be associated + with a secondary asset and recalled using that ID. + """ + + tenant_url: str + """The base URL for the tenant. E.g. "https://tenant.okta.com" """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_get_response.py new file mode 100644 index 00000000000..af016764ca9 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_get_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["IntegrationGetResponse"] + + +class IntegrationGetResponse(BaseModel): + id: str + """The id of the integration, a UUIDv4.""" + + account_tag: str + """The Cloudflare account tag.""" + + active: bool + """Whether this integration is enabled and should export changes in risk score.""" + + created_at: datetime + """When the integration was created in RFC3339 format.""" + + integration_type: Literal["Okta"] + + reference_id: str + """ + A reference ID defined by the client. Should be set to the Access-Okta IDP + integration ID. Useful when the risk-score integration needs to be associated + with a secondary asset and recalled using that ID. + """ + + tenant_url: str + """The base URL for the tenant. E.g. "https://tenant.okta.com" """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_list_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_list_response.py new file mode 100644 index 00000000000..a56a92339d9 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_list_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["IntegrationListResponse"] + + +class IntegrationListResponse(BaseModel): + id: str + """The id of the integration, a UUIDv4.""" + + account_tag: str + """The Cloudflare account tag.""" + + active: bool + """Whether this integration is enabled and should export changes in risk score.""" + + created_at: datetime + """When the integration was created in RFC3339 format.""" + + integration_type: Literal["Okta"] + + reference_id: str + """ + A reference ID defined by the client. Should be set to the Access-Okta IDP + integration ID. Useful when the risk-score integration needs to be associated + with a secondary asset and recalled using that ID. + """ + + tenant_url: str + """The base URL for the tenant. E.g. "https://tenant.okta.com" """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_update_params.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_update_params.py new file mode 100644 index 00000000000..82ad2a12b93 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_update_params.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Required, TypedDict + +__all__ = ["IntegrationUpdateParams"] + + +class IntegrationUpdateParams(TypedDict, total=False): + account_id: Required[str] + + active: Required[bool] + """Whether this integration is enabled. + + If disabled, no risk changes will be exported to the third-party. + """ + + tenant_url: Required[str] + """The base url of the tenant, e.g. "https://tenant.okta.com" """ + + reference_id: Optional[str] + """A reference id that can be supplied by the client. + + Currently this should be set to the Access-Okta IDP ID (a UUIDv4). + https://developers.cloudflare.com/api/operations/access-identity-providers-get-an-access-identity-provider + """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_update_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_update_response.py new file mode 100644 index 00000000000..9fc5ff96e0d --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_update_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["IntegrationUpdateResponse"] + + +class IntegrationUpdateResponse(BaseModel): + id: str + """The id of the integration, a UUIDv4.""" + + account_tag: str + """The Cloudflare account tag.""" + + active: bool + """Whether this integration is enabled and should export changes in risk score.""" + + created_at: datetime + """When the integration was created in RFC3339 format.""" + + integration_type: Literal["Okta"] + + reference_id: str + """ + A reference ID defined by the client. Should be set to the Access-Okta IDP + integration ID. Useful when the risk-score integration needs to be associated + with a secondary asset and recalled using that ID. + """ + + tenant_url: str + """The base URL for the tenant. E.g. "https://tenant.okta.com" """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integrations/__init__.py b/src/cloudflare/types/zero_trust/risk_scoring/integrations/__init__.py new file mode 100644 index 00000000000..9a9f7de1c68 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/integrations/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .reference_get_response import ReferenceGetResponse as ReferenceGetResponse diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integrations/reference_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integrations/reference_get_response.py new file mode 100644 index 00000000000..071ae7cf5e6 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/integrations/reference_get_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from ....._models import BaseModel + +__all__ = ["ReferenceGetResponse"] + + +class ReferenceGetResponse(BaseModel): + id: str + """The id of the integration, a UUIDv4.""" + + account_tag: str + """The Cloudflare account tag.""" + + active: bool + """Whether this integration is enabled and should export changes in risk score.""" + + created_at: datetime + """When the integration was created in RFC3339 format.""" + + integration_type: Literal["Okta"] + + reference_id: str + """ + A reference ID defined by the client. Should be set to the Access-Okta IDP + integration ID. Useful when the risk-score integration needs to be associated + with a secondary asset and recalled using that ID. + """ + + tenant_url: str + """The base URL for the tenant. E.g. "https://tenant.okta.com" """ diff --git a/tests/api_resources/d1/test_database.py b/tests/api_resources/d1/test_database.py index a27420dbd1e..15d0c3e2765 100644 --- a/tests/api_resources/d1/test_database.py +++ b/tests/api_resources/d1/test_database.py @@ -10,8 +10,11 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.types.d1 import ( + D1, DatabaseListResponse, + DatabaseQueryResponse, DatabaseCreateResponse, + DatabaseDeleteResponse, ) from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray @@ -111,6 +114,165 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + database = client.d1.database.delete( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DatabaseDeleteResponse, database, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.d1.database.with_raw_response.delete( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + database = response.parse() + assert_matches_type(DatabaseDeleteResponse, database, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.d1.database.with_streaming_response.delete( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + database = response.parse() + assert_matches_type(DatabaseDeleteResponse, database, 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.d1.database.with_raw_response.delete( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_id` but received ''"): + client.d1.database.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + database = client.d1.database.get( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(D1, database, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.d1.database.with_raw_response.get( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + database = response.parse() + assert_matches_type(D1, database, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.d1.database.with_streaming_response.get( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + database = response.parse() + assert_matches_type(D1, database, 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.d1.database.with_raw_response.get( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_id` but received ''"): + client.d1.database.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_query(self, client: Cloudflare) -> None: + database = client.d1.database.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + assert_matches_type(DatabaseQueryResponse, database, path=["response"]) + + @parametrize + def test_method_query_with_all_params(self, client: Cloudflare) -> None: + database = client.d1.database.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + params=["firstParam", "secondParam"], + ) + assert_matches_type(DatabaseQueryResponse, database, path=["response"]) + + @parametrize + def test_raw_response_query(self, client: Cloudflare) -> None: + response = client.d1.database.with_raw_response.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + database = response.parse() + assert_matches_type(DatabaseQueryResponse, database, path=["response"]) + + @parametrize + def test_streaming_response_query(self, client: Cloudflare) -> None: + with client.d1.database.with_streaming_response.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + database = response.parse() + assert_matches_type(DatabaseQueryResponse, database, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_query(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.d1.database.with_raw_response.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_id` but received ''"): + client.d1.database.with_raw_response.query( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + class TestAsyncDatabase: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -204,3 +366,162 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.d1.database.with_raw_response.list( account_id="", ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + database = await async_client.d1.database.delete( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DatabaseDeleteResponse, database, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.d1.database.with_raw_response.delete( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + database = await response.parse() + assert_matches_type(DatabaseDeleteResponse, database, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.d1.database.with_streaming_response.delete( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + database = await response.parse() + assert_matches_type(DatabaseDeleteResponse, database, 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.d1.database.with_raw_response.delete( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_id` but received ''"): + await async_client.d1.database.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + database = await async_client.d1.database.get( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(D1, database, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.d1.database.with_raw_response.get( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + database = await response.parse() + assert_matches_type(D1, database, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.d1.database.with_streaming_response.get( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + database = await response.parse() + assert_matches_type(D1, database, 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.d1.database.with_raw_response.get( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_id` but received ''"): + await async_client.d1.database.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_query(self, async_client: AsyncCloudflare) -> None: + database = await async_client.d1.database.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + assert_matches_type(DatabaseQueryResponse, database, path=["response"]) + + @parametrize + async def test_method_query_with_all_params(self, async_client: AsyncCloudflare) -> None: + database = await async_client.d1.database.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + params=["firstParam", "secondParam"], + ) + assert_matches_type(DatabaseQueryResponse, database, path=["response"]) + + @parametrize + async def test_raw_response_query(self, async_client: AsyncCloudflare) -> None: + response = await async_client.d1.database.with_raw_response.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + database = await response.parse() + assert_matches_type(DatabaseQueryResponse, database, path=["response"]) + + @parametrize + async def test_streaming_response_query(self, async_client: AsyncCloudflare) -> None: + async with async_client.d1.database.with_streaming_response.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + database = await response.parse() + assert_matches_type(DatabaseQueryResponse, database, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_query(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.d1.database.with_raw_response.query( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_id` but received ''"): + await async_client.d1.database.with_raw_response.query( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) diff --git a/tests/api_resources/magic_transit/sites/test_acls.py b/tests/api_resources/magic_transit/sites/test_acls.py index 107cdc54368..4bcac3f4126 100644 --- a/tests/api_resources/magic_transit/sites/test_acls.py +++ b/tests/api_resources/magic_transit/sites/test_acls.py @@ -10,7 +10,9 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.magic_transit.sites import ACL +from cloudflare.types.magic_transit.sites import ( + ACL, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -298,6 +300,91 @@ def test_path_params_delete(self, client: Cloudflare) -> None: site_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + acl = client.magic_transit.sites.acls.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Allows local traffic between PIN pads and cash register.", + forward_locally=True, + lan_1={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + lan_2={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + name="PIN Pad - Cash Register", + protocols=["tcp", "udp", "icmp"], + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.magic_transit.sites.acls.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = response.parse() + assert_matches_type(ACL, acl, 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.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_identifier` but received ''"): + client.magic_transit.sites.acls.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize def test_method_get(self, client: Cloudflare) -> None: acl = client.magic_transit.sites.acls.get( @@ -642,6 +729,91 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: site_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + acl = await async_client.magic_transit.sites.acls.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + description="Allows local traffic between PIN pads and cash register.", + forward_locally=True, + lan_1={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + lan_2={ + "lan_id": "string", + "lan_name": "string", + "ports": [1, 1, 1], + "subnets": ["192.0.2.1", "192.0.2.1", "192.0.2.1"], + }, + name="PIN Pad - Cash Register", + protocols=["tcp", "udp", "icmp"], + ) + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + acl = await response.parse() + assert_matches_type(ACL, acl, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.acls.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + acl = await response.parse() + assert_matches_type(ACL, acl, 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.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `acl_identifier` but received ''"): + await async_client.magic_transit.sites.acls.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: acl = await async_client.magic_transit.sites.acls.get( diff --git a/tests/api_resources/magic_transit/sites/test_lans.py b/tests/api_resources/magic_transit/sites/test_lans.py index a6cbd9c9307..73aee303592 100644 --- a/tests/api_resources/magic_transit/sites/test_lans.py +++ b/tests/api_resources/magic_transit/sites/test_lans.py @@ -337,6 +337,111 @@ def test_path_params_delete(self, client: Cloudflare) -> None: site_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LAN, lan, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + lan = client.magic_transit.sites.lans.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + name="string", + nat={"static_prefix": "192.0.2.0/24"}, + physport=1, + routed_subnets=[ + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + ], + static_addressing={ + "address": "192.0.2.0/24", + "dhcp_relay": {"server_addresses": ["192.0.2.1", "192.0.2.1", "192.0.2.1"]}, + "dhcp_server": { + "dhcp_pool_end": "192.0.2.1", + "dhcp_pool_start": "192.0.2.1", + "dns_server": "192.0.2.1", + "reservations": { + "00:11:22:33:44:55": "192.0.2.100", + "AA:BB:CC:DD:EE:FF": "192.168.1.101", + }, + }, + "secondary_address": "192.0.2.0/24", + "virtual_address": "192.0.2.0/24", + }, + vlan_tag=0, + ) + assert_matches_type(LAN, lan, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.lans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = response.parse() + assert_matches_type(LAN, lan, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.magic_transit.sites.lans.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = response.parse() + assert_matches_type(LAN, lan, 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.magic_transit.sites.lans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `lan_id` but received ''"): + client.magic_transit.sites.lans.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize def test_method_get(self, client: Cloudflare) -> None: lan = client.magic_transit.sites.lans.get( @@ -717,6 +822,111 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: site_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(LAN, lan, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + lan = await async_client.magic_transit.sites.lans.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + name="string", + nat={"static_prefix": "192.0.2.0/24"}, + physport=1, + routed_subnets=[ + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + { + "nat": {"static_prefix": "192.0.2.0/24"}, + "next_hop": "192.0.2.1", + "prefix": "192.0.2.0/24", + }, + ], + static_addressing={ + "address": "192.0.2.0/24", + "dhcp_relay": {"server_addresses": ["192.0.2.1", "192.0.2.1", "192.0.2.1"]}, + "dhcp_server": { + "dhcp_pool_end": "192.0.2.1", + "dhcp_pool_start": "192.0.2.1", + "dns_server": "192.0.2.1", + "reservations": { + "00:11:22:33:44:55": "192.0.2.100", + "AA:BB:CC:DD:EE:FF": "192.168.1.101", + }, + }, + "secondary_address": "192.0.2.0/24", + "virtual_address": "192.0.2.0/24", + }, + vlan_tag=0, + ) + assert_matches_type(LAN, lan, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.lans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + lan = await response.parse() + assert_matches_type(LAN, lan, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.lans.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + lan = await response.parse() + assert_matches_type(LAN, lan, 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.magic_transit.sites.lans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `lan_id` but received ''"): + await async_client.magic_transit.sites.lans.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: lan = await async_client.magic_transit.sites.lans.get( diff --git a/tests/api_resources/magic_transit/sites/test_wans.py b/tests/api_resources/magic_transit/sites/test_wans.py index 86079814ce2..d8fa728ed91 100644 --- a/tests/api_resources/magic_transit/sites/test_wans.py +++ b/tests/api_resources/magic_transit/sites/test_wans.py @@ -282,6 +282,84 @@ def test_path_params_delete(self, client: Cloudflare) -> None: site_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WAN, wan, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + wan = client.magic_transit.sites.wans.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + name="string", + physport=1, + priority=0, + static_addressing={ + "address": "192.0.2.0/24", + "gateway_address": "192.0.2.1", + "secondary_address": "192.0.2.0/24", + }, + vlan_tag=0, + ) + assert_matches_type(WAN, wan, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.wans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = response.parse() + assert_matches_type(WAN, wan, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.magic_transit.sites.wans.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = response.parse() + assert_matches_type(WAN, wan, 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.magic_transit.sites.wans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `wan_id` but received ''"): + client.magic_transit.sites.wans.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize def test_method_get(self, client: Cloudflare) -> None: wan = client.magic_transit.sites.wans.get( @@ -607,6 +685,84 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: site_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(WAN, wan, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + wan = await async_client.magic_transit.sites.wans.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + name="string", + physport=1, + priority=0, + static_addressing={ + "address": "192.0.2.0/24", + "gateway_address": "192.0.2.1", + "secondary_address": "192.0.2.0/24", + }, + vlan_tag=0, + ) + assert_matches_type(WAN, wan, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.wans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + wan = await response.parse() + assert_matches_type(WAN, wan, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.wans.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + wan = await response.parse() + assert_matches_type(WAN, wan, 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.magic_transit.sites.wans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `wan_id` but received ''"): + await async_client.magic_transit.sites.wans.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: wan = await async_client.magic_transit.sites.wans.get( diff --git a/tests/api_resources/magic_transit/test_sites.py b/tests/api_resources/magic_transit/test_sites.py index a4cfda99cf1..ea1cafd24af 100644 --- a/tests/api_resources/magic_transit/test_sites.py +++ b/tests/api_resources/magic_transit/test_sites.py @@ -10,7 +10,9 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.magic_transit import Site +from cloudflare.types.magic_transit import ( + Site, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -234,6 +236,70 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Site, site, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + site = client.magic_transit.sites.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + connector_id="ac60d3d0435248289d446cedd870bcf4", + description="string", + location={ + "lat": "37.6192", + "lon": "122.3816", + }, + name="site_1", + secondary_connector_id="8d67040d3835dbcf46ce29da440dc482", + ) + assert_matches_type(Site, site, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = response.parse() + assert_matches_type(Site, site, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.magic_transit.sites.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = response.parse() + assert_matches_type(Site, site, 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.magic_transit.sites.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize def test_method_get(self, client: Cloudflare) -> None: site = client.magic_transit.sites.get( @@ -502,6 +568,70 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Site, site, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + site = await async_client.magic_transit.sites.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + connector_id="ac60d3d0435248289d446cedd870bcf4", + description="string", + location={ + "lat": "37.6192", + "lon": "122.3816", + }, + name="site_1", + secondary_connector_id="8d67040d3835dbcf46ce29da440dc482", + ) + assert_matches_type(Site, site, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + site = await response.parse() + assert_matches_type(Site, site, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + site = await response.parse() + assert_matches_type(Site, site, 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.magic_transit.sites.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.with_raw_response.edit( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: site = await async_client.magic_transit.sites.get( diff --git a/tests/api_resources/zero_trust/risk_scoring/integrations/__init__.py b/tests/api_resources/zero_trust/risk_scoring/integrations/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/zero_trust/risk_scoring/integrations/__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/risk_scoring/integrations/test_references.py b/tests/api_resources/zero_trust/risk_scoring/integrations/test_references.py new file mode 100644 index 00000000000..6f7e3ae07d5 --- /dev/null +++ b/tests/api_resources/zero_trust/risk_scoring/integrations/test_references.py @@ -0,0 +1,118 @@ +# 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.risk_scoring.integrations import ReferenceGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestReferences: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + reference = client.zero_trust.risk_scoring.integrations.references.get( + "string", + account_id="string", + ) + assert_matches_type(Optional[ReferenceGetResponse], reference, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.integrations.references.with_raw_response.get( + "string", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + reference = response.parse() + assert_matches_type(Optional[ReferenceGetResponse], reference, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.integrations.references.with_streaming_response.get( + "string", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + reference = response.parse() + assert_matches_type(Optional[ReferenceGetResponse], reference, 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.risk_scoring.integrations.references.with_raw_response.get( + "string", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `reference_id` but received ''"): + client.zero_trust.risk_scoring.integrations.references.with_raw_response.get( + "", + account_id="string", + ) + + +class TestAsyncReferences: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + reference = await async_client.zero_trust.risk_scoring.integrations.references.get( + "string", + account_id="string", + ) + assert_matches_type(Optional[ReferenceGetResponse], reference, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.integrations.references.with_raw_response.get( + "string", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + reference = await response.parse() + assert_matches_type(Optional[ReferenceGetResponse], reference, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.integrations.references.with_streaming_response.get( + "string", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + reference = await response.parse() + assert_matches_type(Optional[ReferenceGetResponse], reference, 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.risk_scoring.integrations.references.with_raw_response.get( + "string", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `reference_id` but received ''"): + await async_client.zero_trust.risk_scoring.integrations.references.with_raw_response.get( + "", + account_id="string", + ) diff --git a/tests/api_resources/zero_trust/risk_scoring/test_integrations.py b/tests/api_resources/zero_trust/risk_scoring/test_integrations.py new file mode 100644 index 00000000000..2ff5a9ecbc8 --- /dev/null +++ b/tests/api_resources/zero_trust/risk_scoring/test_integrations.py @@ -0,0 +1,546 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.risk_scoring import ( + IntegrationGetResponse, + IntegrationListResponse, + IntegrationCreateResponse, + IntegrationUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestIntegrations: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + integration = client.zero_trust.risk_scoring.integrations.create( + account_id="string", + integration_type="Okta", + tenant_url="https://example.com", + ) + assert_matches_type(Optional[IntegrationCreateResponse], integration, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + integration = client.zero_trust.risk_scoring.integrations.create( + account_id="string", + integration_type="Okta", + tenant_url="https://example.com", + reference_id="string", + ) + assert_matches_type(Optional[IntegrationCreateResponse], integration, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.integrations.with_raw_response.create( + account_id="string", + integration_type="Okta", + tenant_url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = response.parse() + assert_matches_type(Optional[IntegrationCreateResponse], integration, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.integrations.with_streaming_response.create( + account_id="string", + integration_type="Okta", + tenant_url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = response.parse() + assert_matches_type(Optional[IntegrationCreateResponse], integration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.risk_scoring.integrations.with_raw_response.create( + account_id="", + integration_type="Okta", + tenant_url="https://example.com", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + integration = client.zero_trust.risk_scoring.integrations.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + active=True, + tenant_url="https://example.com", + ) + assert_matches_type(Optional[IntegrationUpdateResponse], integration, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + integration = client.zero_trust.risk_scoring.integrations.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + active=True, + tenant_url="https://example.com", + reference_id="string", + ) + assert_matches_type(Optional[IntegrationUpdateResponse], integration, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.integrations.with_raw_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + active=True, + tenant_url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = response.parse() + assert_matches_type(Optional[IntegrationUpdateResponse], integration, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.integrations.with_streaming_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + active=True, + tenant_url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = response.parse() + assert_matches_type(Optional[IntegrationUpdateResponse], integration, 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.risk_scoring.integrations.with_raw_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="", + active=True, + tenant_url="https://example.com", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `integration_id` but received ''"): + client.zero_trust.risk_scoring.integrations.with_raw_response.update( + "", + account_id="string", + active=True, + tenant_url="https://example.com", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + integration = client.zero_trust.risk_scoring.integrations.list( + account_id="string", + ) + assert_matches_type(SyncSinglePage[IntegrationListResponse], integration, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.integrations.with_raw_response.list( + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = response.parse() + assert_matches_type(SyncSinglePage[IntegrationListResponse], integration, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.integrations.with_streaming_response.list( + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = response.parse() + assert_matches_type(SyncSinglePage[IntegrationListResponse], integration, 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.risk_scoring.integrations.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + integration = client.zero_trust.risk_scoring.integrations.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) + assert_matches_type(object, integration, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.integrations.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = response.parse() + assert_matches_type(object, integration, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.integrations.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = response.parse() + assert_matches_type(object, integration, 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.risk_scoring.integrations.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `integration_id` but received ''"): + client.zero_trust.risk_scoring.integrations.with_raw_response.delete( + "", + account_id="string", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + integration = client.zero_trust.risk_scoring.integrations.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) + assert_matches_type(Optional[IntegrationGetResponse], integration, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.integrations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = response.parse() + assert_matches_type(Optional[IntegrationGetResponse], integration, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.integrations.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = response.parse() + assert_matches_type(Optional[IntegrationGetResponse], integration, 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.risk_scoring.integrations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `integration_id` but received ''"): + client.zero_trust.risk_scoring.integrations.with_raw_response.get( + "", + account_id="string", + ) + + +class TestAsyncIntegrations: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + integration = await async_client.zero_trust.risk_scoring.integrations.create( + account_id="string", + integration_type="Okta", + tenant_url="https://example.com", + ) + assert_matches_type(Optional[IntegrationCreateResponse], integration, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + integration = await async_client.zero_trust.risk_scoring.integrations.create( + account_id="string", + integration_type="Okta", + tenant_url="https://example.com", + reference_id="string", + ) + assert_matches_type(Optional[IntegrationCreateResponse], integration, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.integrations.with_raw_response.create( + account_id="string", + integration_type="Okta", + tenant_url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = await response.parse() + assert_matches_type(Optional[IntegrationCreateResponse], integration, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.integrations.with_streaming_response.create( + account_id="string", + integration_type="Okta", + tenant_url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = await response.parse() + assert_matches_type(Optional[IntegrationCreateResponse], integration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.risk_scoring.integrations.with_raw_response.create( + account_id="", + integration_type="Okta", + tenant_url="https://example.com", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + integration = await async_client.zero_trust.risk_scoring.integrations.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + active=True, + tenant_url="https://example.com", + ) + assert_matches_type(Optional[IntegrationUpdateResponse], integration, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + integration = await async_client.zero_trust.risk_scoring.integrations.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + active=True, + tenant_url="https://example.com", + reference_id="string", + ) + assert_matches_type(Optional[IntegrationUpdateResponse], integration, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.integrations.with_raw_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + active=True, + tenant_url="https://example.com", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = await response.parse() + assert_matches_type(Optional[IntegrationUpdateResponse], integration, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.integrations.with_streaming_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + active=True, + tenant_url="https://example.com", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = await response.parse() + assert_matches_type(Optional[IntegrationUpdateResponse], integration, 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.risk_scoring.integrations.with_raw_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="", + active=True, + tenant_url="https://example.com", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `integration_id` but received ''"): + await async_client.zero_trust.risk_scoring.integrations.with_raw_response.update( + "", + account_id="string", + active=True, + tenant_url="https://example.com", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + integration = await async_client.zero_trust.risk_scoring.integrations.list( + account_id="string", + ) + assert_matches_type(AsyncSinglePage[IntegrationListResponse], integration, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.integrations.with_raw_response.list( + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = await response.parse() + assert_matches_type(AsyncSinglePage[IntegrationListResponse], integration, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.integrations.with_streaming_response.list( + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = await response.parse() + assert_matches_type(AsyncSinglePage[IntegrationListResponse], integration, 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.risk_scoring.integrations.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + integration = await async_client.zero_trust.risk_scoring.integrations.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) + assert_matches_type(object, integration, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.integrations.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = await response.parse() + assert_matches_type(object, integration, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.integrations.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = await response.parse() + assert_matches_type(object, integration, 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.risk_scoring.integrations.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `integration_id` but received ''"): + await async_client.zero_trust.risk_scoring.integrations.with_raw_response.delete( + "", + account_id="string", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + integration = await async_client.zero_trust.risk_scoring.integrations.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) + assert_matches_type(Optional[IntegrationGetResponse], integration, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.integrations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + integration = await response.parse() + assert_matches_type(Optional[IntegrationGetResponse], integration, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.integrations.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + integration = await response.parse() + assert_matches_type(Optional[IntegrationGetResponse], integration, 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.risk_scoring.integrations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `integration_id` but received ''"): + await async_client.zero_trust.risk_scoring.integrations.with_raw_response.get( + "", + account_id="string", + ) From f8489eb6d00b81a93552edaec6029b7210d10c7a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 09:42:08 +0000 Subject: [PATCH 074/532] feat(api): OpenAPI spec update via Stainless API (#555) --- .stats.yml | 2 +- .../resources/ai_gateway/ai_gateway.py | 20 +++++++++---------- src/cloudflare/resources/ai_gateway/logs.py | 4 ++-- .../ai_gateway/ai_gateway_create_params.py | 2 +- .../ai_gateway/ai_gateway_create_response.py | 2 +- .../ai_gateway/ai_gateway_delete_response.py | 2 +- .../ai_gateway/ai_gateway_get_response.py | 2 +- .../ai_gateway/ai_gateway_list_params.py | 2 +- .../ai_gateway/ai_gateway_list_response.py | 2 +- .../ai_gateway/ai_gateway_update_response.py | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0346a89ff96..785e840739c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-241f970730129e553d466806420a1cf2f6d665abec11667004cb9cf070932a1e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eac0a33bed194093caab0eee016a8225cbd4af5bf185da2242f444e73f279cc4.yml diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 7c08856dc34..76774aed510 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -78,7 +78,7 @@ def create( Create a new Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -136,7 +136,7 @@ def update( Update a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -192,7 +192,7 @@ def list( List Gateway's Args: - id: gateway slug + id: gateway id order_by: Order By Column Name @@ -243,7 +243,7 @@ def delete( Delete a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -285,7 +285,7 @@ def get( Fetch a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -347,7 +347,7 @@ async def create( Create a new Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -405,7 +405,7 @@ async def update( Update a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -461,7 +461,7 @@ def list( List Gateway's Args: - id: gateway slug + id: gateway id order_by: Order By Column Name @@ -512,7 +512,7 @@ async def delete( Delete a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -554,7 +554,7 @@ async def get( Fetch a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py index d993d455796..01650e97aa3 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -65,7 +65,7 @@ def get( List Gateway Logs Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -140,7 +140,7 @@ async def get( List Gateway Logs Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py index 2695453e91d..876aa2295cc 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py @@ -11,7 +11,7 @@ class AIGatewayCreateParams(TypedDict, total=False): account_id: Required[str] id: Required[str] - """gateway slug""" + """gateway id""" cache_invalidate_on_update: Required[bool] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py index 2497e62cf30..79833ca2751 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py @@ -10,7 +10,7 @@ class Task(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py index 0c0c3708b26..a4968de542a 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py @@ -10,7 +10,7 @@ class AIGatewayDeleteResponse(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py index 3cae0803a57..7718bd50b46 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py @@ -10,7 +10,7 @@ class AIGatewayGetResponse(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py index 494ebd39541..71961792462 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py @@ -11,7 +11,7 @@ class AIGatewayListParams(TypedDict, total=False): account_id: Required[str] id: str - """gateway slug""" + """gateway id""" order_by: str """Order By Column Name""" diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py index 9dc08f49b77..eab99a61793 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py @@ -10,7 +10,7 @@ class AIGatewayListResponse(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py index 425aaac572b..d0741678568 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py @@ -10,7 +10,7 @@ class AIGatewayUpdateResponse(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool From 1f18ceb466feb84eab6d4332ad91ecda14554074 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 09:44:33 +0000 Subject: [PATCH 075/532] feat(api): OpenAPI spec update via Stainless API (#556) --- .stats.yml | 2 +- .../resources/ai_gateway/ai_gateway.py | 20 +++++++++---------- src/cloudflare/resources/ai_gateway/logs.py | 4 ++-- .../ai_gateway/ai_gateway_create_params.py | 2 +- .../ai_gateway/ai_gateway_create_response.py | 2 +- .../ai_gateway/ai_gateway_delete_response.py | 2 +- .../ai_gateway/ai_gateway_get_response.py | 2 +- .../ai_gateway/ai_gateway_list_params.py | 2 +- .../ai_gateway/ai_gateway_list_response.py | 2 +- .../ai_gateway/ai_gateway_update_response.py | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index 785e840739c..0346a89ff96 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eac0a33bed194093caab0eee016a8225cbd4af5bf185da2242f444e73f279cc4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-241f970730129e553d466806420a1cf2f6d665abec11667004cb9cf070932a1e.yml diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 76774aed510..7c08856dc34 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -78,7 +78,7 @@ def create( Create a new Gateway Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers @@ -136,7 +136,7 @@ def update( Update a Gateway Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers @@ -192,7 +192,7 @@ def list( List Gateway's Args: - id: gateway id + id: gateway slug order_by: Order By Column Name @@ -243,7 +243,7 @@ def delete( Delete a Gateway Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers @@ -285,7 +285,7 @@ def get( Fetch a Gateway Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers @@ -347,7 +347,7 @@ async def create( Create a new Gateway Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers @@ -405,7 +405,7 @@ async def update( Update a Gateway Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers @@ -461,7 +461,7 @@ def list( List Gateway's Args: - id: gateway id + id: gateway slug order_by: Order By Column Name @@ -512,7 +512,7 @@ async def delete( Delete a Gateway Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers @@ -554,7 +554,7 @@ async def get( Fetch a Gateway Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py index 01650e97aa3..d993d455796 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -65,7 +65,7 @@ def get( List Gateway Logs Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers @@ -140,7 +140,7 @@ async def get( List Gateway Logs Args: - id: gateway id + id: gateway slug extra_headers: Send extra headers diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py index 876aa2295cc..2695453e91d 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py @@ -11,7 +11,7 @@ class AIGatewayCreateParams(TypedDict, total=False): account_id: Required[str] id: Required[str] - """gateway id""" + """gateway slug""" cache_invalidate_on_update: Required[bool] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py index 79833ca2751..2497e62cf30 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py @@ -10,7 +10,7 @@ class Task(BaseModel): id: str - """gateway id""" + """gateway slug""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py index a4968de542a..0c0c3708b26 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py @@ -10,7 +10,7 @@ class AIGatewayDeleteResponse(BaseModel): id: str - """gateway id""" + """gateway slug""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py index 7718bd50b46..3cae0803a57 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py @@ -10,7 +10,7 @@ class AIGatewayGetResponse(BaseModel): id: str - """gateway id""" + """gateway slug""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py index 71961792462..494ebd39541 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py @@ -11,7 +11,7 @@ class AIGatewayListParams(TypedDict, total=False): account_id: Required[str] id: str - """gateway id""" + """gateway slug""" order_by: str """Order By Column Name""" diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py index eab99a61793..9dc08f49b77 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py @@ -10,7 +10,7 @@ class AIGatewayListResponse(BaseModel): id: str - """gateway id""" + """gateway slug""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py index d0741678568..425aaac572b 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py @@ -10,7 +10,7 @@ class AIGatewayUpdateResponse(BaseModel): id: str - """gateway id""" + """gateway slug""" cache_invalidate_on_update: bool From d0b53fbbc6ae22da6e90fb74d0792593e97f4b01 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 10:40:51 +0000 Subject: [PATCH 076/532] feat(api): OpenAPI spec update via Stainless API (#557) --- .stats.yml | 2 +- .../resources/ai_gateway/ai_gateway.py | 20 +++++++++---------- src/cloudflare/resources/ai_gateway/logs.py | 4 ++-- .../ai_gateway/ai_gateway_create_params.py | 2 +- .../ai_gateway/ai_gateway_create_response.py | 2 +- .../ai_gateway/ai_gateway_delete_response.py | 2 +- .../ai_gateway/ai_gateway_get_response.py | 2 +- .../ai_gateway/ai_gateway_list_params.py | 2 +- .../ai_gateway/ai_gateway_list_response.py | 2 +- .../ai_gateway/ai_gateway_update_response.py | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0346a89ff96..c6d377283fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-241f970730129e553d466806420a1cf2f6d665abec11667004cb9cf070932a1e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2bddc40a8ff2dca86129579a3be28dccb6e6376cde30e50c62641a366280395c.yml diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 7c08856dc34..76774aed510 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -78,7 +78,7 @@ def create( Create a new Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -136,7 +136,7 @@ def update( Update a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -192,7 +192,7 @@ def list( List Gateway's Args: - id: gateway slug + id: gateway id order_by: Order By Column Name @@ -243,7 +243,7 @@ def delete( Delete a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -285,7 +285,7 @@ def get( Fetch a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -347,7 +347,7 @@ async def create( Create a new Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -405,7 +405,7 @@ async def update( Update a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -461,7 +461,7 @@ def list( List Gateway's Args: - id: gateway slug + id: gateway id order_by: Order By Column Name @@ -512,7 +512,7 @@ async def delete( Delete a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -554,7 +554,7 @@ async def get( Fetch a Gateway Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py index d993d455796..01650e97aa3 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -65,7 +65,7 @@ def get( List Gateway Logs Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers @@ -140,7 +140,7 @@ async def get( List Gateway Logs Args: - id: gateway slug + id: gateway id extra_headers: Send extra headers diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py index 2695453e91d..876aa2295cc 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py @@ -11,7 +11,7 @@ class AIGatewayCreateParams(TypedDict, total=False): account_id: Required[str] id: Required[str] - """gateway slug""" + """gateway id""" cache_invalidate_on_update: Required[bool] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py index 2497e62cf30..79833ca2751 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py @@ -10,7 +10,7 @@ class Task(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py index 0c0c3708b26..a4968de542a 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py @@ -10,7 +10,7 @@ class AIGatewayDeleteResponse(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py index 3cae0803a57..7718bd50b46 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py @@ -10,7 +10,7 @@ class AIGatewayGetResponse(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py index 494ebd39541..71961792462 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py @@ -11,7 +11,7 @@ class AIGatewayListParams(TypedDict, total=False): account_id: Required[str] id: str - """gateway slug""" + """gateway id""" order_by: str """Order By Column Name""" diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py index 9dc08f49b77..eab99a61793 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py @@ -10,7 +10,7 @@ class AIGatewayListResponse(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py index 425aaac572b..d0741678568 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py @@ -10,7 +10,7 @@ class AIGatewayUpdateResponse(BaseModel): id: str - """gateway slug""" + """gateway id""" cache_invalidate_on_update: bool From c5e858b492609752644d6a69beacc7c8c0dd8b82 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 14:02:54 +0000 Subject: [PATCH 077/532] feat(api): OpenAPI spec update via Stainless API (#558) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index c6d377283fc..b8ca6c43b4d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2bddc40a8ff2dca86129579a3be28dccb6e6376cde30e50c62641a366280395c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f3f9d81bde471bad0925995e3daa241250e84a4312b56a83ae28196fb683cb77.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 2cdd861719c9acf1c3b37779f8d5b349ab704150 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 14:28:38 +0000 Subject: [PATCH 078/532] feat(api): OpenAPI spec update via Stainless API (#559) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index b8ca6c43b4d..c6d377283fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f3f9d81bde471bad0925995e3daa241250e84a4312b56a83ae28196fb683cb77.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2bddc40a8ff2dca86129579a3be28dccb6e6376cde30e50c62641a366280395c.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 3716bf6e437410c64e5f5dc9934f605ac14109a2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 14:31:26 +0000 Subject: [PATCH 079/532] feat(api): OpenAPI spec update via Stainless API (#560) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index c6d377283fc..b8ca6c43b4d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2bddc40a8ff2dca86129579a3be28dccb6e6376cde30e50c62641a366280395c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f3f9d81bde471bad0925995e3daa241250e84a4312b56a83ae28196fb683cb77.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 7e9a942a8b5959ddd734d35fce2bb895a2379936 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 15:14:25 +0000 Subject: [PATCH 080/532] feat(api): OpenAPI spec update via Stainless API (#561) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index b8ca6c43b4d..785e840739c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f3f9d81bde471bad0925995e3daa241250e84a4312b56a83ae28196fb683cb77.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eac0a33bed194093caab0eee016a8225cbd4af5bf185da2242f444e73f279cc4.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 4ca8f6a66747b5dec0126167b6257a3f55ebc385 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 15:16:49 +0000 Subject: [PATCH 081/532] feat(api): OpenAPI spec update via Stainless API (#562) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 785e840739c..c6d377283fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eac0a33bed194093caab0eee016a8225cbd4af5bf185da2242f444e73f279cc4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2bddc40a8ff2dca86129579a3be28dccb6e6376cde30e50c62641a366280395c.yml From df67542643c6b5d17d97b8db6c872508c6225642 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 16:28:20 +0000 Subject: [PATCH 082/532] feat(api): OpenAPI spec update via Stainless API (#563) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index c6d377283fc..ab6d60b97f9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2bddc40a8ff2dca86129579a3be28dccb6e6376cde30e50c62641a366280395c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-89ee887e776dbd6a951c5ec86b7554f3f1eeb4862460b3242f23e1b6f33f6d3c.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From c59b84cfb094e06b5032a015f729320b2196b3e5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 18:02:54 +0000 Subject: [PATCH 083/532] feat(api): OpenAPI spec update via Stainless API (#564) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ab6d60b97f9..7da1a9b0ce8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-89ee887e776dbd6a951c5ec86b7554f3f1eeb4862460b3242f23e1b6f33f6d3c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2c59ba17fb766d9e90a181533e4a331d5bd1f1bf9d2f4ede385e68a40eed3c15.yml From c61e5dd9a2b6e4a69d342104635c472766663792 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 19:16:51 +0000 Subject: [PATCH 084/532] feat(api): OpenAPI spec update via Stainless API (#565) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7da1a9b0ce8..4d55a91598c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2c59ba17fb766d9e90a181533e4a331d5bd1f1bf9d2f4ede385e68a40eed3c15.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-da87625c4b73e80b854a5d9c24c950c288ffc20910e51369326afa5749108968.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 4859e81914b8c5c75a0ea13d9053fd93d0b47baa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 19:19:14 +0000 Subject: [PATCH 085/532] feat(api): OpenAPI spec update via Stainless API (#566) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4d55a91598c..7da1a9b0ce8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-da87625c4b73e80b854a5d9c24c950c288ffc20910e51369326afa5749108968.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2c59ba17fb766d9e90a181533e4a331d5bd1f1bf9d2f4ede385e68a40eed3c15.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 1f7391e7afbdcd2204f807415f5949027989572e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 May 2024 20:07:35 +0000 Subject: [PATCH 086/532] feat(api): OpenAPI spec update via Stainless API (#567) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7da1a9b0ce8..4d55a91598c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2c59ba17fb766d9e90a181533e4a331d5bd1f1bf9d2f4ede385e68a40eed3c15.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-da87625c4b73e80b854a5d9c24c950c288ffc20910e51369326afa5749108968.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From cb1c357b8371055d7617536ab51b773b227aba4b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 May 2024 15:48:06 +0000 Subject: [PATCH 087/532] feat(api): OpenAPI spec update via Stainless API (#568) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4d55a91598c..7da1a9b0ce8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-da87625c4b73e80b854a5d9c24c950c288ffc20910e51369326afa5749108968.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2c59ba17fb766d9e90a181533e4a331d5bd1f1bf9d2f4ede385e68a40eed3c15.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From d19f8fca183c77363c0e5583e745582f5be3ac69 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 May 2024 15:50:29 +0000 Subject: [PATCH 088/532] feat(api): OpenAPI spec update via Stainless API (#569) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7da1a9b0ce8..ab6d60b97f9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2c59ba17fb766d9e90a181533e4a331d5bd1f1bf9d2f4ede385e68a40eed3c15.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-89ee887e776dbd6a951c5ec86b7554f3f1eeb4862460b3242f23e1b6f33f6d3c.yml From a5fd661f247e1d9046057c941ba747f1887a2623 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 08:01:52 +0000 Subject: [PATCH 089/532] feat(api): OpenAPI spec update via Stainless API (#570) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../types/ai_gateway/log_get_response.py | 2 + .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 14 files changed, 295 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index ab6d60b97f9..f77190ce8cb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-89ee887e776dbd6a951c5ec86b7554f3f1eeb4862460b3242f23e1b6f33f6d3c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-89c1a9e0b56e471e0daa8305cfaed0fb3ef444411a6e93f115aa3de048e0cb41.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/ai_gateway/log_get_response.py b/src/cloudflare/types/ai_gateway/log_get_response.py index c7d5c35580f..9a83c1d7a88 100644 --- a/src/cloudflare/types/ai_gateway/log_get_response.py +++ b/src/cloudflare/types/ai_gateway/log_get_response.py @@ -33,6 +33,8 @@ class LogGetResponseItem(BaseModel): tokens_out: int + metadata: Optional[str] = None + status_code: Optional[int] = None diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From bf7083bf52c3ee6352b96d95c2521028e71b4872 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 10:37:43 +0000 Subject: [PATCH 090/532] feat(api): OpenAPI spec update via Stainless API (#571) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index f77190ce8cb..e1cbe685c93 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-89c1a9e0b56e471e0daa8305cfaed0fb3ef444411a6e93f115aa3de048e0cb41.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a370326545e1864f613b392685310d85216beb70c9bf625f19f929af4def53b.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From a11a93ec9f2b43688e659c665017ad9e91fc9fcc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 10:41:50 +0000 Subject: [PATCH 091/532] feat(api): OpenAPI spec update via Stainless API (#572) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e1cbe685c93..19b959aea4e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a370326545e1864f613b392685310d85216beb70c9bf625f19f929af4def53b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-82a7004b51d1761f2cb3a5aaae83f56af924ab0c26564cfe294ad55734adf373.yml From d2862a919e495e47666a1a2f1aaca83f5a9bbe24 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 12:52:54 +0000 Subject: [PATCH 092/532] feat(api): OpenAPI spec update via Stainless API (#573) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 19b959aea4e..d9059b75831 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-82a7004b51d1761f2cb3a5aaae83f56af924ab0c26564cfe294ad55734adf373.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7238fca4bd92278986ecff5ad03ddd7a3e5c7a2d314fcd127d8db2bbd561a13.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From cb4ad309591bab76573c0c0f0348a16320844b0a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 15:10:49 +0000 Subject: [PATCH 093/532] feat(api): OpenAPI spec update via Stainless API (#574) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index d9059b75831..19b959aea4e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7238fca4bd92278986ecff5ad03ddd7a3e5c7a2d314fcd127d8db2bbd561a13.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-82a7004b51d1761f2cb3a5aaae83f56af924ab0c26564cfe294ad55734adf373.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From b7a9f9211d227a5864f64f072bec6636fbdf1985 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 15:13:38 +0000 Subject: [PATCH 094/532] feat(api): OpenAPI spec update via Stainless API (#575) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 19b959aea4e..f77190ce8cb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-82a7004b51d1761f2cb3a5aaae83f56af924ab0c26564cfe294ad55734adf373.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-89c1a9e0b56e471e0daa8305cfaed0fb3ef444411a6e93f115aa3de048e0cb41.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 5cc9564b59ea8049cc4bd434ac6f6d56a7cc524a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 16:54:19 +0000 Subject: [PATCH 095/532] feat(api): OpenAPI spec update via Stainless API (#576) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index f77190ce8cb..e1cbe685c93 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-89c1a9e0b56e471e0daa8305cfaed0fb3ef444411a6e93f115aa3de048e0cb41.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a370326545e1864f613b392685310d85216beb70c9bf625f19f929af4def53b.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From d268aecb0c3973b91a25151f3c2dd02c7465136f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 17:04:08 +0000 Subject: [PATCH 096/532] feat(api): OpenAPI spec update via Stainless API (#577) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index e1cbe685c93..d9059b75831 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5a370326545e1864f613b392685310d85216beb70c9bf625f19f929af4def53b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7238fca4bd92278986ecff5ad03ddd7a3e5c7a2d314fcd127d8db2bbd561a13.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From d4794b658443950f5d7feabc3f54d7bc1b3dd9a9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 17:07:43 +0000 Subject: [PATCH 097/532] feat(api): OpenAPI spec update via Stainless API (#578) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------ .../cloudforce_one/requests/priority.py | 88 ++++++------- .../cloudforce_one/requests/requests.py | 112 +++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../resources/magic_transit/connectors.py | 48 +++++-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../magic_transit/connector_edit_params.py | 3 +- .../magic_transit/connector_update_params.py | 3 +- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------ tests/api_resources/intel/test_whois.py | 18 +-- .../magic_transit/test_connectors.py | 118 +++++++++++++----- 17 files changed, 400 insertions(+), 337 deletions(-) diff --git a/.stats.yml b/.stats.yml index d9059b75831..ca2b4a1f257 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7238fca4bd92278986ecff5ad03ddd7a3e5c7a2d314fcd127d8db2bbd561a13.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4661c57253723a62858ec11879e101250e22c7702521b0aedd61e852a5d6e4e9.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/magic_transit/connectors.py b/src/cloudflare/resources/magic_transit/connectors.py index 684917dbcc3..c9c670927e4 100644 --- a/src/cloudflare/resources/magic_transit/connectors.py +++ b/src/cloudflare/resources/magic_transit/connectors.py @@ -47,7 +47,7 @@ def update( self, connector_id: str, *, - account_id: float, + account_id: str, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -64,6 +64,8 @@ def update( Replace Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -72,6 +74,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._put( @@ -99,7 +103,7 @@ def update( def list( self, *, - account_id: float, + 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, @@ -111,6 +115,8 @@ def list( List Connectors Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -119,6 +125,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/magic/connectors", page=SyncSinglePage[ConnectorListResponse], @@ -132,7 +140,7 @@ def edit( self, connector_id: str, *, - account_id: float, + account_id: str, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -149,6 +157,8 @@ def edit( Update Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -157,6 +167,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._patch( @@ -185,7 +197,7 @@ def get( self, connector_id: str, *, - account_id: float, + 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, @@ -197,6 +209,8 @@ def get( Fetch Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -205,6 +219,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( @@ -233,7 +249,7 @@ async def update( self, connector_id: str, *, - account_id: float, + account_id: str, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -250,6 +266,8 @@ async def update( Replace Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -258,6 +276,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._put( @@ -285,7 +305,7 @@ async def update( def list( self, *, - account_id: float, + 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, @@ -297,6 +317,8 @@ def list( List Connectors Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -305,6 +327,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/magic/connectors", page=AsyncSinglePage[ConnectorListResponse], @@ -318,7 +342,7 @@ async def edit( self, connector_id: str, *, - account_id: float, + account_id: str, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -335,6 +359,8 @@ async def edit( Update Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -343,6 +369,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._patch( @@ -371,7 +399,7 @@ async def get( self, connector_id: str, *, - account_id: float, + 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, @@ -383,6 +411,8 @@ async def get( Fetch Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -391,6 +421,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/magic_transit/connector_edit_params.py b/src/cloudflare/types/magic_transit/connector_edit_params.py index 1dc36abdc0f..da638c4e8a3 100644 --- a/src/cloudflare/types/magic_transit/connector_edit_params.py +++ b/src/cloudflare/types/magic_transit/connector_edit_params.py @@ -8,7 +8,8 @@ class ConnectorEditParams(TypedDict, total=False): - account_id: Required[float] + account_id: Required[str] + """Account identifier""" activated: bool diff --git a/src/cloudflare/types/magic_transit/connector_update_params.py b/src/cloudflare/types/magic_transit/connector_update_params.py index f70f4a4dda8..bce1d58116e 100644 --- a/src/cloudflare/types/magic_transit/connector_update_params.py +++ b/src/cloudflare/types/magic_transit/connector_update_params.py @@ -8,7 +8,8 @@ class ConnectorUpdateParams(TypedDict, total=False): - account_id: Required[float] + account_id: Required[str] + """Account identifier""" activated: bool diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/magic_transit/test_connectors.py b/tests/api_resources/magic_transit/test_connectors.py index 45dcd465181..b2e77874a82 100644 --- a/tests/api_resources/magic_transit/test_connectors.py +++ b/tests/api_resources/magic_transit/test_connectors.py @@ -27,7 +27,7 @@ class TestConnectors: def test_method_update(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) @@ -35,7 +35,7 @@ def test_method_update(self, client: Cloudflare) -> None: def test_method_update_with_all_params(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -48,7 +48,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_update(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -60,7 +60,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: def test_streaming_response_update(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -72,23 +72,29 @@ 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.magic_transit.connectors.with_raw_response.update( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.update( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize def test_method_list(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(SyncSinglePage[ConnectorListResponse], connector, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -99,7 +105,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -109,11 +115,18 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: 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.magic_transit.connectors.with_raw_response.list( + account_id="", + ) + @parametrize def test_method_edit(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorEditResponse, connector, path=["response"]) @@ -121,7 +134,7 @@ def test_method_edit(self, client: Cloudflare) -> None: def test_method_edit_with_all_params(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -134,7 +147,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_edit(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -146,7 +159,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: def test_streaming_response_edit(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -158,17 +171,23 @@ 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.magic_transit.connectors.with_raw_response.edit( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.edit( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize def test_method_get(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorGetResponse, connector, path=["response"]) @@ -176,7 +195,7 @@ def test_method_get(self, client: Cloudflare) -> None: def test_raw_response_get(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -188,7 +207,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: def test_streaming_response_get(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -200,10 +219,16 @@ 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.magic_transit.connectors.with_raw_response.get( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.get( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -214,7 +239,7 @@ class TestAsyncConnectors: async def test_method_update(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) @@ -222,7 +247,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -235,7 +260,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -247,7 +272,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -259,23 +284,29 @@ 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.magic_transit.connectors.with_raw_response.update( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.update( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(AsyncSinglePage[ConnectorListResponse], connector, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -286,7 +317,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -296,11 +327,18 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N 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.magic_transit.connectors.with_raw_response.list( + account_id="", + ) + @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorEditResponse, connector, path=["response"]) @@ -308,7 +346,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -321,7 +359,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -333,7 +371,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -345,17 +383,23 @@ 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.magic_transit.connectors.with_raw_response.edit( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.edit( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorGetResponse, connector, path=["response"]) @@ -363,7 +407,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -375,7 +419,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -387,8 +431,14 @@ 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.magic_transit.connectors.with_raw_response.get( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.get( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) From 29dbf51f934b1d98ea159bf43a06cf392a31ac40 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 17:10:19 +0000 Subject: [PATCH 098/532] feat(api): OpenAPI spec update via Stainless API (#579) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 ++++++----- .../cloudforce_one/requests/priority.py | 88 +++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++------- src/cloudflare/resources/intel/whois.py | 14 +-- .../resources/magic_transit/connectors.py | 48 ++----- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../magic_transit/connector_edit_params.py | 3 +- .../magic_transit/connector_update_params.py | 3 +- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------ tests/api_resources/intel/test_whois.py | 18 +-- .../magic_transit/test_connectors.py | 118 +++++------------- 17 files changed, 337 insertions(+), 400 deletions(-) diff --git a/.stats.yml b/.stats.yml index ca2b4a1f257..d9059b75831 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4661c57253723a62858ec11879e101250e22c7702521b0aedd61e852a5d6e4e9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7238fca4bd92278986ecff5ad03ddd7a3e5c7a2d314fcd127d8db2bbd561a13.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/magic_transit/connectors.py b/src/cloudflare/resources/magic_transit/connectors.py index c9c670927e4..684917dbcc3 100644 --- a/src/cloudflare/resources/magic_transit/connectors.py +++ b/src/cloudflare/resources/magic_transit/connectors.py @@ -47,7 +47,7 @@ def update( self, connector_id: str, *, - account_id: str, + account_id: float, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -64,8 +64,6 @@ def update( Replace Connector Args: - account_id: Account identifier - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -74,8 +72,6 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._put( @@ -103,7 +99,7 @@ def update( def list( self, *, - account_id: str, + account_id: float, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -115,8 +111,6 @@ def list( List Connectors Args: - account_id: Account identifier - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -125,8 +119,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/magic/connectors", page=SyncSinglePage[ConnectorListResponse], @@ -140,7 +132,7 @@ def edit( self, connector_id: str, *, - account_id: str, + account_id: float, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -157,8 +149,6 @@ def edit( Update Connector Args: - account_id: Account identifier - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -167,8 +157,6 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._patch( @@ -197,7 +185,7 @@ def get( self, connector_id: str, *, - account_id: str, + account_id: float, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -209,8 +197,6 @@ def get( Fetch Connector Args: - account_id: Account identifier - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -219,8 +205,6 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( @@ -249,7 +233,7 @@ async def update( self, connector_id: str, *, - account_id: str, + account_id: float, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -266,8 +250,6 @@ async def update( Replace Connector Args: - account_id: Account identifier - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -276,8 +258,6 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._put( @@ -305,7 +285,7 @@ async def update( def list( self, *, - account_id: str, + account_id: float, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -317,8 +297,6 @@ def list( List Connectors Args: - account_id: Account identifier - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -327,8 +305,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/magic/connectors", page=AsyncSinglePage[ConnectorListResponse], @@ -342,7 +318,7 @@ async def edit( self, connector_id: str, *, - account_id: str, + account_id: float, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -359,8 +335,6 @@ async def edit( Update Connector Args: - account_id: Account identifier - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -369,8 +343,6 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._patch( @@ -399,7 +371,7 @@ async def get( self, connector_id: str, *, - account_id: str, + account_id: float, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -411,8 +383,6 @@ async def get( Fetch Connector Args: - account_id: Account identifier - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -421,8 +391,6 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/magic_transit/connector_edit_params.py b/src/cloudflare/types/magic_transit/connector_edit_params.py index da638c4e8a3..1dc36abdc0f 100644 --- a/src/cloudflare/types/magic_transit/connector_edit_params.py +++ b/src/cloudflare/types/magic_transit/connector_edit_params.py @@ -8,8 +8,7 @@ class ConnectorEditParams(TypedDict, total=False): - account_id: Required[str] - """Account identifier""" + account_id: Required[float] activated: bool diff --git a/src/cloudflare/types/magic_transit/connector_update_params.py b/src/cloudflare/types/magic_transit/connector_update_params.py index bce1d58116e..f70f4a4dda8 100644 --- a/src/cloudflare/types/magic_transit/connector_update_params.py +++ b/src/cloudflare/types/magic_transit/connector_update_params.py @@ -8,8 +8,7 @@ class ConnectorUpdateParams(TypedDict, total=False): - account_id: Required[str] - """Account identifier""" + account_id: Required[float] activated: bool diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/magic_transit/test_connectors.py b/tests/api_resources/magic_transit/test_connectors.py index b2e77874a82..45dcd465181 100644 --- a/tests/api_resources/magic_transit/test_connectors.py +++ b/tests/api_resources/magic_transit/test_connectors.py @@ -27,7 +27,7 @@ class TestConnectors: def test_method_update(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.update( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) @@ -35,7 +35,7 @@ def test_method_update(self, client: Cloudflare) -> None: def test_method_update_with_all_params(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.update( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -48,7 +48,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_update(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.update( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert response.is_closed is True @@ -60,7 +60,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: def test_streaming_response_update(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.update( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -72,29 +72,23 @@ 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.magic_transit.connectors.with_raw_response.update( - "string", - account_id="", - ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.update( "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) @parametrize def test_method_list(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert_matches_type(SyncSinglePage[ConnectorListResponse], connector, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert response.is_closed is True @@ -105,7 +99,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -115,18 +109,11 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: 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.magic_transit.connectors.with_raw_response.list( - account_id="", - ) - @parametrize def test_method_edit(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.edit( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert_matches_type(ConnectorEditResponse, connector, path=["response"]) @@ -134,7 +121,7 @@ def test_method_edit(self, client: Cloudflare) -> None: def test_method_edit_with_all_params(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.edit( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -147,7 +134,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_edit(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.edit( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert response.is_closed is True @@ -159,7 +146,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: def test_streaming_response_edit(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.edit( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -171,23 +158,17 @@ 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.magic_transit.connectors.with_raw_response.edit( - "string", - account_id="", - ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.edit( "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) @parametrize def test_method_get(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.get( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert_matches_type(ConnectorGetResponse, connector, path=["response"]) @@ -195,7 +176,7 @@ def test_method_get(self, client: Cloudflare) -> None: def test_raw_response_get(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.get( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert response.is_closed is True @@ -207,7 +188,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: def test_streaming_response_get(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.get( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -219,16 +200,10 @@ 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.magic_transit.connectors.with_raw_response.get( - "string", - account_id="", - ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.get( "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) @@ -239,7 +214,7 @@ class TestAsyncConnectors: async def test_method_update(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.update( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) @@ -247,7 +222,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.update( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -260,7 +235,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.update( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert response.is_closed is True @@ -272,7 +247,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.update( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -284,29 +259,23 @@ 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.magic_transit.connectors.with_raw_response.update( - "string", - account_id="", - ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.update( "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert_matches_type(AsyncSinglePage[ConnectorListResponse], connector, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert response.is_closed is True @@ -317,7 +286,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -327,18 +296,11 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N 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.magic_transit.connectors.with_raw_response.list( - account_id="", - ) - @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.edit( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert_matches_type(ConnectorEditResponse, connector, path=["response"]) @@ -346,7 +308,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.edit( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -359,7 +321,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.edit( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert response.is_closed is True @@ -371,7 +333,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.edit( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -383,23 +345,17 @@ 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.magic_transit.connectors.with_raw_response.edit( - "string", - account_id="", - ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.edit( "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.get( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert_matches_type(ConnectorGetResponse, connector, path=["response"]) @@ -407,7 +363,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.get( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) assert response.is_closed is True @@ -419,7 +375,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.get( "string", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -431,14 +387,8 @@ 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.magic_transit.connectors.with_raw_response.get( - "string", - account_id="", - ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.get( "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id=0, ) From 1f9c6213e90dfed8563956ea822a6e562c8c493e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 17:43:49 +0000 Subject: [PATCH 099/532] feat(api): OpenAPI spec update via Stainless API (#580) --- .stats.yml | 2 +- .../resources/magic_transit/connectors.py | 48 +++++-- .../magic_transit/connector_edit_params.py | 3 +- .../magic_transit/connector_update_params.py | 3 +- .../magic_transit/test_connectors.py | 118 +++++++++++++----- 5 files changed, 129 insertions(+), 45 deletions(-) diff --git a/.stats.yml b/.stats.yml index d9059b75831..c5ea5638682 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7238fca4bd92278986ecff5ad03ddd7a3e5c7a2d314fcd127d8db2bbd561a13.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5bbc085920edd5cffb5cccbc08ab3b94fcc458321144eb01c80c05a089fafafa.yml diff --git a/src/cloudflare/resources/magic_transit/connectors.py b/src/cloudflare/resources/magic_transit/connectors.py index 684917dbcc3..c9c670927e4 100644 --- a/src/cloudflare/resources/magic_transit/connectors.py +++ b/src/cloudflare/resources/magic_transit/connectors.py @@ -47,7 +47,7 @@ def update( self, connector_id: str, *, - account_id: float, + account_id: str, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -64,6 +64,8 @@ def update( Replace Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -72,6 +74,8 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._put( @@ -99,7 +103,7 @@ def update( def list( self, *, - account_id: float, + 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, @@ -111,6 +115,8 @@ def list( List Connectors Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -119,6 +125,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/magic/connectors", page=SyncSinglePage[ConnectorListResponse], @@ -132,7 +140,7 @@ def edit( self, connector_id: str, *, - account_id: float, + account_id: str, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -149,6 +157,8 @@ def edit( Update Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -157,6 +167,8 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._patch( @@ -185,7 +197,7 @@ def get( self, connector_id: str, *, - account_id: float, + 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, @@ -197,6 +209,8 @@ def get( Fetch Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -205,6 +219,8 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return self._get( @@ -233,7 +249,7 @@ async def update( self, connector_id: str, *, - account_id: float, + account_id: str, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -250,6 +266,8 @@ async def update( Replace Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -258,6 +276,8 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._put( @@ -285,7 +305,7 @@ async def update( def list( self, *, - account_id: float, + 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, @@ -297,6 +317,8 @@ def list( List Connectors Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -305,6 +327,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/magic/connectors", page=AsyncSinglePage[ConnectorListResponse], @@ -318,7 +342,7 @@ async def edit( self, connector_id: str, *, - account_id: float, + account_id: str, activated: bool | NotGiven = NOT_GIVEN, interrupt_window_duration_hours: float | NotGiven = NOT_GIVEN, interrupt_window_hour_of_day: float | NotGiven = NOT_GIVEN, @@ -335,6 +359,8 @@ async def edit( Update Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -343,6 +369,8 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._patch( @@ -371,7 +399,7 @@ async def get( self, connector_id: str, *, - account_id: float, + 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, @@ -383,6 +411,8 @@ async def get( Fetch Connector Args: + account_id: Account identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -391,6 +421,8 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not connector_id: raise ValueError(f"Expected a non-empty value for `connector_id` but received {connector_id!r}") return await self._get( diff --git a/src/cloudflare/types/magic_transit/connector_edit_params.py b/src/cloudflare/types/magic_transit/connector_edit_params.py index 1dc36abdc0f..da638c4e8a3 100644 --- a/src/cloudflare/types/magic_transit/connector_edit_params.py +++ b/src/cloudflare/types/magic_transit/connector_edit_params.py @@ -8,7 +8,8 @@ class ConnectorEditParams(TypedDict, total=False): - account_id: Required[float] + account_id: Required[str] + """Account identifier""" activated: bool diff --git a/src/cloudflare/types/magic_transit/connector_update_params.py b/src/cloudflare/types/magic_transit/connector_update_params.py index f70f4a4dda8..bce1d58116e 100644 --- a/src/cloudflare/types/magic_transit/connector_update_params.py +++ b/src/cloudflare/types/magic_transit/connector_update_params.py @@ -8,7 +8,8 @@ class ConnectorUpdateParams(TypedDict, total=False): - account_id: Required[float] + account_id: Required[str] + """Account identifier""" activated: bool diff --git a/tests/api_resources/magic_transit/test_connectors.py b/tests/api_resources/magic_transit/test_connectors.py index 45dcd465181..b2e77874a82 100644 --- a/tests/api_resources/magic_transit/test_connectors.py +++ b/tests/api_resources/magic_transit/test_connectors.py @@ -27,7 +27,7 @@ class TestConnectors: def test_method_update(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) @@ -35,7 +35,7 @@ def test_method_update(self, client: Cloudflare) -> None: def test_method_update_with_all_params(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -48,7 +48,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_update(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -60,7 +60,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: def test_streaming_response_update(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -72,23 +72,29 @@ 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.magic_transit.connectors.with_raw_response.update( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.update( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize def test_method_list(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(SyncSinglePage[ConnectorListResponse], connector, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -99,7 +105,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -109,11 +115,18 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: 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.magic_transit.connectors.with_raw_response.list( + account_id="", + ) + @parametrize def test_method_edit(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorEditResponse, connector, path=["response"]) @@ -121,7 +134,7 @@ def test_method_edit(self, client: Cloudflare) -> None: def test_method_edit_with_all_params(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -134,7 +147,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_edit(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -146,7 +159,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: def test_streaming_response_edit(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -158,17 +171,23 @@ 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.magic_transit.connectors.with_raw_response.edit( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.edit( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize def test_method_get(self, client: Cloudflare) -> None: connector = client.magic_transit.connectors.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorGetResponse, connector, path=["response"]) @@ -176,7 +195,7 @@ def test_method_get(self, client: Cloudflare) -> None: def test_raw_response_get(self, client: Cloudflare) -> None: response = client.magic_transit.connectors.with_raw_response.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -188,7 +207,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: def test_streaming_response_get(self, client: Cloudflare) -> None: with client.magic_transit.connectors.with_streaming_response.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -200,10 +219,16 @@ 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.magic_transit.connectors.with_raw_response.get( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): client.magic_transit.connectors.with_raw_response.get( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -214,7 +239,7 @@ class TestAsyncConnectors: async def test_method_update(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorUpdateResponse, connector, path=["response"]) @@ -222,7 +247,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -235,7 +260,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -247,7 +272,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.update( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -259,23 +284,29 @@ 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.magic_transit.connectors.with_raw_response.update( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.update( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(AsyncSinglePage[ConnectorListResponse], connector, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -286,7 +317,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.list( - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -296,11 +327,18 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N 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.magic_transit.connectors.with_raw_response.list( + account_id="", + ) + @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorEditResponse, connector, path=["response"]) @@ -308,7 +346,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, interrupt_window_duration_hours=0, interrupt_window_hour_of_day=0, @@ -321,7 +359,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -333,7 +371,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.edit( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -345,17 +383,23 @@ 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.magic_transit.connectors.with_raw_response.edit( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.edit( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: connector = await async_client.magic_transit.connectors.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(ConnectorGetResponse, connector, path=["response"]) @@ -363,7 +407,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.connectors.with_raw_response.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -375,7 +419,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.connectors.with_streaming_response.get( "string", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -387,8 +431,14 @@ 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.magic_transit.connectors.with_raw_response.get( + "string", + account_id="", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `connector_id` but received ''"): await async_client.magic_transit.connectors.with_raw_response.get( "", - account_id=0, + account_id="023e105f4ecef8ad9ca31a8372d0c353", ) From 722b132222405cdcdcdcaa3f4624e70b29908c7b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 17:46:14 +0000 Subject: [PATCH 100/532] feat(api): OpenAPI spec update via Stainless API (#581) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index c5ea5638682..30e0514e7c3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5bbc085920edd5cffb5cccbc08ab3b94fcc458321144eb01c80c05a089fafafa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-482840aef1f8d1525507e2ef2bc5ec68a6eb3c7eb4c089800265c12ef99121a0.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From ad4b172d0e71144df1a313877b8f6bdc79a5e7dc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 18:14:47 +0000 Subject: [PATCH 101/532] feat(api): OpenAPI spec update via Stainless API (#582) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 30e0514e7c3..3995c2b5d34 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-482840aef1f8d1525507e2ef2bc5ec68a6eb3c7eb4c089800265c12ef99121a0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a470d9dc8fe965453aeed7fadf059de2e53e1b303e741cd0986e6bddf1fb2afc.yml From 239fe24b701e35a56d8abf355c0a29dc10faa0ad Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 18:57:16 +0000 Subject: [PATCH 102/532] feat(api): OpenAPI spec update via Stainless API (#583) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3995c2b5d34..30e0514e7c3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a470d9dc8fe965453aeed7fadf059de2e53e1b303e741cd0986e6bddf1fb2afc.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-482840aef1f8d1525507e2ef2bc5ec68a6eb3c7eb4c089800265c12ef99121a0.yml From 9b55a931254bd07551969b6ebf51fbebc1b87cdd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 20:00:09 +0000 Subject: [PATCH 103/532] feat(api): OpenAPI spec update via Stainless API (#584) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 30e0514e7c3..3995c2b5d34 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-482840aef1f8d1525507e2ef2bc5ec68a6eb3c7eb4c089800265c12ef99121a0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a470d9dc8fe965453aeed7fadf059de2e53e1b303e741cd0986e6bddf1fb2afc.yml From 8a7795b7f09f58afa2058ae581f34d99cd898369 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 09:01:29 +0000 Subject: [PATCH 104/532] feat(api): OpenAPI spec update via Stainless API (#585) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3995c2b5d34..30e0514e7c3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a470d9dc8fe965453aeed7fadf059de2e53e1b303e741cd0986e6bddf1fb2afc.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-482840aef1f8d1525507e2ef2bc5ec68a6eb3c7eb4c089800265c12ef99121a0.yml From 552a7fb63ce8848c451002b6c38c14a68872c642 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 09:04:12 +0000 Subject: [PATCH 105/532] feat(api): OpenAPI spec update via Stainless API (#586) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 30e0514e7c3..3995c2b5d34 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-482840aef1f8d1525507e2ef2bc5ec68a6eb3c7eb4c089800265c12ef99121a0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a470d9dc8fe965453aeed7fadf059de2e53e1b303e741cd0986e6bddf1fb2afc.yml From 710e80225e97ef947f22cf9524b8d90999ac41fa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 09:49:49 +0000 Subject: [PATCH 106/532] feat(api): OpenAPI spec update via Stainless API (#587) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3995c2b5d34..c5ea5638682 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a470d9dc8fe965453aeed7fadf059de2e53e1b303e741cd0986e6bddf1fb2afc.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5bbc085920edd5cffb5cccbc08ab3b94fcc458321144eb01c80c05a089fafafa.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From b7f5f304ebfa5359744929aac38e88f8b66752bb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 10:58:46 +0000 Subject: [PATCH 107/532] feat(api): OpenAPI spec update via Stainless API (#588) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index c5ea5638682..30e0514e7c3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5bbc085920edd5cffb5cccbc08ab3b94fcc458321144eb01c80c05a089fafafa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-482840aef1f8d1525507e2ef2bc5ec68a6eb3c7eb4c089800265c12ef99121a0.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From e2c61a76fd05df1ef3fa30cbf03119b9d0c9529b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 13:17:07 +0000 Subject: [PATCH 108/532] feat(api): OpenAPI spec update via Stainless API (#589) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 30e0514e7c3..cc4466d7bd5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-482840aef1f8d1525507e2ef2bc5ec68a6eb3c7eb4c089800265c12ef99121a0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ae9c24759a71468298d37ae7aa05d4b1162e756e77597ba8fcd49c7ea2b4ac6b.yml From 58275c6b5839762add0ade113bb8d6b93a6fb990 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 14:42:03 +0000 Subject: [PATCH 109/532] feat(api): OpenAPI spec update via Stainless API (#590) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index cc4466d7bd5..747553e18c0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ae9c24759a71468298d37ae7aa05d4b1162e756e77597ba8fcd49c7ea2b4ac6b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2182de20fb3bd47b4dca83f00f0dd21dcfc8b8c2d24ad81b9751011a4d94765d.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From fae0b85a48e8e82144e06c0ff5172fc2faf59edf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 15:06:36 +0000 Subject: [PATCH 110/532] feat(api): OpenAPI spec update via Stainless API (#591) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 747553e18c0..cc4466d7bd5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2182de20fb3bd47b4dca83f00f0dd21dcfc8b8c2d24ad81b9751011a4d94765d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ae9c24759a71468298d37ae7aa05d4b1162e756e77597ba8fcd49c7ea2b4ac6b.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From f0c7070cb9fe3efbc4e7b66439ab2cb47e08f39e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 15:27:44 +0000 Subject: [PATCH 111/532] feat(api): OpenAPI spec update via Stainless API (#592) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index cc4466d7bd5..747553e18c0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ae9c24759a71468298d37ae7aa05d4b1162e756e77597ba8fcd49c7ea2b4ac6b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2182de20fb3bd47b4dca83f00f0dd21dcfc8b8c2d24ad81b9751011a4d94765d.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 92595595c58f0fea3e1fa6790a363e359a9b2ba3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 17:03:22 +0000 Subject: [PATCH 112/532] feat(api): update via SDK Studio (#593) --- .../zero_trust/risk_scoring/test_integrations.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/api_resources/zero_trust/risk_scoring/test_integrations.py b/tests/api_resources/zero_trust/risk_scoring/test_integrations.py index 2ff5a9ecbc8..c6fa43d9486 100644 --- a/tests/api_resources/zero_trust/risk_scoring/test_integrations.py +++ b/tests/api_resources/zero_trust/risk_scoring/test_integrations.py @@ -148,6 +148,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: tenant_url="https://example.com", ) + @pytest.mark.skip(reason="bug in prism where it confuses this method with /zt_risk_scoring/{user_id}") @parametrize def test_method_list(self, client: Cloudflare) -> None: integration = client.zero_trust.risk_scoring.integrations.list( @@ -155,6 +156,7 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(SyncSinglePage[IntegrationListResponse], integration, path=["response"]) + @pytest.mark.skip(reason="bug in prism where it confuses this method with /zt_risk_scoring/{user_id}") @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.risk_scoring.integrations.with_raw_response.list( @@ -166,6 +168,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: integration = response.parse() assert_matches_type(SyncSinglePage[IntegrationListResponse], integration, path=["response"]) + @pytest.mark.skip(reason="bug in prism where it confuses this method with /zt_risk_scoring/{user_id}") @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.zero_trust.risk_scoring.integrations.with_streaming_response.list( @@ -179,6 +182,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="bug in prism where it confuses this method with /zt_risk_scoring/{user_id}") @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 ''"): @@ -411,6 +415,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: tenant_url="https://example.com", ) + @pytest.mark.skip(reason="bug in prism where it confuses this method with /zt_risk_scoring/{user_id}") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: integration = await async_client.zero_trust.risk_scoring.integrations.list( @@ -418,6 +423,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(AsyncSinglePage[IntegrationListResponse], integration, path=["response"]) + @pytest.mark.skip(reason="bug in prism where it confuses this method with /zt_risk_scoring/{user_id}") @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.risk_scoring.integrations.with_raw_response.list( @@ -429,6 +435,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: integration = await response.parse() assert_matches_type(AsyncSinglePage[IntegrationListResponse], integration, path=["response"]) + @pytest.mark.skip(reason="bug in prism where it confuses this method with /zt_risk_scoring/{user_id}") @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.risk_scoring.integrations.with_streaming_response.list( @@ -442,6 +449,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="bug in prism where it confuses this method with /zt_risk_scoring/{user_id}") @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 ''"): From 39c7682d9df9edb2f51b781c889cdf68436b4a51 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 17:05:55 +0000 Subject: [PATCH 113/532] feat(api): OpenAPI spec update via Stainless API (#594) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 747553e18c0..07056c3f904 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2182de20fb3bd47b4dca83f00f0dd21dcfc8b8c2d24ad81b9751011a4d94765d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b588da95601959bbe0269351d4f052408c11ecc10775f706606f58d33b570178.yml From 1029c076a8ddeeb77e67a5186270c5fd0ebf681a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 19:16:25 +0000 Subject: [PATCH 114/532] feat(api): OpenAPI spec update via Stainless API (#595) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 07056c3f904..6c10e0de57e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b588da95601959bbe0269351d4f052408c11ecc10775f706606f58d33b570178.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4693e2d401ae311fed0316cb1863e37dcaeb53a2ddf07371f8fa36c37e6e0057.yml From 54a316c4c55b81f33e72b700c6f91978db505c57 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 19:18:55 +0000 Subject: [PATCH 115/532] feat(api): OpenAPI spec update via Stainless API (#596) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6c10e0de57e..50fc14c2b9d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4693e2d401ae311fed0316cb1863e37dcaeb53a2ddf07371f8fa36c37e6e0057.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e43f1520a2b2216bc7dc46e06afd92de46884e56eceec212ea8b54bd99013ff3.yml From a54717e10c94bf4a7d50fd2577ac6732621c3500 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 19:23:27 +0000 Subject: [PATCH 116/532] feat(api): OpenAPI spec update via Stainless API (#597) --- .stats.yml | 2 +- .../resources/magic_transit/sites/acls.py | 24 +++++++------- .../resources/magic_transit/sites/lans.py | 32 +++++++++---------- .../resources/magic_transit/sites/sites.py | 24 +++++++------- .../resources/magic_transit/sites/wans.py | 24 +++++++------- src/cloudflare/types/magic_transit/site.py | 4 +-- .../types/magic_transit/site_create_params.py | 4 +-- .../types/magic_transit/site_edit_params.py | 4 +-- .../types/magic_transit/site_update_params.py | 4 +-- .../types/magic_transit/sites/acl.py | 4 +-- .../magic_transit/sites/acl_create_params.py | 4 +-- .../magic_transit/sites/acl_edit_params.py | 4 +-- .../magic_transit/sites/acl_update_params.py | 4 +-- 13 files changed, 69 insertions(+), 69 deletions(-) diff --git a/.stats.yml b/.stats.yml index 50fc14c2b9d..6779bc250e9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e43f1520a2b2216bc7dc46e06afd92de46884e56eceec212ea8b54bd99013ff3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0c0d163e334ea4aceb9155a993fcb36ab5edcb6de64052f81f3c9df94e0ef4b7.yml diff --git a/src/cloudflare/resources/magic_transit/sites/acls.py b/src/cloudflare/resources/magic_transit/sites/acls.py index 6a4b41711fb..8c6e537f60b 100644 --- a/src/cloudflare/resources/magic_transit/sites/acls.py +++ b/src/cloudflare/resources/magic_transit/sites/acls.py @@ -74,8 +74,8 @@ def create( forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward - traffic locally on the Magic WAN Connector. If not included in request, will - default to false. + traffic locally on the Magic Connector. If not included in request, will default + to false. extra_headers: Send extra headers @@ -145,8 +145,8 @@ def update( forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward - traffic locally on the Magic WAN Connector. If not included in request, will - default to false. + traffic locally on the Magic Connector. If not included in request, will default + to false. name: The name of the ACL. @@ -310,8 +310,8 @@ def edit( forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward - traffic locally on the Magic WAN Connector. If not included in request, will - default to false. + traffic locally on the Magic Connector. If not included in request, will default + to false. name: The name of the ACL. @@ -443,8 +443,8 @@ async def create( forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward - traffic locally on the Magic WAN Connector. If not included in request, will - default to false. + traffic locally on the Magic Connector. If not included in request, will default + to false. extra_headers: Send extra headers @@ -514,8 +514,8 @@ async def update( forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward - traffic locally on the Magic WAN Connector. If not included in request, will - default to false. + traffic locally on the Magic Connector. If not included in request, will default + to false. name: The name of the ACL. @@ -679,8 +679,8 @@ async def edit( forward_locally: The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to "true", the policy will forward - traffic locally on the Magic WAN Connector. If not included in request, will - default to false. + traffic locally on the Magic Connector. If not included in request, will default + to false. name: The name of the ACL. diff --git a/src/cloudflare/resources/magic_transit/sites/lans.py b/src/cloudflare/resources/magic_transit/sites/lans.py index 0bba7a450df..307bdcffc9b 100644 --- a/src/cloudflare/resources/magic_transit/sites/lans.py +++ b/src/cloudflare/resources/magic_transit/sites/lans.py @@ -67,10 +67,10 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LANCreateResponse: - """Creates a new LAN. + """Creates a new Site LAN. - If the site is in high availability mode, static_addressing - is required along with secondary and virtual address. + If the site is in high availability mode, + static_addressing is required along with secondary and virtual address. Args: account_id: Identifier @@ -142,7 +142,7 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LAN: """ - Update a specific LAN. + Update a specific Site LAN. Args: account_id: Identifier @@ -207,7 +207,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> SyncSinglePage[LAN]: """ - Lists LANs associated with an account and site. + Lists Site LANs associated with an account. Args: account_id: Identifier @@ -249,7 +249,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LAN: """ - Remove a specific LAN. + Remove a specific Site LAN. Args: account_id: Identifier @@ -304,7 +304,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LAN: """ - Patch a specific LAN. + Patch a specific Site LAN. Args: account_id: Identifier @@ -370,7 +370,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LAN: """ - Get a specific LAN. + Get a specific Site LAN. Args: account_id: Identifier @@ -434,10 +434,10 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LANCreateResponse: - """Creates a new LAN. + """Creates a new Site LAN. - If the site is in high availability mode, static_addressing - is required along with secondary and virtual address. + If the site is in high availability mode, + static_addressing is required along with secondary and virtual address. Args: account_id: Identifier @@ -509,7 +509,7 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LAN: """ - Update a specific LAN. + Update a specific Site LAN. Args: account_id: Identifier @@ -574,7 +574,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AsyncPaginator[LAN, AsyncSinglePage[LAN]]: """ - Lists LANs associated with an account and site. + Lists Site LANs associated with an account. Args: account_id: Identifier @@ -616,7 +616,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LAN: """ - Remove a specific LAN. + Remove a specific Site LAN. Args: account_id: Identifier @@ -671,7 +671,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LAN: """ - Patch a specific LAN. + Patch a specific Site LAN. Args: account_id: Identifier @@ -737,7 +737,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> LAN: """ - Get a specific LAN. + Get a specific Site LAN. Args: account_id: Identifier diff --git a/src/cloudflare/resources/magic_transit/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites.py index 6dd3b97bf65..67c24a85c6f 100644 --- a/src/cloudflare/resources/magic_transit/sites/sites.py +++ b/src/cloudflare/resources/magic_transit/sites/sites.py @@ -107,14 +107,14 @@ def create( name: The name of the site. - connector_id: Magic WAN Connector identifier tag. + connector_id: Magic Connector identifier tag. ha_mode: Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. location: Location of site in latitude and longitude. - secondary_connector_id: Magic WAN Connector identifier tag. Used when high availability mode is on. + secondary_connector_id: Magic Connector identifier tag. Used when high availability mode is on. extra_headers: Send extra headers @@ -174,13 +174,13 @@ def update( site_id: Identifier - connector_id: Magic WAN Connector identifier tag. + connector_id: Magic Connector identifier tag. location: Location of site in latitude and longitude. name: The name of the site. - secondary_connector_id: Magic WAN Connector identifier tag. Used when high availability mode is on. + secondary_connector_id: Magic Connector identifier tag. Used when high availability mode is on. extra_headers: Send extra headers @@ -331,13 +331,13 @@ def edit( site_id: Identifier - connector_id: Magic WAN Connector identifier tag. + connector_id: Magic Connector identifier tag. location: Location of site in latitude and longitude. name: The name of the site. - secondary_connector_id: Magic WAN Connector identifier tag. Used when high availability mode is on. + secondary_connector_id: Magic Connector identifier tag. Used when high availability mode is on. extra_headers: Send extra headers @@ -464,14 +464,14 @@ async def create( name: The name of the site. - connector_id: Magic WAN Connector identifier tag. + connector_id: Magic Connector identifier tag. ha_mode: Site high availability mode. If set to true, the site can have two connectors and runs in high availability mode. location: Location of site in latitude and longitude. - secondary_connector_id: Magic WAN Connector identifier tag. Used when high availability mode is on. + secondary_connector_id: Magic Connector identifier tag. Used when high availability mode is on. extra_headers: Send extra headers @@ -531,13 +531,13 @@ async def update( site_id: Identifier - connector_id: Magic WAN Connector identifier tag. + connector_id: Magic Connector identifier tag. location: Location of site in latitude and longitude. name: The name of the site. - secondary_connector_id: Magic WAN Connector identifier tag. Used when high availability mode is on. + secondary_connector_id: Magic Connector identifier tag. Used when high availability mode is on. extra_headers: Send extra headers @@ -688,13 +688,13 @@ async def edit( site_id: Identifier - connector_id: Magic WAN Connector identifier tag. + connector_id: Magic Connector identifier tag. location: Location of site in latitude and longitude. name: The name of the site. - secondary_connector_id: Magic WAN Connector identifier tag. Used when high availability mode is on. + secondary_connector_id: Magic Connector identifier tag. Used when high availability mode is on. extra_headers: Send extra headers diff --git a/src/cloudflare/resources/magic_transit/sites/wans.py b/src/cloudflare/resources/magic_transit/sites/wans.py index f11fa4ee520..90cba1d7d90 100644 --- a/src/cloudflare/resources/magic_transit/sites/wans.py +++ b/src/cloudflare/resources/magic_transit/sites/wans.py @@ -60,7 +60,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WANCreateResponse: """ - Creates a new WAN. + Creates a new Site WAN. Args: account_id: Identifier @@ -125,7 +125,7 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WAN: """ - Update a specific WAN. + Update a specific Site WAN. Args: account_id: Identifier @@ -188,7 +188,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> SyncSinglePage[WAN]: """ - Lists WANs associated with an account and site. + Lists Site WANs associated with an account. Args: account_id: Identifier @@ -230,7 +230,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WAN: """ - Remove a specific WAN. + Remove a specific Site WAN. Args: account_id: Identifier @@ -284,7 +284,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WAN: """ - Patch a specific WAN. + Patch a specific Site WAN. Args: account_id: Identifier @@ -348,7 +348,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WAN: """ - Get a specific WAN. + Get a specific Site WAN. Args: account_id: Identifier @@ -411,7 +411,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WANCreateResponse: """ - Creates a new WAN. + Creates a new Site WAN. Args: account_id: Identifier @@ -476,7 +476,7 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WAN: """ - Update a specific WAN. + Update a specific Site WAN. Args: account_id: Identifier @@ -539,7 +539,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AsyncPaginator[WAN, AsyncSinglePage[WAN]]: """ - Lists WANs associated with an account and site. + Lists Site WANs associated with an account. Args: account_id: Identifier @@ -581,7 +581,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WAN: """ - Remove a specific WAN. + Remove a specific Site WAN. Args: account_id: Identifier @@ -635,7 +635,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WAN: """ - Patch a specific WAN. + Patch a specific Site WAN. Args: account_id: Identifier @@ -699,7 +699,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> WAN: """ - Get a specific WAN. + Get a specific Site WAN. Args: account_id: Identifier diff --git a/src/cloudflare/types/magic_transit/site.py b/src/cloudflare/types/magic_transit/site.py index 41ffe01ee98..e011ab21bbf 100644 --- a/src/cloudflare/types/magic_transit/site.py +++ b/src/cloudflare/types/magic_transit/site.py @@ -13,7 +13,7 @@ class Site(BaseModel): """Identifier""" connector_id: Optional[str] = None - """Magic WAN Connector identifier tag.""" + """Magic Connector identifier tag.""" description: Optional[str] = None @@ -31,4 +31,4 @@ class Site(BaseModel): """The name of the site.""" secondary_connector_id: Optional[str] = None - """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + """Magic Connector identifier tag. Used when high availability mode is on.""" diff --git a/src/cloudflare/types/magic_transit/site_create_params.py b/src/cloudflare/types/magic_transit/site_create_params.py index 410981caead..70a64bc5406 100644 --- a/src/cloudflare/types/magic_transit/site_create_params.py +++ b/src/cloudflare/types/magic_transit/site_create_params.py @@ -17,7 +17,7 @@ class SiteCreateParams(TypedDict, total=False): """The name of the site.""" connector_id: str - """Magic WAN Connector identifier tag.""" + """Magic Connector identifier tag.""" description: str @@ -32,4 +32,4 @@ class SiteCreateParams(TypedDict, total=False): """Location of site in latitude and longitude.""" secondary_connector_id: str - """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + """Magic Connector identifier tag. Used when high availability mode is on.""" diff --git a/src/cloudflare/types/magic_transit/site_edit_params.py b/src/cloudflare/types/magic_transit/site_edit_params.py index 606d7e66c55..eef65820c0b 100644 --- a/src/cloudflare/types/magic_transit/site_edit_params.py +++ b/src/cloudflare/types/magic_transit/site_edit_params.py @@ -14,7 +14,7 @@ class SiteEditParams(TypedDict, total=False): """Identifier""" connector_id: str - """Magic WAN Connector identifier tag.""" + """Magic Connector identifier tag.""" description: str @@ -25,4 +25,4 @@ class SiteEditParams(TypedDict, total=False): """The name of the site.""" secondary_connector_id: str - """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + """Magic Connector identifier tag. Used when high availability mode is on.""" diff --git a/src/cloudflare/types/magic_transit/site_update_params.py b/src/cloudflare/types/magic_transit/site_update_params.py index 1843cba18ff..4568612636c 100644 --- a/src/cloudflare/types/magic_transit/site_update_params.py +++ b/src/cloudflare/types/magic_transit/site_update_params.py @@ -14,7 +14,7 @@ class SiteUpdateParams(TypedDict, total=False): """Identifier""" connector_id: str - """Magic WAN Connector identifier tag.""" + """Magic Connector identifier tag.""" description: str @@ -25,4 +25,4 @@ class SiteUpdateParams(TypedDict, total=False): """The name of the site.""" secondary_connector_id: str - """Magic WAN Connector identifier tag. Used when high availability mode is on.""" + """Magic Connector identifier tag. Used when high availability mode is on.""" diff --git a/src/cloudflare/types/magic_transit/sites/acl.py b/src/cloudflare/types/magic_transit/sites/acl.py index 01bcf9e4b55..5565fc0f5c9 100644 --- a/src/cloudflare/types/magic_transit/sites/acl.py +++ b/src/cloudflare/types/magic_transit/sites/acl.py @@ -20,8 +20,8 @@ class ACL(BaseModel): """The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to - "true", the policy will forward traffic locally on the Magic WAN Connector. If - not included in request, will default to false. + "true", the policy will forward traffic locally on the Magic Connector. If not + included in request, will default to false. """ lan_1: Optional[ACLConfiguration] = None diff --git a/src/cloudflare/types/magic_transit/sites/acl_create_params.py b/src/cloudflare/types/magic_transit/sites/acl_create_params.py index 67a21900fa4..48b2d5f517b 100644 --- a/src/cloudflare/types/magic_transit/sites/acl_create_params.py +++ b/src/cloudflare/types/magic_transit/sites/acl_create_params.py @@ -29,8 +29,8 @@ class ACLCreateParams(TypedDict, total=False): """The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to - "true", the policy will forward traffic locally on the Magic WAN Connector. If - not included in request, will default to false. + "true", the policy will forward traffic locally on the Magic Connector. If not + included in request, will default to false. """ protocols: List[AllowedProtocol] diff --git a/src/cloudflare/types/magic_transit/sites/acl_edit_params.py b/src/cloudflare/types/magic_transit/sites/acl_edit_params.py index a8808b1b868..8a6c7b0f5c6 100644 --- a/src/cloudflare/types/magic_transit/sites/acl_edit_params.py +++ b/src/cloudflare/types/magic_transit/sites/acl_edit_params.py @@ -25,8 +25,8 @@ class ACLEditParams(TypedDict, total=False): """The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to - "true", the policy will forward traffic locally on the Magic WAN Connector. If - not included in request, will default to false. + "true", the policy will forward traffic locally on the Magic Connector. If not + included in request, will default to false. """ lan_1: ACLConfigurationParam diff --git a/src/cloudflare/types/magic_transit/sites/acl_update_params.py b/src/cloudflare/types/magic_transit/sites/acl_update_params.py index 72165d3c2a2..5abc70c2329 100644 --- a/src/cloudflare/types/magic_transit/sites/acl_update_params.py +++ b/src/cloudflare/types/magic_transit/sites/acl_update_params.py @@ -25,8 +25,8 @@ class ACLUpdateParams(TypedDict, total=False): """The desired forwarding action for this ACL policy. If set to "false", the policy will forward traffic to Cloudflare. If set to - "true", the policy will forward traffic locally on the Magic WAN Connector. If - not included in request, will default to false. + "true", the policy will forward traffic locally on the Magic Connector. If not + included in request, will default to false. """ lan_1: ACLConfigurationParam From 18271d286b07627f5160d2c9343f7e07bf77dc0b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 19:34:11 +0000 Subject: [PATCH 117/532] feat(api): OpenAPI spec update via Stainless API (#598) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6779bc250e9..b4149f716ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0c0d163e334ea4aceb9155a993fcb36ab5edcb6de64052f81f3c9df94e0ef4b7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a92aac1d4f64b4091bcaf32937d80b8472644ca7bba0dc719804e71425ecf067.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From a93e0f4c40ff1fd738eba6b73dfcf0d3f9e1f2f9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 20:20:48 +0000 Subject: [PATCH 118/532] feat(api): OpenAPI spec update via Stainless API (#599) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index b4149f716ff..98e89bff3ce 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a92aac1d4f64b4091bcaf32937d80b8472644ca7bba0dc719804e71425ecf067.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-870afafa5e40263ba51777cf8e8f58da3067f618dcf8b180fb2308b550a0aab6.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From ed7d9cc57dfe0bbe7d84f67baf1e7e555680733f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 20:50:24 +0000 Subject: [PATCH 119/532] feat(api): OpenAPI spec update via Stainless API (#600) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 98e89bff3ce..6779bc250e9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-870afafa5e40263ba51777cf8e8f58da3067f618dcf8b180fb2308b550a0aab6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0c0d163e334ea4aceb9155a993fcb36ab5edcb6de64052f81f3c9df94e0ef4b7.yml From 2a60e2d33a449d42cd50afcfd63dfff4b2daec71 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 22:15:45 +0000 Subject: [PATCH 120/532] feat(api): OpenAPI spec update via Stainless API (#601) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6779bc250e9..71ab8276827 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0c0d163e334ea4aceb9155a993fcb36ab5edcb6de64052f81f3c9df94e0ef4b7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-878b75aba4994fe3a6a7f20b8c3cefe55489437b26641bd769ab30a71c7cf9cf.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 46f23305ab13212929aac54b31f8724e17d38852 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 10:03:37 +0000 Subject: [PATCH 121/532] feat(api): OpenAPI spec update via Stainless API (#602) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 71ab8276827..b4149f716ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-878b75aba4994fe3a6a7f20b8c3cefe55489437b26641bd769ab30a71c7cf9cf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a92aac1d4f64b4091bcaf32937d80b8472644ca7bba0dc719804e71425ecf067.yml From 3bc49fb7bbccf3d27a1861fb9b266b1672f8cfe3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 11:18:11 +0000 Subject: [PATCH 122/532] feat(api): OpenAPI spec update via Stainless API (#603) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index b4149f716ff..6779bc250e9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a92aac1d4f64b4091bcaf32937d80b8472644ca7bba0dc719804e71425ecf067.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0c0d163e334ea4aceb9155a993fcb36ab5edcb6de64052f81f3c9df94e0ef4b7.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 95dd9d710b820264bb100082f8d18fcd090cb175 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 12:25:38 +0000 Subject: [PATCH 123/532] feat(api): OpenAPI spec update via Stainless API (#604) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6779bc250e9..71ab8276827 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0c0d163e334ea4aceb9155a993fcb36ab5edcb6de64052f81f3c9df94e0ef4b7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-878b75aba4994fe3a6a7f20b8c3cefe55489437b26641bd769ab30a71c7cf9cf.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From f84b5d2dd8e2c967ca1dfd43298f284ec3576531 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 14:20:37 +0000 Subject: [PATCH 124/532] feat(api): OpenAPI spec update via Stainless API (#605) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 71ab8276827..98e89bff3ce 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-878b75aba4994fe3a6a7f20b8c3cefe55489437b26641bd769ab30a71c7cf9cf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-870afafa5e40263ba51777cf8e8f58da3067f618dcf8b180fb2308b550a0aab6.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 7626e85e7bb9de3ad9a9f0e88ecb65a5f3bf3e22 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 15:02:52 +0000 Subject: [PATCH 125/532] feat(api): OpenAPI spec update via Stainless API (#606) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 98e89bff3ce..b4149f716ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-870afafa5e40263ba51777cf8e8f58da3067f618dcf8b180fb2308b550a0aab6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a92aac1d4f64b4091bcaf32937d80b8472644ca7bba0dc719804e71425ecf067.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 284e3282f53f6c5279871226a310c5c81c8b6541 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 15:21:08 +0000 Subject: [PATCH 126/532] feat(api): OpenAPI spec update via Stainless API (#607) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b4149f716ff..71ab8276827 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a92aac1d4f64b4091bcaf32937d80b8472644ca7bba0dc719804e71425ecf067.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-878b75aba4994fe3a6a7f20b8c3cefe55489437b26641bd769ab30a71c7cf9cf.yml From 191305d620bb97d52ce67183b0b7913a754e359c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 16:46:12 +0000 Subject: [PATCH 127/532] feat(api): OpenAPI spec update via Stainless API (#608) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 71ab8276827..b4149f716ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-878b75aba4994fe3a6a7f20b8c3cefe55489437b26641bd769ab30a71c7cf9cf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a92aac1d4f64b4091bcaf32937d80b8472644ca7bba0dc719804e71425ecf067.yml From 6ac9c9628350fbf88efd2c59804d4e69d8e5e2e6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 17:14:10 +0000 Subject: [PATCH 128/532] feat(api): OpenAPI spec update via Stainless API (#609) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b4149f716ff..71ab8276827 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a92aac1d4f64b4091bcaf32937d80b8472644ca7bba0dc719804e71425ecf067.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-878b75aba4994fe3a6a7f20b8c3cefe55489437b26641bd769ab30a71c7cf9cf.yml From 0815c66bb894970a7223fe8063764350f37baa8b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 17:50:51 +0000 Subject: [PATCH 129/532] feat(api): OpenAPI spec update via Stainless API (#610) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 71ab8276827..98e89bff3ce 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-878b75aba4994fe3a6a7f20b8c3cefe55489437b26641bd769ab30a71c7cf9cf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-870afafa5e40263ba51777cf8e8f58da3067f618dcf8b180fb2308b550a0aab6.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 82073d1bf46276ae33a8d5c096745f6ca6cd2080 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 18:47:37 +0000 Subject: [PATCH 130/532] feat(api): OpenAPI spec update via Stainless API (#611) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../access/application_create_params.py | 15 ++- .../access/application_create_response.py | 15 ++- .../access/application_get_response.py | 15 ++- .../access/application_list_response.py | 15 ++- .../access/application_update_params.py | 15 ++- .../access/application_update_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 19 files changed, 356 insertions(+), 299 deletions(-) diff --git a/.stats.yml b/.stats.yml index 98e89bff3ce..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-870afafa5e40263ba51777cf8e8f58da3067f618dcf8b180fb2308b550a0aab6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/zero_trust/access/application_create_params.py b/src/cloudflare/types/zero_trust/access/application_create_params.py index d9df78112c3..ceefef639fc 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_params.py +++ b/src/cloudflare/types/zero_trust/access/application_create_params.py @@ -35,6 +35,7 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", "SaaSApplicationScimConfig", "SaaSApplicationScimConfigAuthentication", @@ -599,6 +600,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(TypedDict, total=False source: SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource +class SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions(TypedDict, total=False): + return_access_token_from_authorization_endpoint: bool + """If an Access Token should be returned from the OIDC Authorization endpoint""" + + return_id_token_from_authorization_endpoint: bool + """If an ID Token should be returned from the OIDC Authorization endpoint""" + + class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(TypedDict, total=False): lifetime: str """How long a refresh token will be valid for after creation. @@ -631,12 +640,16 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): custom_claims: SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims - grant_types: List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]] + grant_types: List[ + Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens", "hybrid", "implicit"] + ] """The OIDC flows supported by this application""" group_filter_regex: str """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + hybrid_and_implicit_options: SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions + public_key: str """The Access public certificate that will be used to verify your identity.""" diff --git a/src/cloudflare/types/zero_trust/access/application_create_response.py b/src/cloudflare/types/zero_trust/access/application_create_response.py index 40097b24575..982ec9f5012 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_response.py +++ b/src/cloudflare/types/zero_trust/access/application_create_response.py @@ -33,6 +33,7 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", "SaaSApplicationScimConfig", "SaaSApplicationScimConfigAuthentication", @@ -504,6 +505,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None +class SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions(BaseModel): + return_access_token_from_authorization_endpoint: Optional[bool] = None + """If an Access Token should be returned from the OIDC Authorization endpoint""" + + return_id_token_from_authorization_endpoint: Optional[bool] = None + """If an ID Token should be returned from the OIDC Authorization endpoint""" + + class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): lifetime: Optional[str] = None """How long a refresh token will be valid for after creation. @@ -538,12 +547,16 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None - grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]]] = None + grant_types: Optional[ + List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens", "hybrid", "implicit"]] + ] = None """The OIDC flows supported by this application""" group_filter_regex: Optional[str] = None """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + hybrid_and_implicit_options: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions] = None + public_key: Optional[str] = None """The Access public certificate that will be used to verify your identity.""" diff --git a/src/cloudflare/types/zero_trust/access/application_get_response.py b/src/cloudflare/types/zero_trust/access/application_get_response.py index 7b3c0f9a014..002c59d38ba 100644 --- a/src/cloudflare/types/zero_trust/access/application_get_response.py +++ b/src/cloudflare/types/zero_trust/access/application_get_response.py @@ -33,6 +33,7 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", "SaaSApplicationScimConfig", "SaaSApplicationScimConfigAuthentication", @@ -504,6 +505,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None +class SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions(BaseModel): + return_access_token_from_authorization_endpoint: Optional[bool] = None + """If an Access Token should be returned from the OIDC Authorization endpoint""" + + return_id_token_from_authorization_endpoint: Optional[bool] = None + """If an ID Token should be returned from the OIDC Authorization endpoint""" + + class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): lifetime: Optional[str] = None """How long a refresh token will be valid for after creation. @@ -538,12 +547,16 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None - grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]]] = None + grant_types: Optional[ + List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens", "hybrid", "implicit"]] + ] = None """The OIDC flows supported by this application""" group_filter_regex: Optional[str] = None """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + hybrid_and_implicit_options: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions] = None + public_key: Optional[str] = None """The Access public certificate that will be used to verify your identity.""" diff --git a/src/cloudflare/types/zero_trust/access/application_list_response.py b/src/cloudflare/types/zero_trust/access/application_list_response.py index ece348346d2..5cde098ccba 100644 --- a/src/cloudflare/types/zero_trust/access/application_list_response.py +++ b/src/cloudflare/types/zero_trust/access/application_list_response.py @@ -33,6 +33,7 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", "SaaSApplicationScimConfig", "SaaSApplicationScimConfigAuthentication", @@ -504,6 +505,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None +class SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions(BaseModel): + return_access_token_from_authorization_endpoint: Optional[bool] = None + """If an Access Token should be returned from the OIDC Authorization endpoint""" + + return_id_token_from_authorization_endpoint: Optional[bool] = None + """If an ID Token should be returned from the OIDC Authorization endpoint""" + + class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): lifetime: Optional[str] = None """How long a refresh token will be valid for after creation. @@ -538,12 +547,16 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None - grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]]] = None + grant_types: Optional[ + List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens", "hybrid", "implicit"]] + ] = None """The OIDC flows supported by this application""" group_filter_regex: Optional[str] = None """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + hybrid_and_implicit_options: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions] = None + public_key: Optional[str] = None """The Access public certificate that will be used to verify your identity.""" diff --git a/src/cloudflare/types/zero_trust/access/application_update_params.py b/src/cloudflare/types/zero_trust/access/application_update_params.py index d4777baab75..89f3c200849 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_params.py +++ b/src/cloudflare/types/zero_trust/access/application_update_params.py @@ -35,6 +35,7 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", "SaaSApplicationScimConfig", "SaaSApplicationScimConfigAuthentication", @@ -599,6 +600,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(TypedDict, total=False source: SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource +class SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions(TypedDict, total=False): + return_access_token_from_authorization_endpoint: bool + """If an Access Token should be returned from the OIDC Authorization endpoint""" + + return_id_token_from_authorization_endpoint: bool + """If an ID Token should be returned from the OIDC Authorization endpoint""" + + class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(TypedDict, total=False): lifetime: str """How long a refresh token will be valid for after creation. @@ -631,12 +640,16 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): custom_claims: SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims - grant_types: List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]] + grant_types: List[ + Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens", "hybrid", "implicit"] + ] """The OIDC flows supported by this application""" group_filter_regex: str """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + hybrid_and_implicit_options: SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions + public_key: str """The Access public certificate that will be used to verify your identity.""" diff --git a/src/cloudflare/types/zero_trust/access/application_update_response.py b/src/cloudflare/types/zero_trust/access/application_update_response.py index eb34f2f3f49..e4d7f457b89 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_response.py +++ b/src/cloudflare/types/zero_trust/access/application_update_response.py @@ -33,6 +33,7 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSApp", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims", "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", + "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", "SaaSApplicationScimConfig", "SaaSApplicationScimConfigAuthentication", @@ -504,6 +505,14 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims(BaseModel): source: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource] = None +class SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions(BaseModel): + return_access_token_from_authorization_endpoint: Optional[bool] = None + """If an Access Token should be returned from the OIDC Authorization endpoint""" + + return_id_token_from_authorization_endpoint: Optional[bool] = None + """If an ID Token should be returned from the OIDC Authorization endpoint""" + + class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): lifetime: Optional[str] = None """How long a refresh token will be valid for after creation. @@ -538,12 +547,16 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): custom_claims: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaims] = None - grant_types: Optional[List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens"]]] = None + grant_types: Optional[ + List[Literal["authorization_code", "authorization_code_with_pkce", "refresh_tokens", "hybrid", "implicit"]] + ] = None """The OIDC flows supported by this application""" group_filter_regex: Optional[str] = None """A regex to filter Cloudflare groups returned in ID token and userinfo endpoint""" + hybrid_and_implicit_options: Optional[SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions] = None + public_key: Optional[str] = None """The Access public certificate that will be used to verify your identity.""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From d7a71cd9b1bee4890f6cff29d4d9f359c298f084 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 20:11:30 +0000 Subject: [PATCH 131/532] feat(api): OpenAPI spec update via Stainless API (#612) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a594a051342..e7efc646cab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml From 1f5f9891af12208f9919875309fa505c550a3a5b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 00:40:46 +0000 Subject: [PATCH 132/532] feat(api): OpenAPI spec update via Stainless API (#613) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index e7efc646cab..e469f2d6d78 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-11bbd045a344c1971dd533e157e71576ddd513fa22b13187a2bc2bf72a3c5164.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 58dc060cb71ef587882c9aa45b38b746cab43b48 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 01:08:54 +0000 Subject: [PATCH 133/532] feat(api): OpenAPI spec update via Stainless API (#614) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index e469f2d6d78..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-11bbd045a344c1971dd533e157e71576ddd513fa22b13187a2bc2bf72a3c5164.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From ce0170a05c66a1b74c5a1837d53fa963165f9b25 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 02:49:56 +0000 Subject: [PATCH 134/532] feat(api): OpenAPI spec update via Stainless API (#615) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a594a051342..e469f2d6d78 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-11bbd045a344c1971dd533e157e71576ddd513fa22b13187a2bc2bf72a3c5164.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From e9385899b3f466adf95e097397030ad5364d2037 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 09:40:44 +0000 Subject: [PATCH 135/532] feat(api): OpenAPI spec update via Stainless API (#616) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index e469f2d6d78..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-11bbd045a344c1971dd533e157e71576ddd513fa22b13187a2bc2bf72a3c5164.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 623b17dd79769a6d7abd5380182a793aa117322e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 11:07:02 +0000 Subject: [PATCH 136/532] feat(api): OpenAPI spec update via Stainless API (#617) --- .devcontainer/Dockerfile | 2 +- .github/workflows/ci.yml | 6 +- .github/workflows/publish-pypi.yml | 2 +- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 16 files changed, 298 insertions(+), 277 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index dd93962010e..e9841a168d9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} USER vscode -RUN curl -sSf https://rye-up.com/get | RYE_VERSION="0.24.0" RYE_INSTALL_OPTION="--yes" bash +RUN curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | RYE_VERSION="0.24.0" RYE_INSTALL_OPTION="--yes" bash ENV PATH=/home/vscode/.rye/shims:$PATH RUN echo "[[ -d .venv ]] && source .venv/bin/activate" >> /home/vscode/.bashrc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caedad093be..47bfcb4d257 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - name: Install Rye run: | - curl -sSf https://rye-up.com/get | bash + curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: RYE_VERSION: 0.24.0 @@ -38,7 +38,7 @@ jobs: - name: Install Rye run: | - curl -sSf https://rye-up.com/get | bash + curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: RYE_VERSION: 0.24.0 @@ -58,7 +58,7 @@ jobs: - name: Install Rye run: | - curl -sSf https://rye-up.com/get | bash + curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: RYE_VERSION: 0.24.0 diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 4cc6b598c5a..c6ad3cb1535 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -18,7 +18,7 @@ jobs: - name: Install Rye run: | - curl -sSf https://rye-up.com/get | bash + curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: RYE_VERSION: 0.24.0 diff --git a/.stats.yml b/.stats.yml index a594a051342..d815e5acaf6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From c444151db6ee3cbc796b189beca21674996db316 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 14:07:45 +0000 Subject: [PATCH 137/532] feat(api): OpenAPI spec update via Stainless API (#618) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index d815e5acaf6..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 66f093ff3180cfe15d19a6ebb7c5546c42db9575 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 14:09:54 +0000 Subject: [PATCH 138/532] feat(api): OpenAPI spec update via Stainless API (#619) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a594a051342..e7efc646cab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml From e50476cd7094d4efe31bc47eeb55b3f551da6907 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 14:47:31 +0000 Subject: [PATCH 139/532] feat(api): OpenAPI spec update via Stainless API (#620) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e7efc646cab..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml From fabd160a971988ce3c3bb211d9b54eb07d39b1bc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 14:49:37 +0000 Subject: [PATCH 140/532] feat(api): OpenAPI spec update via Stainless API (#621) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a594a051342..e7efc646cab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml From 466aa547e93e5ba3d60a798f537450a20ec03b72 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 16:18:59 +0000 Subject: [PATCH 141/532] feat(api): OpenAPI spec update via Stainless API (#622) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e7efc646cab..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml From 78e02752ff61111e90ff32e075ee7ca9b8112406 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 16:29:50 +0000 Subject: [PATCH 142/532] feat(api): OpenAPI spec update via Stainless API (#623) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a594a051342..e7efc646cab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml From 3b6a69a9e112b24c09704b2ba6f69ca00157e9a8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 16:57:24 +0000 Subject: [PATCH 143/532] feat(api): OpenAPI spec update via Stainless API (#624) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e7efc646cab..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml From 919c5252ed601379063978fdf835ce3a09341574 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 17:27:57 +0000 Subject: [PATCH 144/532] feat(api): OpenAPI spec update via Stainless API (#625) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a594a051342..e7efc646cab 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml From 6ba0d9c66c754ec630aa79801939652b53607253 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 17:30:16 +0000 Subject: [PATCH 145/532] feat(api): OpenAPI spec update via Stainless API (#626) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index e7efc646cab..d815e5acaf6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1dd55b6debca850e444007b69ca08d589239860ed608c18ea0df7fc359f8a4b4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 311c24c1fa1aef4b5f477bc0bb7e2afc18693943 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 17:32:17 +0000 Subject: [PATCH 146/532] feat(api): OpenAPI spec update via Stainless API (#627) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index d815e5acaf6..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 50a9dcfd48e8daac75c0449a037a5ceb7b1086b8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 17:54:45 +0000 Subject: [PATCH 147/532] feat(api): OpenAPI spec update via Stainless API (#628) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a594a051342..d815e5acaf6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From cbecda37c18375ad9c74d8f7e00620916c3b790c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 20:56:23 +0000 Subject: [PATCH 148/532] feat(api): OpenAPI spec update via Stainless API (#629) --- .devcontainer/Dockerfile | 2 +- .github/workflows/ci.yml | 6 +- .github/workflows/publish-pypi.yml | 2 +- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 16 files changed, 277 insertions(+), 298 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e9841a168d9..83bca8f716a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} USER vscode -RUN curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | RYE_VERSION="0.24.0" RYE_INSTALL_OPTION="--yes" bash +RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.24.0" RYE_INSTALL_OPTION="--yes" bash ENV PATH=/home/vscode/.rye/shims:$PATH RUN echo "[[ -d .venv ]] && source .venv/bin/activate" >> /home/vscode/.bashrc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47bfcb4d257..e853349a718 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - name: Install Rye run: | - curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | bash + curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: RYE_VERSION: 0.24.0 @@ -38,7 +38,7 @@ jobs: - name: Install Rye run: | - curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | bash + curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: RYE_VERSION: 0.24.0 @@ -58,7 +58,7 @@ jobs: - name: Install Rye run: | - curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | bash + curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: RYE_VERSION: 0.24.0 diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index c6ad3cb1535..6528ad30f81 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -18,7 +18,7 @@ jobs: - name: Install Rye run: | - curl -sSf https://raw.githubusercontent.com/astral-sh/rye/main/scripts/install.sh | bash + curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: RYE_VERSION: 0.24.0 diff --git a/.stats.yml b/.stats.yml index d815e5acaf6..a594a051342 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From c9807e4dfe314104a740d90352958f698caf243a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 20:58:32 +0000 Subject: [PATCH 149/532] feat(api): OpenAPI spec update via Stainless API (#630) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a594a051342..d815e5acaf6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 574da52b346de2348be857161782b08153b4bb78 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 21:20:00 +0000 Subject: [PATCH 150/532] feat(api): OpenAPI spec update via Stainless API (#631) --- .stats.yml | 2 +- api.md | 28 ++-- .../resources/argo/tiered_caching.py | 98 +++++------ .../resources/cache/smart_tiered_cache.py | 152 +++++++----------- .../cloudforce_one/requests/message.py | 76 ++++----- .../cloudforce_one/requests/priority.py | 88 ++++------ .../cloudforce_one/requests/requests.py | 112 ++++++------- src/cloudflare/resources/intel/whois.py | 14 +- .../argo/tiered_caching_edit_response.py | 19 ++- .../types/argo/tiered_caching_get_response.py | 19 ++- .../smart_tiered_cache_delete_response.py | 19 ++- .../cache/smart_tiered_cache_edit_params.py | 2 +- .../cache/smart_tiered_cache_edit_response.py | 19 ++- .../cache/smart_tiered_cache_get_response.py | 19 ++- .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- .../cloudforce_one/requests/test_message.py | 50 +++--- .../cloudforce_one/requests/test_priority.py | 50 +++--- .../cloudforce_one/test_requests.py | 82 +++++----- tests/api_resources/intel/test_whois.py | 18 +-- 21 files changed, 458 insertions(+), 454 deletions(-) diff --git a/.stats.yml b/.stats.yml index d815e5acaf6..2be77114940 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9473145ec14267d5f88d6db81fe3b2cfb80d5331f22d58caf929a4baeed8e7c1.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/argo/tiered_caching.py b/src/cloudflare/resources/argo/tiered_caching.py index 89faa76ba4a..978bfc9d2c0 100644 --- a/src/cloudflare/resources/argo/tiered_caching.py +++ b/src/cloudflare/resources/argo/tiered_caching.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, cast from typing_extensions import Literal import httpx @@ -70,22 +70,17 @@ def edit( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - TieredCachingEditResponse, - self._patch( - f"/zones/{zone_id}/argo/tiered_caching", - body=maybe_transform({"value": value}, tiered_caching_edit_params.TieredCachingEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[TieredCachingEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[TieredCachingEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._patch( + f"/zones/{zone_id}/argo/tiered_caching", + body=maybe_transform({"value": value}, tiered_caching_edit_params.TieredCachingEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TieredCachingEditResponse]._unwrapper, ), + cast_to=cast(Type[TieredCachingEditResponse], ResultWrapper[TieredCachingEditResponse]), ) def get( @@ -115,21 +110,16 @@ def get( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - TieredCachingGetResponse, - self._get( - f"/zones/{zone_id}/argo/tiered_caching", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[TieredCachingGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[TieredCachingGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/zones/{zone_id}/argo/tiered_caching", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TieredCachingGetResponse]._unwrapper, ), + cast_to=cast(Type[TieredCachingGetResponse], ResultWrapper[TieredCachingGetResponse]), ) @@ -172,22 +162,17 @@ async def edit( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - TieredCachingEditResponse, - await self._patch( - f"/zones/{zone_id}/argo/tiered_caching", - body=await async_maybe_transform({"value": value}, tiered_caching_edit_params.TieredCachingEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[TieredCachingEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[TieredCachingEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._patch( + f"/zones/{zone_id}/argo/tiered_caching", + body=await async_maybe_transform({"value": value}, tiered_caching_edit_params.TieredCachingEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TieredCachingEditResponse]._unwrapper, ), + cast_to=cast(Type[TieredCachingEditResponse], ResultWrapper[TieredCachingEditResponse]), ) async def get( @@ -217,21 +202,16 @@ async def get( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - TieredCachingGetResponse, - await self._get( - f"/zones/{zone_id}/argo/tiered_caching", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[TieredCachingGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[TieredCachingGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/zones/{zone_id}/argo/tiered_caching", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TieredCachingGetResponse]._unwrapper, ), + cast_to=cast(Type[TieredCachingGetResponse], ResultWrapper[TieredCachingGetResponse]), ) diff --git a/src/cloudflare/resources/cache/smart_tiered_cache.py b/src/cloudflare/resources/cache/smart_tiered_cache.py index 05eaf141475..28189fb0fe5 100644 --- a/src/cloudflare/resources/cache/smart_tiered_cache.py +++ b/src/cloudflare/resources/cache/smart_tiered_cache.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, cast from typing_extensions import Literal import httpx @@ -68,21 +68,16 @@ def delete( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartTieredCacheDeleteResponse, - self._delete( - f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartTieredCacheDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartTieredCacheDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartTieredCacheDeleteResponse]._unwrapper, ), + cast_to=cast(Type[SmartTieredCacheDeleteResponse], ResultWrapper[SmartTieredCacheDeleteResponse]), ) def edit( @@ -103,7 +98,7 @@ def edit( Args: zone_id: Identifier - value: Enables Tiered Cache. + value: Enable or disable the Smart Tiered Cache extra_headers: Send extra headers @@ -115,22 +110,17 @@ def edit( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartTieredCacheEditResponse, - self._patch( - f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", - body=maybe_transform({"value": value}, smart_tiered_cache_edit_params.SmartTieredCacheEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartTieredCacheEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartTieredCacheEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._patch( + f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", + body=maybe_transform({"value": value}, smart_tiered_cache_edit_params.SmartTieredCacheEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartTieredCacheEditResponse]._unwrapper, ), + cast_to=cast(Type[SmartTieredCacheEditResponse], ResultWrapper[SmartTieredCacheEditResponse]), ) def get( @@ -160,21 +150,16 @@ def get( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartTieredCacheGetResponse, - self._get( - f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartTieredCacheGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartTieredCacheGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartTieredCacheGetResponse]._unwrapper, ), + cast_to=cast(Type[SmartTieredCacheGetResponse], ResultWrapper[SmartTieredCacheGetResponse]), ) @@ -214,21 +199,16 @@ async def delete( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartTieredCacheDeleteResponse, - await self._delete( - f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartTieredCacheDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartTieredCacheDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartTieredCacheDeleteResponse]._unwrapper, ), + cast_to=cast(Type[SmartTieredCacheDeleteResponse], ResultWrapper[SmartTieredCacheDeleteResponse]), ) async def edit( @@ -249,7 +229,7 @@ async def edit( Args: zone_id: Identifier - value: Enables Tiered Cache. + value: Enable or disable the Smart Tiered Cache extra_headers: Send extra headers @@ -261,24 +241,19 @@ async def edit( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartTieredCacheEditResponse, - await self._patch( - f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", - body=await async_maybe_transform( - {"value": value}, smart_tiered_cache_edit_params.SmartTieredCacheEditParams - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartTieredCacheEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartTieredCacheEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._patch( + f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", + body=await async_maybe_transform( + {"value": value}, smart_tiered_cache_edit_params.SmartTieredCacheEditParams ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartTieredCacheEditResponse]._unwrapper, + ), + cast_to=cast(Type[SmartTieredCacheEditResponse], ResultWrapper[SmartTieredCacheEditResponse]), ) async def get( @@ -308,21 +283,16 @@ async def get( """ if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return cast( - SmartTieredCacheGetResponse, - await self._get( - f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[SmartTieredCacheGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[SmartTieredCacheGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/zones/{zone_id}/cache/tiered_cache_smart_topology_enable", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SmartTieredCacheGetResponse]._unwrapper, ), + cast_to=cast(Type[SmartTieredCacheGetResponse], ResultWrapper[SmartTieredCacheGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/argo/tiered_caching_edit_response.py b/src/cloudflare/types/argo/tiered_caching_edit_response.py index e86ebbfb070..0e99559b8f5 100644 --- a/src/cloudflare/types/argo/tiered_caching_edit_response.py +++ b/src/cloudflare/types/argo/tiered_caching_edit_response.py @@ -1,7 +1,22 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel __all__ = ["TieredCachingEditResponse"] -TieredCachingEditResponse = Union[Optional[str], Optional[object]] + +class TieredCachingEditResponse(BaseModel): + id: str + """The identifier of the caching setting""" + + editable: bool + """Whether the setting is editable""" + + modified_on: datetime + """The time when the setting was last modified""" + + value: Literal["on", "off"] + """The status of the feature being on / off""" diff --git a/src/cloudflare/types/argo/tiered_caching_get_response.py b/src/cloudflare/types/argo/tiered_caching_get_response.py index b50be22c227..72f04aac880 100644 --- a/src/cloudflare/types/argo/tiered_caching_get_response.py +++ b/src/cloudflare/types/argo/tiered_caching_get_response.py @@ -1,7 +1,22 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel __all__ = ["TieredCachingGetResponse"] -TieredCachingGetResponse = Union[Optional[str], Optional[object]] + +class TieredCachingGetResponse(BaseModel): + id: str + """The identifier of the caching setting""" + + editable: bool + """Whether the setting is editable""" + + modified_on: datetime + """The time when the setting was last modified""" + + value: Literal["on", "off"] + """The status of the feature being on / off""" diff --git a/src/cloudflare/types/cache/smart_tiered_cache_delete_response.py b/src/cloudflare/types/cache/smart_tiered_cache_delete_response.py index 5163ec1c632..3ccc2711f88 100644 --- a/src/cloudflare/types/cache/smart_tiered_cache_delete_response.py +++ b/src/cloudflare/types/cache/smart_tiered_cache_delete_response.py @@ -1,7 +1,22 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel __all__ = ["SmartTieredCacheDeleteResponse"] -SmartTieredCacheDeleteResponse = Union[Optional[str], Optional[object]] + +class SmartTieredCacheDeleteResponse(BaseModel): + id: str + """The identifier of the caching setting""" + + editable: bool + """Whether the setting is editable""" + + modified_on: datetime + """The time when the setting was last modified""" + + value: Literal["on", "off"] + """The status of the feature being on / off""" diff --git a/src/cloudflare/types/cache/smart_tiered_cache_edit_params.py b/src/cloudflare/types/cache/smart_tiered_cache_edit_params.py index 5ab8be3dd6b..557f0df09fe 100644 --- a/src/cloudflare/types/cache/smart_tiered_cache_edit_params.py +++ b/src/cloudflare/types/cache/smart_tiered_cache_edit_params.py @@ -12,4 +12,4 @@ class SmartTieredCacheEditParams(TypedDict, total=False): """Identifier""" value: Required[Literal["on", "off"]] - """Enables Tiered Cache.""" + """Enable or disable the Smart Tiered Cache""" diff --git a/src/cloudflare/types/cache/smart_tiered_cache_edit_response.py b/src/cloudflare/types/cache/smart_tiered_cache_edit_response.py index 904f1c78e2f..8e871b0599c 100644 --- a/src/cloudflare/types/cache/smart_tiered_cache_edit_response.py +++ b/src/cloudflare/types/cache/smart_tiered_cache_edit_response.py @@ -1,7 +1,22 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel __all__ = ["SmartTieredCacheEditResponse"] -SmartTieredCacheEditResponse = Union[Optional[str], Optional[object]] + +class SmartTieredCacheEditResponse(BaseModel): + id: str + """The identifier of the caching setting""" + + editable: bool + """Whether the setting is editable""" + + modified_on: datetime + """The time when the setting was last modified""" + + value: Literal["on", "off"] + """The status of the feature being on / off""" diff --git a/src/cloudflare/types/cache/smart_tiered_cache_get_response.py b/src/cloudflare/types/cache/smart_tiered_cache_get_response.py index d174244f78d..787aa0d5d59 100644 --- a/src/cloudflare/types/cache/smart_tiered_cache_get_response.py +++ b/src/cloudflare/types/cache/smart_tiered_cache_get_response.py @@ -1,7 +1,22 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel __all__ = ["SmartTieredCacheGetResponse"] -SmartTieredCacheGetResponse = Union[Optional[str], Optional[object]] + +class SmartTieredCacheGetResponse(BaseModel): + id: str + """The identifier of the caching setting""" + + editable: bool + """Whether the setting is editable""" + + modified_on: datetime + """The time when the setting was last modified""" + + value: Literal["on", "off"] + """The status of the feature being on / off""" diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 0c2dbd8604ff0f1e354a5195d603bb03d53e627a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 21:51:28 +0000 Subject: [PATCH 151/532] feat(api): OpenAPI spec update via Stainless API (#632) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2be77114940..dae202bcb15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9473145ec14267d5f88d6db81fe3b2cfb80d5331f22d58caf929a4baeed8e7c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml From c9d066bbddc3c96a2e92632de1eaa9588b1f62ed Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 22:11:19 +0000 Subject: [PATCH 152/532] feat(api): OpenAPI spec update via Stainless API (#633) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index dae202bcb15..407e404c66d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 42f9b3f4e9a54e48d2d52100768dd0161d5222ba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:31:35 +0000 Subject: [PATCH 153/532] feat(api): OpenAPI spec update via Stainless API (#634) --- .stats.yml | 2 +- api.md | 28 ++--- requirements-dev.lock | 2 +- src/cloudflare/_utils/_utils.py | 3 +- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 15 files changed, 274 insertions(+), 296 deletions(-) diff --git a/.stats.yml b/.stats.yml index 407e404c66d..2be77114940 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9473145ec14267d5f88d6db81fe3b2cfb80d5331f22d58caf929a4baeed8e7c1.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/requirements-dev.lock b/requirements-dev.lock index 938a9f70eae..3a5469efbd0 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -63,7 +63,7 @@ pydantic==2.7.1 # via cloudflare pydantic-core==2.18.2 # via pydantic -pyright==1.1.359 +pyright==1.1.364 pytest==7.1.1 # via pytest-asyncio pytest-asyncio==0.21.1 diff --git a/src/cloudflare/_utils/_utils.py b/src/cloudflare/_utils/_utils.py index 17904ce60d3..34797c29057 100644 --- a/src/cloudflare/_utils/_utils.py +++ b/src/cloudflare/_utils/_utils.py @@ -20,7 +20,7 @@ import sniffio -from .._types import Headers, NotGiven, FileTypes, NotGivenOr, HeadersLike +from .._types import NotGiven, FileTypes, NotGivenOr, HeadersLike from .._compat import parse_date as parse_date, parse_datetime as parse_datetime _T = TypeVar("_T") @@ -370,7 +370,6 @@ def file_from_path(path: str) -> FileTypes: def get_required_header(headers: HeadersLike, header: str) -> str: lower_header = header.lower() if isinstance(headers, Mapping): - headers = cast(Headers, headers) for k, v in headers.items(): if k.lower() == lower_header and isinstance(v, str): return v diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 6646954d11a7bdd10035aa203d76b9e7e07e2e23 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:33:52 +0000 Subject: [PATCH 154/532] feat(api): OpenAPI spec update via Stainless API (#635) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2be77114940..dae202bcb15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9473145ec14267d5f88d6db81fe3b2cfb80d5331f22d58caf929a4baeed8e7c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml From dea8849a6d689967637b316e25894c3af914b23f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 09:00:41 +0000 Subject: [PATCH 155/532] feat(api): OpenAPI spec update via Stainless API (#636) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index dae202bcb15..407e404c66d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From b1be7083229987e7891c2d9e0677cc04aa149f2e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 09:41:18 +0000 Subject: [PATCH 156/532] feat(api): OpenAPI spec update via Stainless API (#637) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 407e404c66d..dae202bcb15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 95bced9f30ac1723e8de51074d4a731f555c130a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 09:43:26 +0000 Subject: [PATCH 157/532] feat(api): OpenAPI spec update via Stainless API (#638) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index dae202bcb15..407e404c66d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From a6f2de9912cd4a1fcb762e8d88c2bd8fd985b54b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 09:45:41 +0000 Subject: [PATCH 158/532] feat(api): OpenAPI spec update via Stainless API (#639) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 407e404c66d..dae202bcb15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 281e5905a9302ff561dac9997245524971165191 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 10:54:57 +0000 Subject: [PATCH 159/532] feat(api): OpenAPI spec update via Stainless API (#640) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index dae202bcb15..407e404c66d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From e512306c9e4c45edfaf300869789744291e32b2b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 10:57:01 +0000 Subject: [PATCH 160/532] feat(api): OpenAPI spec update via Stainless API (#641) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 407e404c66d..2be77114940 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9473145ec14267d5f88d6db81fe3b2cfb80d5331f22d58caf929a4baeed8e7c1.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 105f09369bd8107bda47c06b0f661d7faaebfe61 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 11:18:59 +0000 Subject: [PATCH 161/532] feat(api): OpenAPI spec update via Stainless API (#642) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2be77114940..407e404c66d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9473145ec14267d5f88d6db81fe3b2cfb80d5331f22d58caf929a4baeed8e7c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 30c3d9bdc48e949d5699282e9768ae8a8ecfc04f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 11:20:59 +0000 Subject: [PATCH 162/532] feat(api): OpenAPI spec update via Stainless API (#643) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 407e404c66d..2be77114940 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9473145ec14267d5f88d6db81fe3b2cfb80d5331f22d58caf929a4baeed8e7c1.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From f853251079c061ca1c53d43762851ca943110e39 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 11:37:08 +0000 Subject: [PATCH 163/532] feat(api): OpenAPI spec update via Stainless API (#644) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2be77114940..407e404c66d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9473145ec14267d5f88d6db81fe3b2cfb80d5331f22d58caf929a4baeed8e7c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml diff --git a/api.md b/api.md index 5d723ee337b..2eae51c83c6 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 882d30d1f7b9b85446c175cbab08635096c8c7c5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 11:39:16 +0000 Subject: [PATCH 164/532] feat(api): OpenAPI spec update via Stainless API (#645) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 407e404c66d..dae202bcb15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4a62091d8e29b52ee985f4746fdea2431c2de10049c0b60256eca36ab75164a8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml diff --git a/api.md b/api.md index 2eae51c83c6..5d723ee337b 100644 --- a/api.md +++ b/api.md @@ -3657,7 +3657,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7492,14 +7492,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7515,10 +7515,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7535,11 +7535,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From a0ab776c1608e6134724e7cebf0a0f6d9b98c87c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 01:21:51 +0000 Subject: [PATCH 165/532] feat(api): update via SDK Studio (#646) --- .stats.yml | 4 +- CONTRIBUTING.md | 2 +- api.md | 31 ++-- .../resources/alerting/available_alerts.py | 48 +++---- .../alerting/destinations/eligible.py | 48 +++---- .../alerting/destinations/pagerduty.py | 68 ++++----- .../alerting/destinations/webhooks.py | 80 ++++------- src/cloudflare/resources/alerting/policies.py | 80 ++++------- .../access/applications/policies.py | 127 ---------------- .../zero_trust/access/custom_pages.py | 134 +---------------- .../alerting/available_alert_list_response.py | 26 +++- .../destinations/eligible_get_response.py | 25 +++- .../destinations/pagerduty_delete_response.py | 33 ++++- .../destinations/webhook_delete_response.py | 33 ++++- .../types/alerting/policy_delete_response.py | 33 ++++- src/cloudflare/types/pages/project.py | 6 + .../types/pages/project_create_params.py | 6 + src/cloudflare/types/shared/result.py | 6 +- .../types/zero_trust/access/__init__.py | 1 - .../access/applications/__init__.py | 1 - .../applications/policy_list_response.py | 73 ---------- .../access/custom_page_create_params.py | 21 --- .../alerting/destinations/test_pagerduty.py | 36 ++--- .../alerting/destinations/test_webhooks.py | 56 ++++---- tests/api_resources/alerting/test_policies.py | 56 ++++---- tests/api_resources/pages/test_projects.py | 28 +++- .../access/applications/test_policies.py | 136 ------------------ .../zero_trust/access/test_custom_pages.py | 122 ---------------- 28 files changed, 387 insertions(+), 933 deletions(-) delete mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_list_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/custom_page_create_params.py diff --git a/.stats.yml b/.stats.yml index dae202bcb15..1dd9e3f2e2a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b52b16bff8ec1d2a907464ad0923ecf4dcb16c4d7c4e36396aeb24fd2cea99a.yml +configured_endpoints: 1294 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaf3cf93b4b0566484405b918a65aeca6e5ad4cc194989298a633601684fa0c1.yml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4fc00cc62e1..655bcd3b39d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ### With Rye -We use [Rye](https://rye-up.com/) to manage dependencies so we highly recommend [installing it](https://rye-up.com/guide/installation/) as it will automatically provision a Python environment with the expected Python version. +We use [Rye](https://rye.astral.sh/) to manage dependencies so we highly recommend [installing it](https://rye.astral.sh/guide/installation/) as it will automatically provision a Python environment with the expected Python version. After installing Rye, you'll just have to run this command: diff --git a/api.md b/api.md index 5d723ee337b..aedb5c8b044 100644 --- a/api.md +++ b/api.md @@ -4483,12 +4483,6 @@ Methods: # Alerting -Types: - -```python -from cloudflare.types.alerting import Alert -``` - ## AvailableAlerts Types: @@ -4531,10 +4525,10 @@ from cloudflare.types.alerting.destinations import ( Methods: -- client.alerting.destinations.pagerduty.create(\*, account_id) -> PagerdutyCreateResponse -- client.alerting.destinations.pagerduty.delete(\*, account_id) -> Optional +- client.alerting.destinations.pagerduty.create(\*, account_id) -> Optional +- client.alerting.destinations.pagerduty.delete(\*, account_id) -> PagerdutyDeleteResponse - client.alerting.destinations.pagerduty.get(\*, account_id) -> Optional -- client.alerting.destinations.pagerduty.link(token_id, \*, account_id) -> PagerdutyLinkResponse +- client.alerting.destinations.pagerduty.link(token_id, \*, account_id) -> Optional ### Webhooks @@ -4551,11 +4545,11 @@ from cloudflare.types.alerting.destinations import ( Methods: -- client.alerting.destinations.webhooks.create(\*, account_id, \*\*params) -> WebhookCreateResponse -- client.alerting.destinations.webhooks.update(webhook_id, \*, account_id, \*\*params) -> WebhookUpdateResponse +- client.alerting.destinations.webhooks.create(\*, account_id, \*\*params) -> Optional +- client.alerting.destinations.webhooks.update(webhook_id, \*, account_id, \*\*params) -> Optional - client.alerting.destinations.webhooks.list(\*, account_id) -> SyncSinglePage[Webhooks] -- client.alerting.destinations.webhooks.delete(webhook_id, \*, account_id) -> Optional -- client.alerting.destinations.webhooks.get(webhook_id, \*, account_id) -> Webhooks +- client.alerting.destinations.webhooks.delete(webhook_id, \*, account_id) -> WebhookDeleteResponse +- client.alerting.destinations.webhooks.get(webhook_id, \*, account_id) -> Optional ## History @@ -4586,11 +4580,11 @@ from cloudflare.types.alerting import ( Methods: -- client.alerting.policies.create(\*, account_id, \*\*params) -> PolicyCreateResponse -- client.alerting.policies.update(policy_id, \*, account_id, \*\*params) -> PolicyUpdateResponse +- client.alerting.policies.create(\*, account_id, \*\*params) -> Optional +- client.alerting.policies.update(policy_id, \*, account_id, \*\*params) -> Optional - client.alerting.policies.list(\*, account_id) -> SyncSinglePage[Policy] -- client.alerting.policies.delete(policy_id, \*, account_id) -> Optional -- client.alerting.policies.get(policy_id, \*, account_id) -> Policy +- client.alerting.policies.delete(policy_id, \*, account_id) -> PolicyDeleteResponse +- client.alerting.policies.get(policy_id, \*, account_id) -> Optional # D1 @@ -5183,7 +5177,6 @@ from cloudflare.types.zero_trust.access.applications import ( Policy, PolicyCreateResponse, PolicyUpdateResponse, - PolicyListResponse, PolicyDeleteResponse, PolicyGetResponse, ) @@ -5193,7 +5186,6 @@ Methods: - client.zero_trust.access.applications.policies.create(uuid, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.applications.policies.update(uuid, \*, uuid1, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.policies.list(uuid, \*, account_id, zone_id) -> SyncSinglePage[PolicyListResponse] - client.zero_trust.access.applications.policies.delete(uuid, \*, uuid1, account_id, zone_id) -> Optional - client.zero_trust.access.applications.policies.get(uuid, \*, uuid1, account_id, zone_id) -> Optional @@ -5382,7 +5374,6 @@ from cloudflare.types.zero_trust.access import ( Methods: -- client.zero_trust.access.custom_pages.create(identifier, \*\*params) -> Optional - client.zero_trust.access.custom_pages.update(uuid, \*, identifier, \*\*params) -> Optional - client.zero_trust.access.custom_pages.list(identifier) -> SyncSinglePage[CustomPageWithoutHTML] - client.zero_trust.access.custom_pages.delete(uuid, \*, identifier) -> Optional diff --git a/src/cloudflare/resources/alerting/available_alerts.py b/src/cloudflare/resources/alerting/available_alerts.py index abcc97045c4..b6c6a2d8327 100644 --- a/src/cloudflare/resources/alerting/available_alerts.py +++ b/src/cloudflare/resources/alerting/available_alerts.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Optional, cast +from typing import Type, Optional, cast import httpx @@ -60,21 +60,16 @@ def list( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - Optional[AvailableAlertListResponse], - self._get( - f"/accounts/{account_id}/alerting/v3/available_alerts", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AvailableAlertListResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[AvailableAlertListResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/accounts/{account_id}/alerting/v3/available_alerts", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AvailableAlertListResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[AvailableAlertListResponse]], ResultWrapper[AvailableAlertListResponse]), ) @@ -114,21 +109,16 @@ async def list( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - Optional[AvailableAlertListResponse], - await self._get( - f"/accounts/{account_id}/alerting/v3/available_alerts", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AvailableAlertListResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[AvailableAlertListResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/accounts/{account_id}/alerting/v3/available_alerts", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AvailableAlertListResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[AvailableAlertListResponse]], ResultWrapper[AvailableAlertListResponse]), ) diff --git a/src/cloudflare/resources/alerting/destinations/eligible.py b/src/cloudflare/resources/alerting/destinations/eligible.py index 850586d484a..25d24519dce 100644 --- a/src/cloudflare/resources/alerting/destinations/eligible.py +++ b/src/cloudflare/resources/alerting/destinations/eligible.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Optional, cast +from typing import Type, Optional, cast import httpx @@ -60,21 +60,16 @@ def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - Optional[EligibleGetResponse], - self._get( - f"/accounts/{account_id}/alerting/v3/destinations/eligible", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[EligibleGetResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[EligibleGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/accounts/{account_id}/alerting/v3/destinations/eligible", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[EligibleGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[EligibleGetResponse]], ResultWrapper[EligibleGetResponse]), ) @@ -114,21 +109,16 @@ async def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - Optional[EligibleGetResponse], - await self._get( - f"/accounts/{account_id}/alerting/v3/destinations/eligible", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[EligibleGetResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[EligibleGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/accounts/{account_id}/alerting/v3/destinations/eligible", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[EligibleGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[EligibleGetResponse]], ResultWrapper[EligibleGetResponse]), ) diff --git a/src/cloudflare/resources/alerting/destinations/pagerduty.py b/src/cloudflare/resources/alerting/destinations/pagerduty.py index bf465aff2f2..093dbb88fbf 100644 --- a/src/cloudflare/resources/alerting/destinations/pagerduty.py +++ b/src/cloudflare/resources/alerting/destinations/pagerduty.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Optional, cast +from typing import Type, Optional, cast import httpx @@ -46,7 +46,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PagerdutyCreateResponse: + ) -> Optional[PagerdutyCreateResponse]: """ Creates a new token for integrating with PagerDuty. @@ -70,9 +70,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PagerdutyCreateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PagerdutyCreateResponse]]._unwrapper, ), - cast_to=cast(Type[PagerdutyCreateResponse], ResultWrapper[PagerdutyCreateResponse]), + cast_to=cast(Type[Optional[PagerdutyCreateResponse]], ResultWrapper[PagerdutyCreateResponse]), ) def delete( @@ -85,7 +85,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PagerdutyDeleteResponse]: + ) -> PagerdutyDeleteResponse: """ Deletes all the PagerDuty Services connected to the account. @@ -102,21 +102,12 @@ def delete( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - Optional[PagerdutyDeleteResponse], - self._delete( - f"/accounts/{account_id}/alerting/v3/destinations/pagerduty", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PagerdutyDeleteResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PagerdutyDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/alerting/v3/destinations/pagerduty", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PagerdutyDeleteResponse, ) def get( @@ -169,7 +160,7 @@ def link( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PagerdutyLinkResponse: + ) -> Optional[PagerdutyLinkResponse]: """ Links PagerDuty with the account using the integration token. @@ -197,9 +188,9 @@ def link( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PagerdutyLinkResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PagerdutyLinkResponse]]._unwrapper, ), - cast_to=cast(Type[PagerdutyLinkResponse], ResultWrapper[PagerdutyLinkResponse]), + cast_to=cast(Type[Optional[PagerdutyLinkResponse]], ResultWrapper[PagerdutyLinkResponse]), ) @@ -222,7 +213,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PagerdutyCreateResponse: + ) -> Optional[PagerdutyCreateResponse]: """ Creates a new token for integrating with PagerDuty. @@ -246,9 +237,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PagerdutyCreateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PagerdutyCreateResponse]]._unwrapper, ), - cast_to=cast(Type[PagerdutyCreateResponse], ResultWrapper[PagerdutyCreateResponse]), + cast_to=cast(Type[Optional[PagerdutyCreateResponse]], ResultWrapper[PagerdutyCreateResponse]), ) async def delete( @@ -261,7 +252,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PagerdutyDeleteResponse]: + ) -> PagerdutyDeleteResponse: """ Deletes all the PagerDuty Services connected to the account. @@ -278,21 +269,12 @@ async def delete( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - Optional[PagerdutyDeleteResponse], - await self._delete( - f"/accounts/{account_id}/alerting/v3/destinations/pagerduty", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PagerdutyDeleteResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PagerdutyDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/alerting/v3/destinations/pagerduty", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PagerdutyDeleteResponse, ) async def get( @@ -345,7 +327,7 @@ async def link( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PagerdutyLinkResponse: + ) -> Optional[PagerdutyLinkResponse]: """ Links PagerDuty with the account using the integration token. @@ -373,9 +355,9 @@ async def link( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PagerdutyLinkResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PagerdutyLinkResponse]]._unwrapper, ), - cast_to=cast(Type[PagerdutyLinkResponse], ResultWrapper[PagerdutyLinkResponse]), + cast_to=cast(Type[Optional[PagerdutyLinkResponse]], ResultWrapper[PagerdutyLinkResponse]), ) diff --git a/src/cloudflare/resources/alerting/destinations/webhooks.py b/src/cloudflare/resources/alerting/destinations/webhooks.py index f988d06b025..883d4890db8 100644 --- a/src/cloudflare/resources/alerting/destinations/webhooks.py +++ b/src/cloudflare/resources/alerting/destinations/webhooks.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Optional, cast +from typing import Type, Optional, cast import httpx @@ -56,7 +56,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WebhookCreateResponse: + ) -> Optional[WebhookCreateResponse]: """ Creates a new webhook destination. @@ -97,9 +97,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WebhookCreateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WebhookCreateResponse]]._unwrapper, ), - cast_to=cast(Type[WebhookCreateResponse], ResultWrapper[WebhookCreateResponse]), + cast_to=cast(Type[Optional[WebhookCreateResponse]], ResultWrapper[WebhookCreateResponse]), ) def update( @@ -116,7 +116,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WebhookUpdateResponse: + ) -> Optional[WebhookUpdateResponse]: """ Update a webhook destination. @@ -161,9 +161,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WebhookUpdateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WebhookUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[WebhookUpdateResponse], ResultWrapper[WebhookUpdateResponse]), + cast_to=cast(Type[Optional[WebhookUpdateResponse]], ResultWrapper[WebhookUpdateResponse]), ) def list( @@ -213,7 +213,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WebhookDeleteResponse]: + ) -> WebhookDeleteResponse: """ Delete a configured webhook destination. @@ -234,21 +234,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") - return cast( - Optional[WebhookDeleteResponse], - self._delete( - f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[WebhookDeleteResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[WebhookDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=WebhookDeleteResponse, ) def get( @@ -262,7 +253,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Webhooks: + ) -> Optional[Webhooks]: """ Get details for a single webhooks destination. @@ -290,9 +281,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Webhooks]._unwrapper, + post_parser=ResultWrapper[Optional[Webhooks]]._unwrapper, ), - cast_to=cast(Type[Webhooks], ResultWrapper[Webhooks]), + cast_to=cast(Type[Optional[Webhooks]], ResultWrapper[Webhooks]), ) @@ -318,7 +309,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WebhookCreateResponse: + ) -> Optional[WebhookCreateResponse]: """ Creates a new webhook destination. @@ -359,9 +350,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WebhookCreateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WebhookCreateResponse]]._unwrapper, ), - cast_to=cast(Type[WebhookCreateResponse], ResultWrapper[WebhookCreateResponse]), + cast_to=cast(Type[Optional[WebhookCreateResponse]], ResultWrapper[WebhookCreateResponse]), ) async def update( @@ -378,7 +369,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WebhookUpdateResponse: + ) -> Optional[WebhookUpdateResponse]: """ Update a webhook destination. @@ -423,9 +414,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WebhookUpdateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WebhookUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[WebhookUpdateResponse], ResultWrapper[WebhookUpdateResponse]), + cast_to=cast(Type[Optional[WebhookUpdateResponse]], ResultWrapper[WebhookUpdateResponse]), ) def list( @@ -475,7 +466,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WebhookDeleteResponse]: + ) -> WebhookDeleteResponse: """ Delete a configured webhook destination. @@ -496,21 +487,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not webhook_id: raise ValueError(f"Expected a non-empty value for `webhook_id` but received {webhook_id!r}") - return cast( - Optional[WebhookDeleteResponse], - await self._delete( - f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[WebhookDeleteResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[WebhookDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=WebhookDeleteResponse, ) async def get( @@ -524,7 +506,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Webhooks: + ) -> Optional[Webhooks]: """ Get details for a single webhooks destination. @@ -552,9 +534,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Webhooks]._unwrapper, + post_parser=ResultWrapper[Optional[Webhooks]]._unwrapper, ), - cast_to=cast(Type[Webhooks], ResultWrapper[Webhooks]), + cast_to=cast(Type[Optional[Webhooks]], ResultWrapper[Webhooks]), ) diff --git a/src/cloudflare/resources/alerting/policies.py b/src/cloudflare/resources/alerting/policies.py index b7c35076824..b4c0c91442f 100644 --- a/src/cloudflare/resources/alerting/policies.py +++ b/src/cloudflare/resources/alerting/policies.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Optional, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -118,7 +118,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PolicyCreateResponse: + ) -> Optional[PolicyCreateResponse]: """ Creates a new Notification policy. @@ -170,9 +170,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PolicyCreateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyCreateResponse]]._unwrapper, ), - cast_to=cast(Type[PolicyCreateResponse], ResultWrapper[PolicyCreateResponse]), + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), ) def update( @@ -249,7 +249,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PolicyUpdateResponse: + ) -> Optional[PolicyUpdateResponse]: """ Update a Notification policy. @@ -305,9 +305,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PolicyUpdateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[PolicyUpdateResponse], ResultWrapper[PolicyUpdateResponse]), + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) def list( @@ -357,7 +357,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PolicyDeleteResponse]: + ) -> PolicyDeleteResponse: """ Delete a Notification policy. @@ -378,21 +378,12 @@ def delete( 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 cast( - Optional[PolicyDeleteResponse], - self._delete( - f"/accounts/{account_id}/alerting/v3/policies/{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( - Any, ResultWrapper[PolicyDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PolicyDeleteResponse, ) def get( @@ -406,7 +397,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Policy: + ) -> Optional[Policy]: """ Get details for a single policy. @@ -434,9 +425,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Policy]._unwrapper, + post_parser=ResultWrapper[Optional[Policy]]._unwrapper, ), - cast_to=cast(Type[Policy], ResultWrapper[Policy]), + cast_to=cast(Type[Optional[Policy]], ResultWrapper[Policy]), ) @@ -521,7 +512,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PolicyCreateResponse: + ) -> Optional[PolicyCreateResponse]: """ Creates a new Notification policy. @@ -573,9 +564,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PolicyCreateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyCreateResponse]]._unwrapper, ), - cast_to=cast(Type[PolicyCreateResponse], ResultWrapper[PolicyCreateResponse]), + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), ) async def update( @@ -652,7 +643,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PolicyUpdateResponse: + ) -> Optional[PolicyUpdateResponse]: """ Update a Notification policy. @@ -708,9 +699,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PolicyUpdateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[PolicyUpdateResponse], ResultWrapper[PolicyUpdateResponse]), + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) def list( @@ -760,7 +751,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PolicyDeleteResponse]: + ) -> PolicyDeleteResponse: """ Delete a Notification policy. @@ -781,21 +772,12 @@ async def delete( 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 cast( - Optional[PolicyDeleteResponse], - await self._delete( - f"/accounts/{account_id}/alerting/v3/policies/{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( - Any, ResultWrapper[PolicyDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/alerting/v3/policies/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PolicyDeleteResponse, ) async def get( @@ -809,7 +791,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Policy: + ) -> Optional[Policy]: """ Get details for a single policy. @@ -837,9 +819,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Policy]._unwrapper, + post_parser=ResultWrapper[Optional[Policy]]._unwrapper, ), - cast_to=cast(Type[Policy], ResultWrapper[Policy]), + cast_to=cast(Type[Optional[Policy]], ResultWrapper[Policy]), ) diff --git a/src/cloudflare/resources/zero_trust/access/applications/policies.py b/src/cloudflare/resources/zero_trust/access/applications/policies.py index b5c9f110dee..40c2491c9f2 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/policies.py +++ b/src/cloudflare/resources/zero_trust/access/applications/policies.py @@ -20,9 +20,7 @@ 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.access import Decision @@ -31,7 +29,6 @@ from .....types.zero_trust.access.applications import policy_create_params, policy_update_params from .....types.zero_trust.access.applications.policy_get_response import PolicyGetResponse from .....types.zero_trust.access.applications.approval_group_param import ApprovalGroupParam -from .....types.zero_trust.access.applications.policy_list_response import PolicyListResponse from .....types.zero_trust.access.applications.policy_create_response import PolicyCreateResponse from .....types.zero_trust.access.applications.policy_delete_response import PolicyDeleteResponse from .....types.zero_trust.access.applications.policy_update_response import PolicyUpdateResponse @@ -296,62 +293,6 @@ def update( cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) - def list( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[PolicyListResponse]: - """Lists Access policies configured for an application. - - Returns both exclusively - scoped and reusable policies used by the application. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", - page=SyncSinglePage[PolicyListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=PolicyListResponse, - ) - def delete( self, uuid: str, @@ -738,62 +679,6 @@ async def update( cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) - def list( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[PolicyListResponse, AsyncSinglePage[PolicyListResponse]]: - """Lists Access policies configured for an application. - - Returns both exclusively - scoped and reusable policies used by the application. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", - page=AsyncSinglePage[PolicyListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=PolicyListResponse, - ) - async def delete( self, uuid: str, @@ -933,9 +818,6 @@ def __init__(self, policies: PoliciesResource) -> None: self.update = to_raw_response_wrapper( policies.update, ) - self.list = to_raw_response_wrapper( - policies.list, - ) self.delete = to_raw_response_wrapper( policies.delete, ) @@ -954,9 +836,6 @@ def __init__(self, policies: AsyncPoliciesResource) -> None: self.update = async_to_raw_response_wrapper( policies.update, ) - self.list = async_to_raw_response_wrapper( - policies.list, - ) self.delete = async_to_raw_response_wrapper( policies.delete, ) @@ -975,9 +854,6 @@ def __init__(self, policies: PoliciesResource) -> None: self.update = to_streamed_response_wrapper( policies.update, ) - self.list = to_streamed_response_wrapper( - policies.list, - ) self.delete = to_streamed_response_wrapper( policies.delete, ) @@ -996,9 +872,6 @@ def __init__(self, policies: AsyncPoliciesResource) -> None: self.update = async_to_streamed_response_wrapper( policies.update, ) - self.list = async_to_streamed_response_wrapper( - policies.list, - ) self.delete = async_to_streamed_response_wrapper( policies.delete, ) diff --git a/src/cloudflare/resources/zero_trust/access/custom_pages.py b/src/cloudflare/resources/zero_trust/access/custom_pages.py index 1314c7e01b9..596e6cd8f68 100644 --- a/src/cloudflare/resources/zero_trust/access/custom_pages.py +++ b/src/cloudflare/resources/zero_trust/access/custom_pages.py @@ -26,7 +26,7 @@ AsyncPaginator, make_request_options, ) -from ....types.zero_trust.access import custom_page_create_params, custom_page_update_params +from ....types.zero_trust.access import custom_page_update_params from ....types.zero_trust.access.custom_page import CustomPage from ....types.zero_trust.access.custom_page_without_html import CustomPageWithoutHTML from ....types.zero_trust.access.custom_page_delete_response import CustomPageDeleteResponse @@ -43,66 +43,6 @@ def with_raw_response(self) -> CustomPagesResourceWithRawResponse: def with_streaming_response(self) -> CustomPagesResourceWithStreamingResponse: return CustomPagesResourceWithStreamingResponse(self) - def create( - self, - identifier: str, - *, - custom_html: str, - name: str, - type: Literal["identity_denied", "forbidden"], - app_count: int | 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[CustomPageWithoutHTML]: - """ - Create a custom page - - Args: - identifier: Identifier - - custom_html: Custom page HTML. - - name: Custom page name. - - type: Custom page type. - - app_count: Number of apps the custom page is assigned to. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._post( - f"/accounts/{identifier}/access/custom_pages", - body=maybe_transform( - { - "custom_html": custom_html, - "name": name, - "type": type, - "app_count": app_count, - }, - custom_page_create_params.CustomPageCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), - ) - def update( self, uuid: str, @@ -302,66 +242,6 @@ def with_raw_response(self) -> AsyncCustomPagesResourceWithRawResponse: def with_streaming_response(self) -> AsyncCustomPagesResourceWithStreamingResponse: return AsyncCustomPagesResourceWithStreamingResponse(self) - async def create( - self, - identifier: str, - *, - custom_html: str, - name: str, - type: Literal["identity_denied", "forbidden"], - app_count: int | 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[CustomPageWithoutHTML]: - """ - Create a custom page - - Args: - identifier: Identifier - - custom_html: Custom page HTML. - - name: Custom page name. - - type: Custom page type. - - app_count: Number of apps the custom page is assigned to. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return await self._post( - f"/accounts/{identifier}/access/custom_pages", - body=await async_maybe_transform( - { - "custom_html": custom_html, - "name": name, - "type": type, - "app_count": app_count, - }, - custom_page_create_params.CustomPageCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), - ) - async def update( self, uuid: str, @@ -556,9 +436,6 @@ class CustomPagesResourceWithRawResponse: def __init__(self, custom_pages: CustomPagesResource) -> None: self._custom_pages = custom_pages - self.create = to_raw_response_wrapper( - custom_pages.create, - ) self.update = to_raw_response_wrapper( custom_pages.update, ) @@ -577,9 +454,6 @@ class AsyncCustomPagesResourceWithRawResponse: def __init__(self, custom_pages: AsyncCustomPagesResource) -> None: self._custom_pages = custom_pages - self.create = async_to_raw_response_wrapper( - custom_pages.create, - ) self.update = async_to_raw_response_wrapper( custom_pages.update, ) @@ -598,9 +472,6 @@ class CustomPagesResourceWithStreamingResponse: def __init__(self, custom_pages: CustomPagesResource) -> None: self._custom_pages = custom_pages - self.create = to_streamed_response_wrapper( - custom_pages.create, - ) self.update = to_streamed_response_wrapper( custom_pages.update, ) @@ -619,9 +490,6 @@ class AsyncCustomPagesResourceWithStreamingResponse: def __init__(self, custom_pages: AsyncCustomPagesResource) -> None: self._custom_pages = custom_pages - self.create = async_to_streamed_response_wrapper( - custom_pages.create, - ) self.update = async_to_streamed_response_wrapper( custom_pages.update, ) diff --git a/src/cloudflare/types/alerting/available_alert_list_response.py b/src/cloudflare/types/alerting/available_alert_list_response.py index 10470fec71c..b0ff8190634 100644 --- a/src/cloudflare/types/alerting/available_alert_list_response.py +++ b/src/cloudflare/types/alerting/available_alert_list_response.py @@ -1,7 +1,27 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import Dict, List, Optional -__all__ = ["AvailableAlertListResponse"] +from ..._models import BaseModel -AvailableAlertListResponse = Union[List[object], str, object, None] +__all__ = ["AvailableAlertListResponse", "AvailableAlertListResponseItem"] + + +class AvailableAlertListResponseItem(BaseModel): + description: Optional[str] = None + """Describes the alert type.""" + + display_name: Optional[str] = None + """Alert type name.""" + + filter_options: Optional[List[object]] = None + """Format of additional configuration options (filters) for the alert type. + + Data type of filters during policy creation: Array of strings. + """ + + type: Optional[str] = None + """Use this value when creating and updating a notification policy.""" + + +AvailableAlertListResponse = Dict[str, List[AvailableAlertListResponseItem]] diff --git a/src/cloudflare/types/alerting/destinations/eligible_get_response.py b/src/cloudflare/types/alerting/destinations/eligible_get_response.py index fa08c934e4b..127867de2c7 100644 --- a/src/cloudflare/types/alerting/destinations/eligible_get_response.py +++ b/src/cloudflare/types/alerting/destinations/eligible_get_response.py @@ -1,7 +1,26 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import Dict, List, Optional +from typing_extensions import Literal -__all__ = ["EligibleGetResponse"] +from ...._models import BaseModel -EligibleGetResponse = Union[List[object], str, object, None] +__all__ = ["EligibleGetResponse", "EligibleGetResponseItem"] + + +class EligibleGetResponseItem(BaseModel): + eligible: Optional[bool] = None + """Determines whether or not the account is eligible for the delivery mechanism.""" + + ready: Optional[bool] = None + """Beta flag. + + Users can create a policy with a mechanism that is not ready, but we cannot + guarantee successful delivery of notifications. + """ + + type: Optional[Literal["email", "pagerduty", "webhook"]] = None + """Determines type of delivery mechanism.""" + + +EligibleGetResponse = Dict[str, List[EligibleGetResponseItem]] diff --git a/src/cloudflare/types/alerting/destinations/pagerduty_delete_response.py b/src/cloudflare/types/alerting/destinations/pagerduty_delete_response.py index 3171e8788bc..958d795048c 100644 --- a/src/cloudflare/types/alerting/destinations/pagerduty_delete_response.py +++ b/src/cloudflare/types/alerting/destinations/pagerduty_delete_response.py @@ -1,7 +1,34 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List, Optional +from typing_extensions import Literal -__all__ = ["PagerdutyDeleteResponse"] +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo -PagerdutyDeleteResponse = Union[List[object], str, object, None] +__all__ = ["PagerdutyDeleteResponse", "ResultInfo"] + + +class ResultInfo(BaseModel): + count: Optional[float] = None + """Total number of results for the requested service""" + + page: Optional[float] = None + """Current page within paginated list of results""" + + per_page: Optional[float] = None + """Number of results per page of results""" + + total_count: Optional[float] = None + """Total results available without any search parameters""" + + +class PagerdutyDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" + + result_info: Optional[ResultInfo] = None diff --git a/src/cloudflare/types/alerting/destinations/webhook_delete_response.py b/src/cloudflare/types/alerting/destinations/webhook_delete_response.py index 2869927bb58..eef159b9921 100644 --- a/src/cloudflare/types/alerting/destinations/webhook_delete_response.py +++ b/src/cloudflare/types/alerting/destinations/webhook_delete_response.py @@ -1,7 +1,34 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List, Optional +from typing_extensions import Literal -__all__ = ["WebhookDeleteResponse"] +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo -WebhookDeleteResponse = Union[List[object], str, object, None] +__all__ = ["WebhookDeleteResponse", "ResultInfo"] + + +class ResultInfo(BaseModel): + count: Optional[float] = None + """Total number of results for the requested service""" + + page: Optional[float] = None + """Current page within paginated list of results""" + + per_page: Optional[float] = None + """Number of results per page of results""" + + total_count: Optional[float] = None + """Total results available without any search parameters""" + + +class WebhookDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" + + result_info: Optional[ResultInfo] = None diff --git a/src/cloudflare/types/alerting/policy_delete_response.py b/src/cloudflare/types/alerting/policy_delete_response.py index f211604e11c..d0feccf6ae2 100644 --- a/src/cloudflare/types/alerting/policy_delete_response.py +++ b/src/cloudflare/types/alerting/policy_delete_response.py @@ -1,7 +1,34 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List, Optional +from typing_extensions import Literal -__all__ = ["PolicyDeleteResponse"] +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo -PolicyDeleteResponse = Union[List[object], str, object, None] +__all__ = ["PolicyDeleteResponse", "ResultInfo"] + + +class ResultInfo(BaseModel): + count: Optional[float] = None + """Total number of results for the requested service""" + + page: Optional[float] = None + """Current page within paginated list of results""" + + per_page: Optional[float] = None + """Number of results per page of results""" + + total_count: Optional[float] = None + """Total results available without any search parameters""" + + +class PolicyDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" + + result_info: Optional[ResultInfo] = None diff --git a/src/cloudflare/types/pages/project.py b/src/cloudflare/types/pages/project.py index b4bd6af5396..d3e0210408f 100644 --- a/src/cloudflare/types/pages/project.py +++ b/src/cloudflare/types/pages/project.py @@ -201,6 +201,9 @@ class DeploymentConfigsPreviewQueueProducers(BaseModel): class DeploymentConfigsPreviewR2BucketsR2Binding(BaseModel): + jurisdiction: Optional[str] = None + """Jurisdiction of the R2 bucket.""" + name: Optional[str] = None """Name of the R2 bucket.""" @@ -398,6 +401,9 @@ class DeploymentConfigsProductionQueueProducers(BaseModel): class DeploymentConfigsProductionR2BucketsR2Binding(BaseModel): + jurisdiction: Optional[str] = None + """Jurisdiction of the R2 bucket.""" + name: Optional[str] = None """Name of the R2 bucket.""" diff --git a/src/cloudflare/types/pages/project_create_params.py b/src/cloudflare/types/pages/project_create_params.py index 8951be5327a..8c524d05ead 100644 --- a/src/cloudflare/types/pages/project_create_params.py +++ b/src/cloudflare/types/pages/project_create_params.py @@ -218,6 +218,9 @@ class DeploymentConfigsPreviewQueueProducers(TypedDict, total=False): class DeploymentConfigsPreviewR2BucketsR2Binding(TypedDict, total=False): + jurisdiction: Optional[str] + """Jurisdiction of the R2 bucket.""" + name: str """Name of the R2 bucket.""" @@ -410,6 +413,9 @@ class DeploymentConfigsProductionQueueProducers(TypedDict, total=False): class DeploymentConfigsProductionR2BucketsR2Binding(TypedDict, total=False): + jurisdiction: Optional[str] + """Jurisdiction of the R2 bucket.""" + name: str """Name of the R2 bucket.""" diff --git a/src/cloudflare/types/shared/result.py b/src/cloudflare/types/shared/result.py index 27983e6c0fd..5923de2e012 100644 --- a/src/cloudflare/types/shared/result.py +++ b/src/cloudflare/types/shared/result.py @@ -11,9 +11,9 @@ class UnionMember0(BaseModel): - errors: Optional[object] = None + errors: Optional[List[ResponseInfo]] = None - messages: Optional[List[object]] = None + messages: Optional[List[ResponseInfo]] = None result: Optional[List[AuditLog]] = None @@ -25,8 +25,6 @@ class AaaAPIResponseCommon(BaseModel): messages: List[ResponseInfo] - result: Union[List[object], str, object] - success: Literal[True] """Whether the API call was successful""" diff --git a/src/cloudflare/types/zero_trust/access/__init__.py b/src/cloudflare/types/zero_trust/access/__init__.py index 8b8d5c829cf..93d7f00acbb 100644 --- a/src/cloudflare/types/zero_trust/access/__init__.py +++ b/src/cloudflare/types/zero_trust/access/__init__.py @@ -46,7 +46,6 @@ from .application_update_params import ApplicationUpdateParams as ApplicationUpdateParams from .certificate_create_params import CertificateCreateParams as CertificateCreateParams from .certificate_update_params import CertificateUpdateParams as CertificateUpdateParams -from .custom_page_create_params import CustomPageCreateParams as CustomPageCreateParams from .custom_page_update_params import CustomPageUpdateParams as CustomPageUpdateParams from .application_create_response import ApplicationCreateResponse as ApplicationCreateResponse from .application_delete_response import ApplicationDeleteResponse as ApplicationDeleteResponse diff --git a/src/cloudflare/types/zero_trust/access/applications/__init__.py b/src/cloudflare/types/zero_trust/access/applications/__init__.py index 206ec39071b..b5124d49e0e 100644 --- a/src/cloudflare/types/zero_trust/access/applications/__init__.py +++ b/src/cloudflare/types/zero_trust/access/applications/__init__.py @@ -10,7 +10,6 @@ from .policy_get_response import PolicyGetResponse as PolicyGetResponse from .approval_group_param import ApprovalGroupParam as ApprovalGroupParam from .policy_create_params import PolicyCreateParams as PolicyCreateParams -from .policy_list_response import PolicyListResponse as PolicyListResponse from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams from .user_policy_check_geo import UserPolicyCheckGeo as UserPolicyCheckGeo from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py deleted file mode 100644 index 176b10bf16d..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py +++ /dev/null @@ -1,73 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime - -from ..decision import Decision -from ....._models import BaseModel -from ...access_rule import AccessRule -from .approval_group import ApprovalGroup - -__all__ = ["PolicyListResponse"] - - -class PolicyListResponse(BaseModel): - id: Optional[str] = None - """UUID""" - - approval_groups: Optional[List[ApprovalGroup]] = None - """Administrators who can approve a temporary authentication request.""" - - approval_required: Optional[bool] = None - """ - Requires the user to request access from an administrator at the start of each - session. - """ - - created_at: Optional[datetime] = None - - decision: Optional[Decision] = None - """The action Access will take if a user matches this policy.""" - - exclude: Optional[List[AccessRule]] = None - """Rules evaluated with a NOT logical operator. - - To match the policy, a user cannot meet any of the Exclude rules. - """ - - include: Optional[List[AccessRule]] = None - """Rules evaluated with an OR logical operator. - - A user needs to meet only one of the Include rules. - """ - - isolation_required: Optional[bool] = None - """ - Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - """ - - name: Optional[str] = None - """The name of the Access policy.""" - - purpose_justification_prompt: Optional[str] = None - """A custom message that will appear on the purpose justification screen.""" - - purpose_justification_required: Optional[bool] = None - """Require users to enter a justification when they log in to the application.""" - - require: Optional[List[AccessRule]] = None - """Rules evaluated with an AND logical operator. - - To match the policy, a user must meet all of the Require rules. - """ - - session_duration: Optional[str] = None - """The amount of time that tokens issued for the application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/custom_page_create_params.py b/src/cloudflare/types/zero_trust/access/custom_page_create_params.py deleted file mode 100644 index f1890d141b8..00000000000 --- a/src/cloudflare/types/zero_trust/access/custom_page_create_params.py +++ /dev/null @@ -1,21 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["CustomPageCreateParams"] - - -class CustomPageCreateParams(TypedDict, total=False): - custom_html: Required[str] - """Custom page HTML.""" - - name: Required[str] - """Custom page name.""" - - type: Required[Literal["identity_denied", "forbidden"]] - """Custom page type.""" - - app_count: int - """Number of apps the custom page is assigned to.""" diff --git a/tests/api_resources/alerting/destinations/test_pagerduty.py b/tests/api_resources/alerting/destinations/test_pagerduty.py index 912f43e1c42..cded507dd68 100644 --- a/tests/api_resources/alerting/destinations/test_pagerduty.py +++ b/tests/api_resources/alerting/destinations/test_pagerduty.py @@ -27,7 +27,7 @@ def test_method_create(self, client: Cloudflare) -> None: pagerduty = client.alerting.destinations.pagerduty.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(PagerdutyCreateResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -38,7 +38,7 @@ 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" pagerduty = response.parse() - assert_matches_type(PagerdutyCreateResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = response.parse() - assert_matches_type(PagerdutyCreateResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) assert cast(Any, response.is_closed) is True @@ -65,7 +65,7 @@ def test_method_delete(self, client: Cloudflare) -> None: pagerduty = client.alerting.destinations.pagerduty.delete( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[PagerdutyDeleteResponse], pagerduty, path=["response"]) + assert_matches_type(PagerdutyDeleteResponse, pagerduty, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -76,7 +76,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = response.parse() - assert_matches_type(Optional[PagerdutyDeleteResponse], pagerduty, path=["response"]) + assert_matches_type(PagerdutyDeleteResponse, pagerduty, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -87,7 +87,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = response.parse() - assert_matches_type(Optional[PagerdutyDeleteResponse], pagerduty, path=["response"]) + assert_matches_type(PagerdutyDeleteResponse, pagerduty, path=["response"]) assert cast(Any, response.is_closed) is True @@ -142,7 +142,7 @@ def test_method_link(self, client: Cloudflare) -> None: "8c71e667571b4f61b94d9e4b12158038", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(PagerdutyLinkResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) @parametrize def test_raw_response_link(self, client: Cloudflare) -> None: @@ -154,7 +154,7 @@ def test_raw_response_link(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = response.parse() - assert_matches_type(PagerdutyLinkResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) @parametrize def test_streaming_response_link(self, client: Cloudflare) -> None: @@ -166,7 +166,7 @@ def test_streaming_response_link(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = response.parse() - assert_matches_type(PagerdutyLinkResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) assert cast(Any, response.is_closed) is True @@ -193,7 +193,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: pagerduty = await async_client.alerting.destinations.pagerduty.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(PagerdutyCreateResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -204,7 +204,7 @@ 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" pagerduty = await response.parse() - assert_matches_type(PagerdutyCreateResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -215,7 +215,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = await response.parse() - assert_matches_type(PagerdutyCreateResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) assert cast(Any, response.is_closed) is True @@ -231,7 +231,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: pagerduty = await async_client.alerting.destinations.pagerduty.delete( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[PagerdutyDeleteResponse], pagerduty, path=["response"]) + assert_matches_type(PagerdutyDeleteResponse, pagerduty, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -242,7 +242,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = await response.parse() - assert_matches_type(Optional[PagerdutyDeleteResponse], pagerduty, path=["response"]) + assert_matches_type(PagerdutyDeleteResponse, pagerduty, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -253,7 +253,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = await response.parse() - assert_matches_type(Optional[PagerdutyDeleteResponse], pagerduty, path=["response"]) + assert_matches_type(PagerdutyDeleteResponse, pagerduty, path=["response"]) assert cast(Any, response.is_closed) is True @@ -308,7 +308,7 @@ async def test_method_link(self, async_client: AsyncCloudflare) -> None: "8c71e667571b4f61b94d9e4b12158038", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(PagerdutyLinkResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) @parametrize async def test_raw_response_link(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_raw_response_link(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = await response.parse() - assert_matches_type(PagerdutyLinkResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) @parametrize async def test_streaming_response_link(self, async_client: AsyncCloudflare) -> None: @@ -332,7 +332,7 @@ async def test_streaming_response_link(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" pagerduty = await response.parse() - assert_matches_type(PagerdutyLinkResponse, pagerduty, path=["response"]) + assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/alerting/destinations/test_webhooks.py b/tests/api_resources/alerting/destinations/test_webhooks.py index 9da98e9f458..29460dcbc01 100644 --- a/tests/api_resources/alerting/destinations/test_webhooks.py +++ b/tests/api_resources/alerting/destinations/test_webhooks.py @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: name="Slack Webhook", url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", ) - assert_matches_type(WebhookCreateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -40,7 +40,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", secret="string", ) - assert_matches_type(WebhookCreateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -53,7 +53,7 @@ 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" webhook = response.parse() - assert_matches_type(WebhookCreateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -66,7 +66,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = response.parse() - assert_matches_type(WebhookCreateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) assert cast(Any, response.is_closed) is True @@ -87,7 +87,7 @@ def test_method_update(self, client: Cloudflare) -> None: name="Slack Webhook", url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", ) - assert_matches_type(WebhookUpdateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -98,7 +98,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", secret="string", ) - assert_matches_type(WebhookUpdateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -112,7 +112,7 @@ 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" webhook = response.parse() - assert_matches_type(WebhookUpdateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = response.parse() - assert_matches_type(WebhookUpdateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) assert cast(Any, response.is_closed) is True @@ -192,7 +192,7 @@ def test_method_delete(self, client: Cloudflare) -> None: "b115d5ec-15c6-41ee-8b76-92c449b5227b", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WebhookDeleteResponse], webhook, path=["response"]) + assert_matches_type(WebhookDeleteResponse, webhook, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -204,7 +204,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = response.parse() - assert_matches_type(Optional[WebhookDeleteResponse], webhook, path=["response"]) + assert_matches_type(WebhookDeleteResponse, webhook, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -216,7 +216,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = response.parse() - assert_matches_type(Optional[WebhookDeleteResponse], webhook, path=["response"]) + assert_matches_type(WebhookDeleteResponse, webhook, path=["response"]) assert cast(Any, response.is_closed) is True @@ -240,7 +240,7 @@ def test_method_get(self, client: Cloudflare) -> None: "b115d5ec-15c6-41ee-8b76-92c449b5227b", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Webhooks, webhook, path=["response"]) + assert_matches_type(Optional[Webhooks], webhook, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -252,7 +252,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = response.parse() - assert_matches_type(Webhooks, webhook, path=["response"]) + assert_matches_type(Optional[Webhooks], webhook, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = response.parse() - assert_matches_type(Webhooks, webhook, path=["response"]) + assert_matches_type(Optional[Webhooks], webhook, path=["response"]) assert cast(Any, response.is_closed) is True @@ -293,7 +293,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: name="Slack Webhook", url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", ) - assert_matches_type(WebhookCreateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -303,7 +303,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", secret="string", ) - assert_matches_type(WebhookCreateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -316,7 +316,7 @@ 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" webhook = await response.parse() - assert_matches_type(WebhookCreateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -329,7 +329,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = await response.parse() - assert_matches_type(WebhookCreateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) assert cast(Any, response.is_closed) is True @@ -350,7 +350,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: name="Slack Webhook", url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", ) - assert_matches_type(WebhookUpdateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", secret="string", ) - assert_matches_type(WebhookUpdateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -375,7 +375,7 @@ 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" webhook = await response.parse() - assert_matches_type(WebhookUpdateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -389,7 +389,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = await response.parse() - assert_matches_type(WebhookUpdateResponse, webhook, path=["response"]) + assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) assert cast(Any, response.is_closed) is True @@ -455,7 +455,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: "b115d5ec-15c6-41ee-8b76-92c449b5227b", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WebhookDeleteResponse], webhook, path=["response"]) + assert_matches_type(WebhookDeleteResponse, webhook, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -467,7 +467,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = await response.parse() - assert_matches_type(Optional[WebhookDeleteResponse], webhook, path=["response"]) + assert_matches_type(WebhookDeleteResponse, webhook, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -479,7 +479,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = await response.parse() - assert_matches_type(Optional[WebhookDeleteResponse], webhook, path=["response"]) + assert_matches_type(WebhookDeleteResponse, webhook, path=["response"]) assert cast(Any, response.is_closed) is True @@ -503,7 +503,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "b115d5ec-15c6-41ee-8b76-92c449b5227b", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Webhooks, webhook, path=["response"]) + assert_matches_type(Optional[Webhooks], webhook, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = await response.parse() - assert_matches_type(Webhooks, webhook, path=["response"]) + assert_matches_type(Optional[Webhooks], webhook, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -527,7 +527,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" webhook = await response.parse() - assert_matches_type(Webhooks, webhook, path=["response"]) + assert_matches_type(Optional[Webhooks], webhook, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/alerting/test_policies.py b/tests/api_resources/alerting/test_policies.py index c66a55a5837..2eb84a45b54 100644 --- a/tests/api_resources/alerting/test_policies.py +++ b/tests/api_resources/alerting/test_policies.py @@ -36,7 +36,7 @@ def test_method_create(self, client: Cloudflare) -> None: }, name="SSL Notification Event Policy", ) - assert_matches_type(PolicyCreateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -94,7 +94,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "zones": ["string", "string", "string"], }, ) - assert_matches_type(PolicyCreateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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(PolicyCreateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -132,7 +132,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(PolicyCreateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -157,7 +157,7 @@ def test_method_update(self, client: Cloudflare) -> None: "0da2b59e-f118-439d-8097-bdfb215203c9", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(PolicyUpdateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -216,7 +216,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: }, name="SSL Notification Event Policy", ) - assert_matches_type(PolicyUpdateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -228,7 +228,7 @@ 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" policy = response.parse() - assert_matches_type(PolicyUpdateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -240,7 +240,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(PolicyUpdateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -302,7 +302,7 @@ def test_method_delete(self, client: Cloudflare) -> None: "0da2b59e-f118-439d-8097-bdfb215203c9", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + assert_matches_type(PolicyDeleteResponse, policy, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -314,7 +314,7 @@ def test_raw_response_delete(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[PolicyDeleteResponse], policy, path=["response"]) + assert_matches_type(PolicyDeleteResponse, policy, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -326,7 +326,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + assert_matches_type(PolicyDeleteResponse, policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -350,7 +350,7 @@ def test_method_get(self, client: Cloudflare) -> None: "0da2b59e-f118-439d-8097-bdfb215203c9", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[Policy], policy, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -362,7 +362,7 @@ def test_raw_response_get(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(Policy, policy, path=["response"]) + assert_matches_type(Optional[Policy], policy, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -374,7 +374,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[Policy], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -409,7 +409,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: }, name="SSL Notification Event Policy", ) - assert_matches_type(PolicyCreateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -467,7 +467,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "zones": ["string", "string", "string"], }, ) - assert_matches_type(PolicyCreateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -486,7 +486,7 @@ 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(PolicyCreateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -505,7 +505,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(PolicyCreateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -530,7 +530,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "0da2b59e-f118-439d-8097-bdfb215203c9", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(PolicyUpdateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -589,7 +589,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare }, name="SSL Notification Event Policy", ) - assert_matches_type(PolicyUpdateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -601,7 +601,7 @@ 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" policy = await response.parse() - assert_matches_type(PolicyUpdateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -613,7 +613,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(PolicyUpdateResponse, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -675,7 +675,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: "0da2b59e-f118-439d-8097-bdfb215203c9", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + assert_matches_type(PolicyDeleteResponse, policy, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -687,7 +687,7 @@ async def test_raw_response_delete(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[PolicyDeleteResponse], policy, path=["response"]) + assert_matches_type(PolicyDeleteResponse, policy, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -699,7 +699,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + assert_matches_type(PolicyDeleteResponse, policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -723,7 +723,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "0da2b59e-f118-439d-8097-bdfb215203c9", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[Policy], policy, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -735,7 +735,7 @@ async def test_raw_response_get(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(Policy, policy, path=["response"]) + assert_matches_type(Optional[Policy], policy, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -747,7 +747,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[Policy], policy, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/pages/test_projects.py b/tests/api_resources/pages/test_projects.py index 562db3e98af..c3f969b628b 100644 --- a/tests/api_resources/pages/test_projects.py +++ b/tests/api_resources/pages/test_projects.py @@ -63,7 +63,12 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "mtls_certificates": {"mtls": {"certificate_id": "d7cdd17c-916f-4cb7-aabe-585eb382ec4e"}}, "placement": {"mode": "smart"}, "queue_producers": {"queue_producer_binding": {"name": "some-queue"}}, - "r2_buckets": {"r2_binding": {"name": "some-bucket"}}, + "r2_buckets": { + "r2_binding": { + "jurisdiction": "eu", + "name": "some-bucket", + } + }, "services": { "service_binding": { "entrypoint": "MyHandler", @@ -92,7 +97,12 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "mtls_certificates": {"mtls": {"certificate_id": "d7cdd17c-916f-4cb7-aabe-585eb382ec4e"}}, "placement": {"mode": "smart"}, "queue_producers": {"queue_producer_binding": {"name": "some-queue"}}, - "r2_buckets": {"r2_binding": {"name": "some-bucket"}}, + "r2_buckets": { + "r2_binding": { + "jurisdiction": "eu", + "name": "some-bucket", + } + }, "services": { "service_binding": { "entrypoint": "MyHandler", @@ -494,7 +504,12 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "mtls_certificates": {"mtls": {"certificate_id": "d7cdd17c-916f-4cb7-aabe-585eb382ec4e"}}, "placement": {"mode": "smart"}, "queue_producers": {"queue_producer_binding": {"name": "some-queue"}}, - "r2_buckets": {"r2_binding": {"name": "some-bucket"}}, + "r2_buckets": { + "r2_binding": { + "jurisdiction": "eu", + "name": "some-bucket", + } + }, "services": { "service_binding": { "entrypoint": "MyHandler", @@ -523,7 +538,12 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "mtls_certificates": {"mtls": {"certificate_id": "d7cdd17c-916f-4cb7-aabe-585eb382ec4e"}}, "placement": {"mode": "smart"}, "queue_producers": {"queue_producer_binding": {"name": "some-queue"}}, - "r2_buckets": {"r2_binding": {"name": "some-bucket"}}, + "r2_buckets": { + "r2_binding": { + "jurisdiction": "eu", + "name": "some-bucket", + } + }, "services": { "service_binding": { "entrypoint": "MyHandler", diff --git a/tests/api_resources/zero_trust/access/applications/test_policies.py b/tests/api_resources/zero_trust/access/applications/test_policies.py index b00514954fd..80ab503f4dd 100644 --- a/tests/api_resources/zero_trust/access/applications/test_policies.py +++ b/tests/api_resources/zero_trust/access/applications/test_policies.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.access.applications import ( PolicyGetResponse, - PolicyListResponse, PolicyCreateResponse, PolicyDeleteResponse, PolicyUpdateResponse, @@ -333,73 +331,6 @@ def test_path_params_update(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.policies.with_streaming_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - policy = response.parse() - assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.list( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_delete(self, client: Cloudflare) -> None: @@ -875,73 +806,6 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.applications.policies.with_streaming_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) 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[PolicyListResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.list( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: diff --git a/tests/api_resources/zero_trust/access/test_custom_pages.py b/tests/api_resources/zero_trust/access/test_custom_pages.py index 7c84edab1bc..620d917c5f8 100644 --- a/tests/api_resources/zero_trust/access/test_custom_pages.py +++ b/tests/api_resources/zero_trust/access/test_custom_pages.py @@ -22,67 +22,6 @@ class TestCustomPages: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - app_count=0, - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.zero_trust.access.custom_pages.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.zero_trust.access.custom_pages.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.create( - "", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - @parametrize def test_method_update(self, client: Cloudflare) -> None: custom_page = client.zero_trust.access.custom_pages.update( @@ -296,67 +235,6 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncCustomPages: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - app_count=0, - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.custom_pages.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = await response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.custom_pages.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = await response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.create( - "", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: custom_page = await async_client.zero_trust.access.custom_pages.update( From 4e5920c8704dfe74d8494290c407afd1733ce966 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 01:28:07 +0000 Subject: [PATCH 166/532] feat(api): update via SDK Studio (#647) --- .stats.yml | 2 +- api.md | 3 + .../access/applications/policies.py | 127 ++++++++++++++++ .../zero_trust/access/custom_pages.py | 134 ++++++++++++++++- .../types/zero_trust/access/__init__.py | 1 + .../access/applications/__init__.py | 1 + .../applications/policy_list_response.py | 73 ++++++++++ .../access/custom_page_create_params.py | 21 +++ .../access/applications/test_policies.py | 136 ++++++++++++++++++ .../zero_trust/access/test_custom_pages.py | 122 ++++++++++++++++ 10 files changed, 618 insertions(+), 2 deletions(-) create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_list_response.py create mode 100644 src/cloudflare/types/zero_trust/access/custom_page_create_params.py diff --git a/.stats.yml b/.stats.yml index 1dd9e3f2e2a..10d76151103 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1294 +configured_endpoints: 1296 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaf3cf93b4b0566484405b918a65aeca6e5ad4cc194989298a633601684fa0c1.yml diff --git a/api.md b/api.md index aedb5c8b044..d99843c7cdc 100644 --- a/api.md +++ b/api.md @@ -5177,6 +5177,7 @@ from cloudflare.types.zero_trust.access.applications import ( Policy, PolicyCreateResponse, PolicyUpdateResponse, + PolicyListResponse, PolicyDeleteResponse, PolicyGetResponse, ) @@ -5186,6 +5187,7 @@ Methods: - client.zero_trust.access.applications.policies.create(uuid, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.applications.policies.update(uuid, \*, uuid1, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.applications.policies.list(uuid, \*, account_id, zone_id) -> SyncSinglePage[PolicyListResponse] - client.zero_trust.access.applications.policies.delete(uuid, \*, uuid1, account_id, zone_id) -> Optional - client.zero_trust.access.applications.policies.get(uuid, \*, uuid1, account_id, zone_id) -> Optional @@ -5374,6 +5376,7 @@ from cloudflare.types.zero_trust.access import ( Methods: +- client.zero_trust.access.custom_pages.create(identifier, \*\*params) -> Optional - client.zero_trust.access.custom_pages.update(uuid, \*, identifier, \*\*params) -> Optional - client.zero_trust.access.custom_pages.list(identifier) -> SyncSinglePage[CustomPageWithoutHTML] - client.zero_trust.access.custom_pages.delete(uuid, \*, identifier) -> Optional diff --git a/src/cloudflare/resources/zero_trust/access/applications/policies.py b/src/cloudflare/resources/zero_trust/access/applications/policies.py index 40c2491c9f2..b5c9f110dee 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/policies.py +++ b/src/cloudflare/resources/zero_trust/access/applications/policies.py @@ -20,7 +20,9 @@ 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.access import Decision @@ -29,6 +31,7 @@ from .....types.zero_trust.access.applications import policy_create_params, policy_update_params from .....types.zero_trust.access.applications.policy_get_response import PolicyGetResponse from .....types.zero_trust.access.applications.approval_group_param import ApprovalGroupParam +from .....types.zero_trust.access.applications.policy_list_response import PolicyListResponse from .....types.zero_trust.access.applications.policy_create_response import PolicyCreateResponse from .....types.zero_trust.access.applications.policy_delete_response import PolicyDeleteResponse from .....types.zero_trust.access.applications.policy_update_response import PolicyUpdateResponse @@ -293,6 +296,62 @@ def update( cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) + def list( + self, + uuid: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[PolicyListResponse]: + """Lists Access policies configured for an application. + + Returns both exclusively + scoped and reusable policies used by the application. + + Args: + uuid: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not uuid: + raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", + page=SyncSinglePage[PolicyListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=PolicyListResponse, + ) + def delete( self, uuid: str, @@ -679,6 +738,62 @@ async def update( cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) + def list( + self, + uuid: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[PolicyListResponse, AsyncSinglePage[PolicyListResponse]]: + """Lists Access policies configured for an application. + + Returns both exclusively + scoped and reusable policies used by the application. + + Args: + uuid: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not uuid: + raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", + page=AsyncSinglePage[PolicyListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=PolicyListResponse, + ) + async def delete( self, uuid: str, @@ -818,6 +933,9 @@ def __init__(self, policies: PoliciesResource) -> None: self.update = to_raw_response_wrapper( policies.update, ) + self.list = to_raw_response_wrapper( + policies.list, + ) self.delete = to_raw_response_wrapper( policies.delete, ) @@ -836,6 +954,9 @@ def __init__(self, policies: AsyncPoliciesResource) -> None: self.update = async_to_raw_response_wrapper( policies.update, ) + self.list = async_to_raw_response_wrapper( + policies.list, + ) self.delete = async_to_raw_response_wrapper( policies.delete, ) @@ -854,6 +975,9 @@ def __init__(self, policies: PoliciesResource) -> None: self.update = to_streamed_response_wrapper( policies.update, ) + self.list = to_streamed_response_wrapper( + policies.list, + ) self.delete = to_streamed_response_wrapper( policies.delete, ) @@ -872,6 +996,9 @@ def __init__(self, policies: AsyncPoliciesResource) -> None: self.update = async_to_streamed_response_wrapper( policies.update, ) + self.list = async_to_streamed_response_wrapper( + policies.list, + ) self.delete = async_to_streamed_response_wrapper( policies.delete, ) diff --git a/src/cloudflare/resources/zero_trust/access/custom_pages.py b/src/cloudflare/resources/zero_trust/access/custom_pages.py index 596e6cd8f68..1314c7e01b9 100644 --- a/src/cloudflare/resources/zero_trust/access/custom_pages.py +++ b/src/cloudflare/resources/zero_trust/access/custom_pages.py @@ -26,7 +26,7 @@ AsyncPaginator, make_request_options, ) -from ....types.zero_trust.access import custom_page_update_params +from ....types.zero_trust.access import custom_page_create_params, custom_page_update_params from ....types.zero_trust.access.custom_page import CustomPage from ....types.zero_trust.access.custom_page_without_html import CustomPageWithoutHTML from ....types.zero_trust.access.custom_page_delete_response import CustomPageDeleteResponse @@ -43,6 +43,66 @@ def with_raw_response(self) -> CustomPagesResourceWithRawResponse: def with_streaming_response(self) -> CustomPagesResourceWithStreamingResponse: return CustomPagesResourceWithStreamingResponse(self) + def create( + self, + identifier: str, + *, + custom_html: str, + name: str, + type: Literal["identity_denied", "forbidden"], + app_count: int | 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[CustomPageWithoutHTML]: + """ + Create a custom page + + Args: + identifier: Identifier + + custom_html: Custom page HTML. + + name: Custom page name. + + type: Custom page type. + + app_count: Number of apps the custom page is assigned to. + + 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 identifier: + raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + return self._post( + f"/accounts/{identifier}/access/custom_pages", + body=maybe_transform( + { + "custom_html": custom_html, + "name": name, + "type": type, + "app_count": app_count, + }, + custom_page_create_params.CustomPageCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), + ) + def update( self, uuid: str, @@ -242,6 +302,66 @@ def with_raw_response(self) -> AsyncCustomPagesResourceWithRawResponse: def with_streaming_response(self) -> AsyncCustomPagesResourceWithStreamingResponse: return AsyncCustomPagesResourceWithStreamingResponse(self) + async def create( + self, + identifier: str, + *, + custom_html: str, + name: str, + type: Literal["identity_denied", "forbidden"], + app_count: int | 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[CustomPageWithoutHTML]: + """ + Create a custom page + + Args: + identifier: Identifier + + custom_html: Custom page HTML. + + name: Custom page name. + + type: Custom page type. + + app_count: Number of apps the custom page is assigned to. + + 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 identifier: + raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + return await self._post( + f"/accounts/{identifier}/access/custom_pages", + body=await async_maybe_transform( + { + "custom_html": custom_html, + "name": name, + "type": type, + "app_count": app_count, + }, + custom_page_create_params.CustomPageCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), + ) + async def update( self, uuid: str, @@ -436,6 +556,9 @@ class CustomPagesResourceWithRawResponse: def __init__(self, custom_pages: CustomPagesResource) -> None: self._custom_pages = custom_pages + self.create = to_raw_response_wrapper( + custom_pages.create, + ) self.update = to_raw_response_wrapper( custom_pages.update, ) @@ -454,6 +577,9 @@ class AsyncCustomPagesResourceWithRawResponse: def __init__(self, custom_pages: AsyncCustomPagesResource) -> None: self._custom_pages = custom_pages + self.create = async_to_raw_response_wrapper( + custom_pages.create, + ) self.update = async_to_raw_response_wrapper( custom_pages.update, ) @@ -472,6 +598,9 @@ class CustomPagesResourceWithStreamingResponse: def __init__(self, custom_pages: CustomPagesResource) -> None: self._custom_pages = custom_pages + self.create = to_streamed_response_wrapper( + custom_pages.create, + ) self.update = to_streamed_response_wrapper( custom_pages.update, ) @@ -490,6 +619,9 @@ class AsyncCustomPagesResourceWithStreamingResponse: def __init__(self, custom_pages: AsyncCustomPagesResource) -> None: self._custom_pages = custom_pages + self.create = async_to_streamed_response_wrapper( + custom_pages.create, + ) self.update = async_to_streamed_response_wrapper( custom_pages.update, ) diff --git a/src/cloudflare/types/zero_trust/access/__init__.py b/src/cloudflare/types/zero_trust/access/__init__.py index 93d7f00acbb..8b8d5c829cf 100644 --- a/src/cloudflare/types/zero_trust/access/__init__.py +++ b/src/cloudflare/types/zero_trust/access/__init__.py @@ -46,6 +46,7 @@ from .application_update_params import ApplicationUpdateParams as ApplicationUpdateParams from .certificate_create_params import CertificateCreateParams as CertificateCreateParams from .certificate_update_params import CertificateUpdateParams as CertificateUpdateParams +from .custom_page_create_params import CustomPageCreateParams as CustomPageCreateParams from .custom_page_update_params import CustomPageUpdateParams as CustomPageUpdateParams from .application_create_response import ApplicationCreateResponse as ApplicationCreateResponse from .application_delete_response import ApplicationDeleteResponse as ApplicationDeleteResponse diff --git a/src/cloudflare/types/zero_trust/access/applications/__init__.py b/src/cloudflare/types/zero_trust/access/applications/__init__.py index b5124d49e0e..206ec39071b 100644 --- a/src/cloudflare/types/zero_trust/access/applications/__init__.py +++ b/src/cloudflare/types/zero_trust/access/applications/__init__.py @@ -10,6 +10,7 @@ from .policy_get_response import PolicyGetResponse as PolicyGetResponse from .approval_group_param import ApprovalGroupParam as ApprovalGroupParam from .policy_create_params import PolicyCreateParams as PolicyCreateParams +from .policy_list_response import PolicyListResponse as PolicyListResponse from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams from .user_policy_check_geo import UserPolicyCheckGeo as UserPolicyCheckGeo from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py new file mode 100644 index 00000000000..176b10bf16d --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..decision import Decision +from ....._models import BaseModel +from ...access_rule import AccessRule +from .approval_group import ApprovalGroup + +__all__ = ["PolicyListResponse"] + + +class PolicyListResponse(BaseModel): + id: Optional[str] = None + """UUID""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/custom_page_create_params.py b/src/cloudflare/types/zero_trust/access/custom_page_create_params.py new file mode 100644 index 00000000000..f1890d141b8 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/custom_page_create_params.py @@ -0,0 +1,21 @@ +# 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__ = ["CustomPageCreateParams"] + + +class CustomPageCreateParams(TypedDict, total=False): + custom_html: Required[str] + """Custom page HTML.""" + + name: Required[str] + """Custom page name.""" + + type: Required[Literal["identity_denied", "forbidden"]] + """Custom page type.""" + + app_count: int + """Number of apps the custom page is assigned to.""" diff --git a/tests/api_resources/zero_trust/access/applications/test_policies.py b/tests/api_resources/zero_trust/access/applications/test_policies.py index 80ab503f4dd..b00514954fd 100644 --- a/tests/api_resources/zero_trust/access/applications/test_policies.py +++ b/tests/api_resources/zero_trust/access/applications/test_policies.py @@ -9,8 +9,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.zero_trust.access.applications import ( PolicyGetResponse, + PolicyListResponse, PolicyCreateResponse, PolicyDeleteResponse, PolicyUpdateResponse, @@ -331,6 +333,73 @@ def test_path_params_update(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.policies.with_streaming_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.list( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_delete(self, client: Cloudflare) -> None: @@ -806,6 +875,73 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.applications.policies.with_streaming_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) 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[PolicyListResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.list( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: diff --git a/tests/api_resources/zero_trust/access/test_custom_pages.py b/tests/api_resources/zero_trust/access/test_custom_pages.py index 620d917c5f8..7c84edab1bc 100644 --- a/tests/api_resources/zero_trust/access/test_custom_pages.py +++ b/tests/api_resources/zero_trust/access/test_custom_pages.py @@ -22,6 +22,67 @@ class TestCustomPages: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.create( + "023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.create( + "023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + app_count=0, + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.access.custom_pages.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.access.custom_pages.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + client.zero_trust.access.custom_pages.with_raw_response.create( + "", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + @parametrize def test_method_update(self, client: Cloudflare) -> None: custom_page = client.zero_trust.access.custom_pages.update( @@ -235,6 +296,67 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncCustomPages: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.create( + "023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.create( + "023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + app_count=0, + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.custom_pages.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = await response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.custom_pages.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = await response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + await async_client.zero_trust.access.custom_pages.with_raw_response.create( + "", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: custom_page = await async_client.zero_trust.access.custom_pages.update( From cb22c63827ee88135dd22ec15f22edfcfaf23362 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 03:37:57 +0000 Subject: [PATCH 167/532] feat(api): update via SDK Studio (#648) --- api.md | 8 +- .../resources/logs/control/control.py | 1 - .../{retention/flag.py => retention.py} | 110 +++++++++--------- .../logs/control/retention/__init__.py | 33 ------ .../logs/control/retention/retention.py | 80 ------------- src/cloudflare/types/logs/control/__init__.py | 4 + .../types/logs/control/retention/__init__.py | 7 -- ...e_params.py => retention_create_params.py} | 4 +- ...sponse.py => retention_create_response.py} | 6 +- ..._response.py => retention_get_response.py} | 6 +- .../logs/control/retention/__init__.py | 1 - .../test_flag.py => test_retention.py} | 78 ++++++------- 12 files changed, 109 insertions(+), 229 deletions(-) rename src/cloudflare/resources/logs/control/{retention/flag.py => retention.py} (68%) delete mode 100644 src/cloudflare/resources/logs/control/retention/__init__.py delete mode 100644 src/cloudflare/resources/logs/control/retention/retention.py delete mode 100644 src/cloudflare/types/logs/control/retention/__init__.py rename src/cloudflare/types/logs/control/{retention/flag_create_params.py => retention_create_params.py} (73%) rename src/cloudflare/types/logs/control/{retention/flag_get_response.py => retention_create_response.py} (56%) rename src/cloudflare/types/logs/control/{retention/flag_create_response.py => retention_get_response.py} (58%) delete mode 100644 tests/api_resources/logs/control/retention/__init__.py rename tests/api_resources/logs/control/{retention/test_flag.py => test_retention.py} (65%) diff --git a/api.md b/api.md index d99843c7cdc..23160a4ff3f 100644 --- a/api.md +++ b/api.md @@ -2142,18 +2142,16 @@ Methods: ### Retention -#### Flag - Types: ```python -from cloudflare.types.logs.control.retention import FlagCreateResponse, FlagGetResponse +from cloudflare.types.logs.control import RetentionCreateResponse, RetentionGetResponse ``` Methods: -- client.logs.control.retention.flag.create(zone_identifier, \*\*params) -> FlagCreateResponse -- client.logs.control.retention.flag.get(zone_identifier) -> FlagGetResponse +- client.logs.control.retention.create(zone_identifier, \*\*params) -> RetentionCreateResponse +- client.logs.control.retention.get(zone_identifier) -> RetentionGetResponse ### Cmb diff --git a/src/cloudflare/resources/logs/control/control.py b/src/cloudflare/resources/logs/control/control.py index ce92ba94219..b642e31a573 100644 --- a/src/cloudflare/resources/logs/control/control.py +++ b/src/cloudflare/resources/logs/control/control.py @@ -21,7 +21,6 @@ ) from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource -from .retention.retention import RetentionResource, AsyncRetentionResource __all__ = ["ControlResource", "AsyncControlResource"] diff --git a/src/cloudflare/resources/logs/control/retention/flag.py b/src/cloudflare/resources/logs/control/retention.py similarity index 68% rename from src/cloudflare/resources/logs/control/retention/flag.py rename to src/cloudflare/resources/logs/control/retention.py index 3b430f1e9c6..2d468f2a73f 100644 --- a/src/cloudflare/resources/logs/control/retention/flag.py +++ b/src/cloudflare/resources/logs/control/retention.py @@ -6,38 +6,38 @@ 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 ( +from ...._wrappers import ResultWrapper +from ...._base_client import ( make_request_options, ) -from .....types.logs.control.retention import flag_create_params -from .....types.logs.control.retention.flag_get_response import FlagGetResponse -from .....types.logs.control.retention.flag_create_response import FlagCreateResponse +from ....types.logs.control import retention_create_params +from ....types.logs.control.retention_get_response import RetentionGetResponse +from ....types.logs.control.retention_create_response import RetentionCreateResponse -__all__ = ["FlagResource", "AsyncFlagResource"] +__all__ = ["RetentionResource", "AsyncRetentionResource"] -class FlagResource(SyncAPIResource): +class RetentionResource(SyncAPIResource): @cached_property - def with_raw_response(self) -> FlagResourceWithRawResponse: - return FlagResourceWithRawResponse(self) + def with_raw_response(self) -> RetentionResourceWithRawResponse: + return RetentionResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> FlagResourceWithStreamingResponse: - return FlagResourceWithStreamingResponse(self) + def with_streaming_response(self) -> RetentionResourceWithStreamingResponse: + return RetentionResourceWithStreamingResponse(self) def create( self, @@ -50,7 +50,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> FlagCreateResponse: + ) -> RetentionCreateResponse: """ Updates log retention flag for Logpull API. @@ -71,15 +71,15 @@ def create( raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") return self._post( f"/zones/{zone_identifier}/logs/control/retention/flag", - body=maybe_transform({"flag": flag}, flag_create_params.FlagCreateParams), + body=maybe_transform({"flag": flag}, retention_create_params.RetentionCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[FlagCreateResponse]._unwrapper, + post_parser=ResultWrapper[RetentionCreateResponse]._unwrapper, ), - cast_to=cast(Type[FlagCreateResponse], ResultWrapper[FlagCreateResponse]), + cast_to=cast(Type[RetentionCreateResponse], ResultWrapper[RetentionCreateResponse]), ) def get( @@ -92,7 +92,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> FlagGetResponse: + ) -> RetentionGetResponse: """ Gets log retention flag for Logpull API. @@ -116,20 +116,20 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[FlagGetResponse]._unwrapper, + post_parser=ResultWrapper[RetentionGetResponse]._unwrapper, ), - cast_to=cast(Type[FlagGetResponse], ResultWrapper[FlagGetResponse]), + cast_to=cast(Type[RetentionGetResponse], ResultWrapper[RetentionGetResponse]), ) -class AsyncFlagResource(AsyncAPIResource): +class AsyncRetentionResource(AsyncAPIResource): @cached_property - def with_raw_response(self) -> AsyncFlagResourceWithRawResponse: - return AsyncFlagResourceWithRawResponse(self) + def with_raw_response(self) -> AsyncRetentionResourceWithRawResponse: + return AsyncRetentionResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncFlagResourceWithStreamingResponse: - return AsyncFlagResourceWithStreamingResponse(self) + def with_streaming_response(self) -> AsyncRetentionResourceWithStreamingResponse: + return AsyncRetentionResourceWithStreamingResponse(self) async def create( self, @@ -142,7 +142,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> FlagCreateResponse: + ) -> RetentionCreateResponse: """ Updates log retention flag for Logpull API. @@ -163,15 +163,15 @@ async def create( raise ValueError(f"Expected a non-empty value for `zone_identifier` but received {zone_identifier!r}") return await self._post( f"/zones/{zone_identifier}/logs/control/retention/flag", - body=await async_maybe_transform({"flag": flag}, flag_create_params.FlagCreateParams), + body=await async_maybe_transform({"flag": flag}, retention_create_params.RetentionCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[FlagCreateResponse]._unwrapper, + post_parser=ResultWrapper[RetentionCreateResponse]._unwrapper, ), - cast_to=cast(Type[FlagCreateResponse], ResultWrapper[FlagCreateResponse]), + cast_to=cast(Type[RetentionCreateResponse], ResultWrapper[RetentionCreateResponse]), ) async def get( @@ -184,7 +184,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> FlagGetResponse: + ) -> RetentionGetResponse: """ Gets log retention flag for Logpull API. @@ -208,55 +208,55 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[FlagGetResponse]._unwrapper, + post_parser=ResultWrapper[RetentionGetResponse]._unwrapper, ), - cast_to=cast(Type[FlagGetResponse], ResultWrapper[FlagGetResponse]), + cast_to=cast(Type[RetentionGetResponse], ResultWrapper[RetentionGetResponse]), ) -class FlagResourceWithRawResponse: - def __init__(self, flag: FlagResource) -> None: - self._flag = flag +class RetentionResourceWithRawResponse: + def __init__(self, retention: RetentionResource) -> None: + self._retention = retention self.create = to_raw_response_wrapper( - flag.create, + retention.create, ) self.get = to_raw_response_wrapper( - flag.get, + retention.get, ) -class AsyncFlagResourceWithRawResponse: - def __init__(self, flag: AsyncFlagResource) -> None: - self._flag = flag +class AsyncRetentionResourceWithRawResponse: + def __init__(self, retention: AsyncRetentionResource) -> None: + self._retention = retention self.create = async_to_raw_response_wrapper( - flag.create, + retention.create, ) self.get = async_to_raw_response_wrapper( - flag.get, + retention.get, ) -class FlagResourceWithStreamingResponse: - def __init__(self, flag: FlagResource) -> None: - self._flag = flag +class RetentionResourceWithStreamingResponse: + def __init__(self, retention: RetentionResource) -> None: + self._retention = retention self.create = to_streamed_response_wrapper( - flag.create, + retention.create, ) self.get = to_streamed_response_wrapper( - flag.get, + retention.get, ) -class AsyncFlagResourceWithStreamingResponse: - def __init__(self, flag: AsyncFlagResource) -> None: - self._flag = flag +class AsyncRetentionResourceWithStreamingResponse: + def __init__(self, retention: AsyncRetentionResource) -> None: + self._retention = retention self.create = async_to_streamed_response_wrapper( - flag.create, + retention.create, ) self.get = async_to_streamed_response_wrapper( - flag.get, + retention.get, ) diff --git a/src/cloudflare/resources/logs/control/retention/__init__.py b/src/cloudflare/resources/logs/control/retention/__init__.py deleted file mode 100644 index f86ef33b8fd..00000000000 --- a/src/cloudflare/resources/logs/control/retention/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .flag import ( - FlagResource, - AsyncFlagResource, - FlagResourceWithRawResponse, - AsyncFlagResourceWithRawResponse, - FlagResourceWithStreamingResponse, - AsyncFlagResourceWithStreamingResponse, -) -from .retention import ( - RetentionResource, - AsyncRetentionResource, - RetentionResourceWithRawResponse, - AsyncRetentionResourceWithRawResponse, - RetentionResourceWithStreamingResponse, - AsyncRetentionResourceWithStreamingResponse, -) - -__all__ = [ - "FlagResource", - "AsyncFlagResource", - "FlagResourceWithRawResponse", - "AsyncFlagResourceWithRawResponse", - "FlagResourceWithStreamingResponse", - "AsyncFlagResourceWithStreamingResponse", - "RetentionResource", - "AsyncRetentionResource", - "RetentionResourceWithRawResponse", - "AsyncRetentionResourceWithRawResponse", - "RetentionResourceWithStreamingResponse", - "AsyncRetentionResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/logs/control/retention/retention.py b/src/cloudflare/resources/logs/control/retention/retention.py deleted file mode 100644 index 01597a0c091..00000000000 --- a/src/cloudflare/resources/logs/control/retention/retention.py +++ /dev/null @@ -1,80 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .flag import ( - FlagResource, - AsyncFlagResource, - FlagResourceWithRawResponse, - AsyncFlagResourceWithRawResponse, - FlagResourceWithStreamingResponse, - AsyncFlagResourceWithStreamingResponse, -) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource - -__all__ = ["RetentionResource", "AsyncRetentionResource"] - - -class RetentionResource(SyncAPIResource): - @cached_property - def flag(self) -> FlagResource: - return FlagResource(self._client) - - @cached_property - def with_raw_response(self) -> RetentionResourceWithRawResponse: - return RetentionResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> RetentionResourceWithStreamingResponse: - return RetentionResourceWithStreamingResponse(self) - - -class AsyncRetentionResource(AsyncAPIResource): - @cached_property - def flag(self) -> AsyncFlagResource: - return AsyncFlagResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncRetentionResourceWithRawResponse: - return AsyncRetentionResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncRetentionResourceWithStreamingResponse: - return AsyncRetentionResourceWithStreamingResponse(self) - - -class RetentionResourceWithRawResponse: - def __init__(self, retention: RetentionResource) -> None: - self._retention = retention - - @cached_property - def flag(self) -> FlagResourceWithRawResponse: - return FlagResourceWithRawResponse(self._retention.flag) - - -class AsyncRetentionResourceWithRawResponse: - def __init__(self, retention: AsyncRetentionResource) -> None: - self._retention = retention - - @cached_property - def flag(self) -> AsyncFlagResourceWithRawResponse: - return AsyncFlagResourceWithRawResponse(self._retention.flag) - - -class RetentionResourceWithStreamingResponse: - def __init__(self, retention: RetentionResource) -> None: - self._retention = retention - - @cached_property - def flag(self) -> FlagResourceWithStreamingResponse: - return FlagResourceWithStreamingResponse(self._retention.flag) - - -class AsyncRetentionResourceWithStreamingResponse: - def __init__(self, retention: AsyncRetentionResource) -> None: - self._retention = retention - - @cached_property - def flag(self) -> AsyncFlagResourceWithStreamingResponse: - return AsyncFlagResourceWithStreamingResponse(self._retention.flag) diff --git a/src/cloudflare/types/logs/control/__init__.py b/src/cloudflare/types/logs/control/__init__.py index f8ee8b14b1c..bab336a2b0d 100644 --- a/src/cloudflare/types/logs/control/__init__.py +++ b/src/cloudflare/types/logs/control/__init__.py @@ -1,3 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .retention_get_response import RetentionGetResponse as RetentionGetResponse +from .retention_create_params import RetentionCreateParams as RetentionCreateParams +from .retention_create_response import RetentionCreateResponse as RetentionCreateResponse diff --git a/src/cloudflare/types/logs/control/retention/__init__.py b/src/cloudflare/types/logs/control/retention/__init__.py deleted file mode 100644 index 5ee01ff7c47..00000000000 --- a/src/cloudflare/types/logs/control/retention/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .flag_get_response import FlagGetResponse as FlagGetResponse -from .flag_create_params import FlagCreateParams as FlagCreateParams -from .flag_create_response import FlagCreateResponse as FlagCreateResponse diff --git a/src/cloudflare/types/logs/control/retention/flag_create_params.py b/src/cloudflare/types/logs/control/retention_create_params.py similarity index 73% rename from src/cloudflare/types/logs/control/retention/flag_create_params.py rename to src/cloudflare/types/logs/control/retention_create_params.py index 0dfbf8885db..d022c669bc2 100644 --- a/src/cloudflare/types/logs/control/retention/flag_create_params.py +++ b/src/cloudflare/types/logs/control/retention_create_params.py @@ -4,9 +4,9 @@ from typing_extensions import Required, TypedDict -__all__ = ["FlagCreateParams"] +__all__ = ["RetentionCreateParams"] -class FlagCreateParams(TypedDict, total=False): +class RetentionCreateParams(TypedDict, total=False): flag: Required[bool] """The log retention flag for Logpull API.""" diff --git a/src/cloudflare/types/logs/control/retention/flag_get_response.py b/src/cloudflare/types/logs/control/retention_create_response.py similarity index 56% rename from src/cloudflare/types/logs/control/retention/flag_get_response.py rename to src/cloudflare/types/logs/control/retention_create_response.py index 6b7291bd7da..1c2d420bb34 100644 --- a/src/cloudflare/types/logs/control/retention/flag_get_response.py +++ b/src/cloudflare/types/logs/control/retention_create_response.py @@ -2,10 +2,10 @@ from typing import Optional -from ....._models import BaseModel +from ...._models import BaseModel -__all__ = ["FlagGetResponse"] +__all__ = ["RetentionCreateResponse"] -class FlagGetResponse(BaseModel): +class RetentionCreateResponse(BaseModel): flag: Optional[bool] = None diff --git a/src/cloudflare/types/logs/control/retention/flag_create_response.py b/src/cloudflare/types/logs/control/retention_get_response.py similarity index 58% rename from src/cloudflare/types/logs/control/retention/flag_create_response.py rename to src/cloudflare/types/logs/control/retention_get_response.py index a96a4fa2b8d..3d2d09e5461 100644 --- a/src/cloudflare/types/logs/control/retention/flag_create_response.py +++ b/src/cloudflare/types/logs/control/retention_get_response.py @@ -2,10 +2,10 @@ from typing import Optional -from ....._models import BaseModel +from ...._models import BaseModel -__all__ = ["FlagCreateResponse"] +__all__ = ["RetentionGetResponse"] -class FlagCreateResponse(BaseModel): +class RetentionGetResponse(BaseModel): flag: Optional[bool] = None diff --git a/tests/api_resources/logs/control/retention/__init__.py b/tests/api_resources/logs/control/retention/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/logs/control/retention/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/logs/control/retention/test_flag.py b/tests/api_resources/logs/control/test_retention.py similarity index 65% rename from tests/api_resources/logs/control/retention/test_flag.py rename to tests/api_resources/logs/control/test_retention.py index ace95eb0dd9..b3ae8454210 100644 --- a/tests/api_resources/logs/control/retention/test_flag.py +++ b/tests/api_resources/logs/control/test_retention.py @@ -9,174 +9,174 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.logs.control.retention import FlagGetResponse, FlagCreateResponse +from cloudflare.types.logs.control import RetentionGetResponse, RetentionCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -class TestFlag: +class TestRetention: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize def test_method_create(self, client: Cloudflare) -> None: - flag = client.logs.control.retention.flag.create( + retention = client.logs.control.retention.create( "023e105f4ecef8ad9ca31a8372d0c353", flag=True, ) - assert_matches_type(FlagCreateResponse, flag, path=["response"]) + assert_matches_type(RetentionCreateResponse, retention, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.logs.control.retention.flag.with_raw_response.create( + response = client.logs.control.retention.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", flag=True, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - flag = response.parse() - assert_matches_type(FlagCreateResponse, flag, path=["response"]) + retention = response.parse() + assert_matches_type(RetentionCreateResponse, retention, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.logs.control.retention.flag.with_streaming_response.create( + with client.logs.control.retention.with_streaming_response.create( "023e105f4ecef8ad9ca31a8372d0c353", flag=True, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - flag = response.parse() - assert_matches_type(FlagCreateResponse, flag, path=["response"]) + retention = response.parse() + assert_matches_type(RetentionCreateResponse, retention, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.logs.control.retention.flag.with_raw_response.create( + client.logs.control.retention.with_raw_response.create( "", flag=True, ) @parametrize def test_method_get(self, client: Cloudflare) -> None: - flag = client.logs.control.retention.flag.get( + retention = client.logs.control.retention.get( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(FlagGetResponse, flag, path=["response"]) + assert_matches_type(RetentionGetResponse, retention, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.logs.control.retention.flag.with_raw_response.get( + response = client.logs.control.retention.with_raw_response.get( "023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - flag = response.parse() - assert_matches_type(FlagGetResponse, flag, path=["response"]) + retention = response.parse() + assert_matches_type(RetentionGetResponse, retention, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.logs.control.retention.flag.with_streaming_response.get( + with client.logs.control.retention.with_streaming_response.get( "023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - flag = response.parse() - assert_matches_type(FlagGetResponse, flag, path=["response"]) + retention = response.parse() + assert_matches_type(RetentionGetResponse, retention, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.logs.control.retention.flag.with_raw_response.get( + client.logs.control.retention.with_raw_response.get( "", ) -class TestAsyncFlag: +class TestAsyncRetention: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: - flag = await async_client.logs.control.retention.flag.create( + retention = await async_client.logs.control.retention.create( "023e105f4ecef8ad9ca31a8372d0c353", flag=True, ) - assert_matches_type(FlagCreateResponse, flag, path=["response"]) + assert_matches_type(RetentionCreateResponse, retention, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.logs.control.retention.flag.with_raw_response.create( + response = await async_client.logs.control.retention.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", flag=True, ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - flag = await response.parse() - assert_matches_type(FlagCreateResponse, flag, path=["response"]) + retention = await response.parse() + assert_matches_type(RetentionCreateResponse, retention, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.logs.control.retention.flag.with_streaming_response.create( + async with async_client.logs.control.retention.with_streaming_response.create( "023e105f4ecef8ad9ca31a8372d0c353", flag=True, ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - flag = await response.parse() - assert_matches_type(FlagCreateResponse, flag, path=["response"]) + retention = await response.parse() + assert_matches_type(RetentionCreateResponse, retention, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.logs.control.retention.flag.with_raw_response.create( + await async_client.logs.control.retention.with_raw_response.create( "", flag=True, ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - flag = await async_client.logs.control.retention.flag.get( + retention = await async_client.logs.control.retention.get( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(FlagGetResponse, flag, path=["response"]) + assert_matches_type(RetentionGetResponse, retention, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.logs.control.retention.flag.with_raw_response.get( + response = await async_client.logs.control.retention.with_raw_response.get( "023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - flag = await response.parse() - assert_matches_type(FlagGetResponse, flag, path=["response"]) + retention = await response.parse() + assert_matches_type(RetentionGetResponse, retention, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.logs.control.retention.flag.with_streaming_response.get( + async with async_client.logs.control.retention.with_streaming_response.get( "023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - flag = await response.parse() - assert_matches_type(FlagGetResponse, flag, path=["response"]) + retention = await response.parse() + assert_matches_type(RetentionGetResponse, retention, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.logs.control.retention.flag.with_raw_response.get( + await async_client.logs.control.retention.with_raw_response.get( "", ) From a27a054a4648b0df48a8a629960eb0f7281bae88 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 03:41:57 +0000 Subject: [PATCH 168/532] feat(api): update via SDK Studio (#649) --- .stats.yml | 2 +- api.md | 12 + src/cloudflare/resources/r2/__init__.py | 14 ++ src/cloudflare/resources/r2/r2.py | 32 +++ .../resources/r2/temporary_credentials.py | 224 ++++++++++++++++++ src/cloudflare/types/r2/__init__.py | 2 + .../r2/temporary_credential_create_params.py | 33 +++ .../temporary_credential_create_response.py | 20 ++ .../r2/test_temporary_credentials.py | 156 ++++++++++++ 9 files changed, 494 insertions(+), 1 deletion(-) create mode 100644 src/cloudflare/resources/r2/temporary_credentials.py create mode 100644 src/cloudflare/types/r2/temporary_credential_create_params.py create mode 100644 src/cloudflare/types/r2/temporary_credential_create_response.py create mode 100644 tests/api_resources/r2/test_temporary_credentials.py diff --git a/.stats.yml b/.stats.yml index 10d76151103..5e1891fd453 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1296 +configured_endpoints: 1297 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaf3cf93b4b0566484405b918a65aeca6e5ad4cc194989298a633601684fa0c1.yml diff --git a/api.md b/api.md index 23160a4ff3f..405673a113d 100644 --- a/api.md +++ b/api.md @@ -4645,6 +4645,18 @@ Methods: - client.r2.sippy.delete(bucket_name, \*, account_id) -> SippyDeleteResponse - client.r2.sippy.get(bucket_name, \*, account_id) -> Sippy +## TemporaryCredentials + +Types: + +```python +from cloudflare.types.r2 import TemporaryCredential, TemporaryCredentialCreateResponse +``` + +Methods: + +- client.r2.temporary_credentials.create(\*, account_id, \*\*params) -> TemporaryCredentialCreateResponse + # WARPConnector Types: diff --git a/src/cloudflare/resources/r2/__init__.py b/src/cloudflare/resources/r2/__init__.py index 96e202b807b..be9a0113617 100644 --- a/src/cloudflare/resources/r2/__init__.py +++ b/src/cloudflare/resources/r2/__init__.py @@ -24,6 +24,14 @@ BucketsResourceWithStreamingResponse, AsyncBucketsResourceWithStreamingResponse, ) +from .temporary_credentials import ( + TemporaryCredentialsResource, + AsyncTemporaryCredentialsResource, + TemporaryCredentialsResourceWithRawResponse, + AsyncTemporaryCredentialsResourceWithRawResponse, + TemporaryCredentialsResourceWithStreamingResponse, + AsyncTemporaryCredentialsResourceWithStreamingResponse, +) __all__ = [ "BucketsResource", @@ -38,6 +46,12 @@ "AsyncSippyResourceWithRawResponse", "SippyResourceWithStreamingResponse", "AsyncSippyResourceWithStreamingResponse", + "TemporaryCredentialsResource", + "AsyncTemporaryCredentialsResource", + "TemporaryCredentialsResourceWithRawResponse", + "AsyncTemporaryCredentialsResourceWithRawResponse", + "TemporaryCredentialsResourceWithStreamingResponse", + "AsyncTemporaryCredentialsResourceWithStreamingResponse", "R2Resource", "AsyncR2Resource", "R2ResourceWithRawResponse", diff --git a/src/cloudflare/resources/r2/r2.py b/src/cloudflare/resources/r2/r2.py index 5bf7bfb501e..a9999cd369a 100644 --- a/src/cloudflare/resources/r2/r2.py +++ b/src/cloudflare/resources/r2/r2.py @@ -20,6 +20,14 @@ ) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource +from .temporary_credentials import ( + TemporaryCredentialsResource, + AsyncTemporaryCredentialsResource, + TemporaryCredentialsResourceWithRawResponse, + AsyncTemporaryCredentialsResourceWithRawResponse, + TemporaryCredentialsResourceWithStreamingResponse, + AsyncTemporaryCredentialsResourceWithStreamingResponse, +) __all__ = ["R2Resource", "AsyncR2Resource"] @@ -33,6 +41,10 @@ def buckets(self) -> BucketsResource: def sippy(self) -> SippyResource: return SippyResource(self._client) + @cached_property + def temporary_credentials(self) -> TemporaryCredentialsResource: + return TemporaryCredentialsResource(self._client) + @cached_property def with_raw_response(self) -> R2ResourceWithRawResponse: return R2ResourceWithRawResponse(self) @@ -51,6 +63,10 @@ def buckets(self) -> AsyncBucketsResource: def sippy(self) -> AsyncSippyResource: return AsyncSippyResource(self._client) + @cached_property + def temporary_credentials(self) -> AsyncTemporaryCredentialsResource: + return AsyncTemporaryCredentialsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncR2ResourceWithRawResponse: return AsyncR2ResourceWithRawResponse(self) @@ -72,6 +88,10 @@ def buckets(self) -> BucketsResourceWithRawResponse: def sippy(self) -> SippyResourceWithRawResponse: return SippyResourceWithRawResponse(self._r2.sippy) + @cached_property + def temporary_credentials(self) -> TemporaryCredentialsResourceWithRawResponse: + return TemporaryCredentialsResourceWithRawResponse(self._r2.temporary_credentials) + class AsyncR2ResourceWithRawResponse: def __init__(self, r2: AsyncR2Resource) -> None: @@ -85,6 +105,10 @@ def buckets(self) -> AsyncBucketsResourceWithRawResponse: def sippy(self) -> AsyncSippyResourceWithRawResponse: return AsyncSippyResourceWithRawResponse(self._r2.sippy) + @cached_property + def temporary_credentials(self) -> AsyncTemporaryCredentialsResourceWithRawResponse: + return AsyncTemporaryCredentialsResourceWithRawResponse(self._r2.temporary_credentials) + class R2ResourceWithStreamingResponse: def __init__(self, r2: R2Resource) -> None: @@ -98,6 +122,10 @@ def buckets(self) -> BucketsResourceWithStreamingResponse: def sippy(self) -> SippyResourceWithStreamingResponse: return SippyResourceWithStreamingResponse(self._r2.sippy) + @cached_property + def temporary_credentials(self) -> TemporaryCredentialsResourceWithStreamingResponse: + return TemporaryCredentialsResourceWithStreamingResponse(self._r2.temporary_credentials) + class AsyncR2ResourceWithStreamingResponse: def __init__(self, r2: AsyncR2Resource) -> None: @@ -110,3 +138,7 @@ def buckets(self) -> AsyncBucketsResourceWithStreamingResponse: @cached_property def sippy(self) -> AsyncSippyResourceWithStreamingResponse: return AsyncSippyResourceWithStreamingResponse(self._r2.sippy) + + @cached_property + def temporary_credentials(self) -> AsyncTemporaryCredentialsResourceWithStreamingResponse: + return AsyncTemporaryCredentialsResourceWithStreamingResponse(self._r2.temporary_credentials) diff --git a/src/cloudflare/resources/r2/temporary_credentials.py b/src/cloudflare/resources/r2/temporary_credentials.py new file mode 100644 index 00000000000..f621ecdab1a --- /dev/null +++ b/src/cloudflare/resources/r2/temporary_credentials.py @@ -0,0 +1,224 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, cast +from typing_extensions import Literal + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ...types.r2 import temporary_credential_create_params +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.r2.temporary_credential_create_response import TemporaryCredentialCreateResponse + +__all__ = ["TemporaryCredentialsResource", "AsyncTemporaryCredentialsResource"] + + +class TemporaryCredentialsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> TemporaryCredentialsResourceWithRawResponse: + return TemporaryCredentialsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TemporaryCredentialsResourceWithStreamingResponse: + return TemporaryCredentialsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + bucket: str, + parent_access_key_id: str, + permission: Literal["admin-read-write", "admin-read-only", "object-read-write", "object-read-only"], + ttl_seconds: float, + objects: List[str] | NotGiven = NOT_GIVEN, + prefixes: List[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, + ) -> TemporaryCredentialCreateResponse: + """ + Creates temporary access credentials on a bucket that can be optionally scoped + to prefixes or objects. + + Args: + account_id: Account ID + + bucket: Name of the GCS bucket + + parent_access_key_id: The parent access key id to use for signing + + permission: Permissions allowed on the credentials + + ttl_seconds: How long the credentials will live for in seconds + + objects: Optional object paths to scope the credentials to + + prefixes: Optional prefix paths to scope the credentials to + + 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}/r2/temp-access-credentials", + body=maybe_transform( + { + "bucket": bucket, + "parent_access_key_id": parent_access_key_id, + "permission": permission, + "ttl_seconds": ttl_seconds, + "objects": objects, + "prefixes": prefixes, + }, + temporary_credential_create_params.TemporaryCredentialCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TemporaryCredentialCreateResponse]._unwrapper, + ), + cast_to=cast(Type[TemporaryCredentialCreateResponse], ResultWrapper[TemporaryCredentialCreateResponse]), + ) + + +class AsyncTemporaryCredentialsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncTemporaryCredentialsResourceWithRawResponse: + return AsyncTemporaryCredentialsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTemporaryCredentialsResourceWithStreamingResponse: + return AsyncTemporaryCredentialsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + bucket: str, + parent_access_key_id: str, + permission: Literal["admin-read-write", "admin-read-only", "object-read-write", "object-read-only"], + ttl_seconds: float, + objects: List[str] | NotGiven = NOT_GIVEN, + prefixes: List[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, + ) -> TemporaryCredentialCreateResponse: + """ + Creates temporary access credentials on a bucket that can be optionally scoped + to prefixes or objects. + + Args: + account_id: Account ID + + bucket: Name of the GCS bucket + + parent_access_key_id: The parent access key id to use for signing + + permission: Permissions allowed on the credentials + + ttl_seconds: How long the credentials will live for in seconds + + objects: Optional object paths to scope the credentials to + + prefixes: Optional prefix paths to scope the credentials to + + 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}/r2/temp-access-credentials", + body=await async_maybe_transform( + { + "bucket": bucket, + "parent_access_key_id": parent_access_key_id, + "permission": permission, + "ttl_seconds": ttl_seconds, + "objects": objects, + "prefixes": prefixes, + }, + temporary_credential_create_params.TemporaryCredentialCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TemporaryCredentialCreateResponse]._unwrapper, + ), + cast_to=cast(Type[TemporaryCredentialCreateResponse], ResultWrapper[TemporaryCredentialCreateResponse]), + ) + + +class TemporaryCredentialsResourceWithRawResponse: + def __init__(self, temporary_credentials: TemporaryCredentialsResource) -> None: + self._temporary_credentials = temporary_credentials + + self.create = to_raw_response_wrapper( + temporary_credentials.create, + ) + + +class AsyncTemporaryCredentialsResourceWithRawResponse: + def __init__(self, temporary_credentials: AsyncTemporaryCredentialsResource) -> None: + self._temporary_credentials = temporary_credentials + + self.create = async_to_raw_response_wrapper( + temporary_credentials.create, + ) + + +class TemporaryCredentialsResourceWithStreamingResponse: + def __init__(self, temporary_credentials: TemporaryCredentialsResource) -> None: + self._temporary_credentials = temporary_credentials + + self.create = to_streamed_response_wrapper( + temporary_credentials.create, + ) + + +class AsyncTemporaryCredentialsResourceWithStreamingResponse: + def __init__(self, temporary_credentials: AsyncTemporaryCredentialsResource) -> None: + self._temporary_credentials = temporary_credentials + + self.create = async_to_streamed_response_wrapper( + temporary_credentials.create, + ) diff --git a/src/cloudflare/types/r2/__init__.py b/src/cloudflare/types/r2/__init__.py index 9227a53be92..a4a10ec7a7c 100644 --- a/src/cloudflare/types/r2/__init__.py +++ b/src/cloudflare/types/r2/__init__.py @@ -9,3 +9,5 @@ from .sippy_update_params import SippyUpdateParams as SippyUpdateParams from .bucket_create_params import BucketCreateParams as BucketCreateParams from .sippy_delete_response import SippyDeleteResponse as SippyDeleteResponse +from .temporary_credential_create_params import TemporaryCredentialCreateParams as TemporaryCredentialCreateParams +from .temporary_credential_create_response import TemporaryCredentialCreateResponse as TemporaryCredentialCreateResponse diff --git a/src/cloudflare/types/r2/temporary_credential_create_params.py b/src/cloudflare/types/r2/temporary_credential_create_params.py new file mode 100644 index 00000000000..c79dcc8e5f6 --- /dev/null +++ b/src/cloudflare/types/r2/temporary_credential_create_params.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["TemporaryCredentialCreateParams"] + + +class TemporaryCredentialCreateParams(TypedDict, total=False): + account_id: Required[str] + """Account ID""" + + bucket: Required[str] + """Name of the GCS bucket""" + + parent_access_key_id: Required[Annotated[str, PropertyInfo(alias="parentAccessKeyId")]] + """The parent access key id to use for signing""" + + permission: Required[Literal["admin-read-write", "admin-read-only", "object-read-write", "object-read-only"]] + """Permissions allowed on the credentials""" + + ttl_seconds: Required[Annotated[float, PropertyInfo(alias="ttlSeconds")]] + """How long the credentials will live for in seconds""" + + objects: List[str] + """Optional object paths to scope the credentials to""" + + prefixes: List[str] + """Optional prefix paths to scope the credentials to""" diff --git a/src/cloudflare/types/r2/temporary_credential_create_response.py b/src/cloudflare/types/r2/temporary_credential_create_response.py new file mode 100644 index 00000000000..3a1838f74fc --- /dev/null +++ b/src/cloudflare/types/r2/temporary_credential_create_response.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["TemporaryCredentialCreateResponse"] + + +class TemporaryCredentialCreateResponse(BaseModel): + access_key_id: Optional[str] = FieldInfo(alias="accessKeyId", default=None) + """ID for new access key""" + + secret_access_key: Optional[str] = FieldInfo(alias="secretAccessKey", default=None) + """Secret access key""" + + session_token: Optional[str] = FieldInfo(alias="sessionToken", default=None) + """Security token""" diff --git a/tests/api_resources/r2/test_temporary_credentials.py b/tests/api_resources/r2/test_temporary_credentials.py new file mode 100644 index 00000000000..3bdf9c876b1 --- /dev/null +++ b/tests/api_resources/r2/test_temporary_credentials.py @@ -0,0 +1,156 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.r2 import TemporaryCredentialCreateResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestTemporaryCredentials: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + temporary_credential = client.r2.temporary_credentials.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + ) + assert_matches_type(TemporaryCredentialCreateResponse, temporary_credential, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + temporary_credential = client.r2.temporary_credentials.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + objects=["example-object"], + prefixes=["example-prefix/"], + ) + assert_matches_type(TemporaryCredentialCreateResponse, temporary_credential, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.r2.temporary_credentials.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + temporary_credential = response.parse() + assert_matches_type(TemporaryCredentialCreateResponse, temporary_credential, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.r2.temporary_credentials.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + temporary_credential = response.parse() + assert_matches_type(TemporaryCredentialCreateResponse, temporary_credential, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.r2.temporary_credentials.with_raw_response.create( + account_id="", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + ) + + +class TestAsyncTemporaryCredentials: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + temporary_credential = await async_client.r2.temporary_credentials.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + ) + assert_matches_type(TemporaryCredentialCreateResponse, temporary_credential, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + temporary_credential = await async_client.r2.temporary_credentials.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + objects=["example-object"], + prefixes=["example-prefix/"], + ) + assert_matches_type(TemporaryCredentialCreateResponse, temporary_credential, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.r2.temporary_credentials.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + temporary_credential = await response.parse() + assert_matches_type(TemporaryCredentialCreateResponse, temporary_credential, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.r2.temporary_credentials.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + temporary_credential = await response.parse() + assert_matches_type(TemporaryCredentialCreateResponse, temporary_credential, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.r2.temporary_credentials.with_raw_response.create( + account_id="", + bucket="example-bucket", + parent_access_key_id="example-access-key-id", + permission="object-read-write", + ttl_seconds=3600, + ) From 554952b2141d0c9541cccf9ee6ea5d3269fef1a8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 04:16:47 +0000 Subject: [PATCH 169/532] feat(api): update via SDK Studio (#650) --- src/cloudflare/resources/filters.py | 151 +++++-- tests/api_resources/test_filters.py | 586 +++++++++++++++------------- 2 files changed, 432 insertions(+), 305 deletions(-) diff --git a/src/cloudflare/resources/filters.py b/src/cloudflare/resources/filters.py index 6e9f3b01354..551ef84541b 100644 --- a/src/cloudflare/resources/filters.py +++ b/src/cloudflare/resources/filters.py @@ -2,6 +2,7 @@ from __future__ import annotations +import typing_extensions from typing import Type, Optional, cast import httpx @@ -41,6 +42,9 @@ def with_raw_response(self) -> FiltersResourceWithRawResponse: def with_streaming_response(self) -> FiltersResourceWithStreamingResponse: return FiltersResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def create( self, zone_identifier: str, @@ -82,6 +86,9 @@ def create( cast_to=cast(Type[Optional[FilterCreateResponse]], ResultWrapper[FilterCreateResponse]), ) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def update( self, id: str, @@ -128,6 +135,9 @@ def update( cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), ) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def list( self, zone_identifier: str, @@ -202,6 +212,9 @@ def list( model=FirewallFilter, ) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def delete( self, id: str, @@ -246,6 +259,9 @@ def delete( cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), ) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def get( self, id: str, @@ -300,6 +316,9 @@ def with_raw_response(self) -> AsyncFiltersResourceWithRawResponse: def with_streaming_response(self) -> AsyncFiltersResourceWithStreamingResponse: return AsyncFiltersResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def create( self, zone_identifier: str, @@ -341,6 +360,9 @@ async def create( cast_to=cast(Type[Optional[FilterCreateResponse]], ResultWrapper[FilterCreateResponse]), ) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def update( self, id: str, @@ -387,6 +409,9 @@ async def update( cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), ) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def list( self, zone_identifier: str, @@ -461,6 +486,9 @@ def list( model=FirewallFilter, ) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def delete( self, id: str, @@ -505,6 +533,9 @@ async def delete( cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), ) + @typing_extensions.deprecated( + "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def get( self, id: str, @@ -554,20 +585,30 @@ class FiltersResourceWithRawResponse: def __init__(self, filters: FiltersResource) -> None: self._filters = filters - self.create = to_raw_response_wrapper( - filters.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + filters.create # pyright: ignore[reportDeprecated], + ) ) - self.update = to_raw_response_wrapper( - filters.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + filters.update # pyright: ignore[reportDeprecated], + ) ) - self.list = to_raw_response_wrapper( - filters.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + filters.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_raw_response_wrapper( - filters.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + filters.delete # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - filters.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + filters.get # pyright: ignore[reportDeprecated], + ) ) @@ -575,20 +616,30 @@ class AsyncFiltersResourceWithRawResponse: def __init__(self, filters: AsyncFiltersResource) -> None: self._filters = filters - self.create = async_to_raw_response_wrapper( - filters.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + filters.create # pyright: ignore[reportDeprecated], + ) ) - self.update = async_to_raw_response_wrapper( - filters.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + filters.update # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_raw_response_wrapper( - filters.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + filters.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_raw_response_wrapper( - filters.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + filters.delete # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - filters.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + filters.get # pyright: ignore[reportDeprecated], + ) ) @@ -596,20 +647,30 @@ class FiltersResourceWithStreamingResponse: def __init__(self, filters: FiltersResource) -> None: self._filters = filters - self.create = to_streamed_response_wrapper( - filters.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + filters.create # pyright: ignore[reportDeprecated], + ) ) - self.update = to_streamed_response_wrapper( - filters.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + filters.update # pyright: ignore[reportDeprecated], + ) ) - self.list = to_streamed_response_wrapper( - filters.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + filters.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_streamed_response_wrapper( - filters.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + filters.delete # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - filters.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + filters.get # pyright: ignore[reportDeprecated], + ) ) @@ -617,18 +678,28 @@ class AsyncFiltersResourceWithStreamingResponse: def __init__(self, filters: AsyncFiltersResource) -> None: self._filters = filters - self.create = async_to_streamed_response_wrapper( - filters.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + filters.create # pyright: ignore[reportDeprecated], + ) ) - self.update = async_to_streamed_response_wrapper( - filters.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + filters.update # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_streamed_response_wrapper( - filters.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + filters.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_streamed_response_wrapper( - filters.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + filters.delete # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_streamed_response_wrapper( - filters.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + filters.get # pyright: ignore[reportDeprecated], + ) ) diff --git a/tests/api_resources/test_filters.py b/tests/api_resources/test_filters.py index e840ceb5eaa..58215dc774b 100644 --- a/tests/api_resources/test_filters.py +++ b/tests/api_resources/test_filters.py @@ -15,6 +15,8 @@ FilterCreateResponse, ) +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -24,19 +26,22 @@ class TestFilters: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_create(self, client: Cloudflare) -> None: - filter = client.filters.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + filter = client.filters.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.filters.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = client.filters.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -46,45 +51,50 @@ def test_raw_response_create(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.filters.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.filters.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) + filter = response.parse() + assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.filters.with_raw_response.create( - "", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.filters.with_raw_response.create( + "", + body={}, + ) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_update(self, client: Cloudflare) -> None: - filter = client.filters.update( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + filter = client.filters.update( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(FirewallFilter, filter, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.filters.with_raw_response.update( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = client.filters.with_raw_response.update( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -94,62 +104,69 @@ def test_raw_response_update(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.filters.with_streaming_response.update( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.filters.with_streaming_response.update( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) + filter = response.parse() + assert_matches_type(FirewallFilter, filter, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.filters.with_raw_response.update( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.filters.with_raw_response.update( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.filters.with_raw_response.update( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.filters.with_raw_response.update( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) @parametrize def test_method_list(self, client: Cloudflare) -> None: - filter = client.filters.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + filter = client.filters.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: - filter = client.filters.list( - "023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b61", - description="browsers", - expression="php", - page=1, - paused=False, - per_page=5, - ref="FIL-100", - ) + with pytest.warns(DeprecationWarning): + filter = client.filters.list( + "023e105f4ecef8ad9ca31a8372d0c353", + id="372e67954025e0ba6aaa6d586b9e0b61", + description="browsers", + expression="php", + page=1, + paused=False, + per_page=5, + ref="FIL-100", + ) + assert_matches_type(SyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.filters.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.filters.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -158,38 +175,43 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.filters.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.filters.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(SyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) + filter = response.parse() + assert_matches_type(SyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.filters.with_raw_response.list( - "", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.filters.with_raw_response.list( + "", + ) @parametrize def test_method_delete(self, client: Cloudflare) -> None: - filter = client.filters.delete( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + filter = client.filters.delete( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(FirewallFilter, filter, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.filters.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.filters.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -198,46 +220,51 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.filters.with_streaming_response.delete( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.filters.with_streaming_response.delete( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) + filter = response.parse() + assert_matches_type(FirewallFilter, filter, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.filters.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.filters.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.filters.with_raw_response.delete( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.filters.with_raw_response.delete( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) @parametrize def test_method_get(self, client: Cloudflare) -> None: - filter = client.filters.get( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + filter = client.filters.get( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(FirewallFilter, filter, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.filters.with_raw_response.get( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.filters.with_raw_response.get( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -246,31 +273,33 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.filters.with_streaming_response.get( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.filters.with_streaming_response.get( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) + filter = response.parse() + assert_matches_type(FirewallFilter, filter, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.filters.with_raw_response.get( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.filters.with_raw_response.get( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.filters.with_raw_response.get( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.filters.with_raw_response.get( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) class TestAsyncFilters: @@ -279,19 +308,22 @@ class TestAsyncFilters: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: - filter = await async_client.filters.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + filter = await async_client.filters.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.filters.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.filters.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -301,45 +333,50 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.filters.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.filters.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) + filter = await response.parse() + assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.filters.with_raw_response.create( - "", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.filters.with_raw_response.create( + "", + body={}, + ) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: - filter = await async_client.filters.update( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + filter = await async_client.filters.update( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(FirewallFilter, filter, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.filters.with_raw_response.update( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.filters.with_raw_response.update( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -349,62 +386,69 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.filters.with_streaming_response.update( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.filters.with_streaming_response.update( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) + filter = await response.parse() + assert_matches_type(FirewallFilter, filter, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.filters.with_raw_response.update( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.filters.with_raw_response.update( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.filters.with_raw_response.update( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.filters.with_raw_response.update( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: - filter = await async_client.filters.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + filter = await async_client.filters.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - filter = await async_client.filters.list( - "023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b61", - description="browsers", - expression="php", - page=1, - paused=False, - per_page=5, - ref="FIL-100", - ) + with pytest.warns(DeprecationWarning): + filter = await async_client.filters.list( + "023e105f4ecef8ad9ca31a8372d0c353", + id="372e67954025e0ba6aaa6d586b9e0b61", + description="browsers", + expression="php", + page=1, + paused=False, + per_page=5, + ref="FIL-100", + ) + assert_matches_type(AsyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.filters.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.filters.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -413,38 +457,43 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.filters.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.filters.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) + filter = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.filters.with_raw_response.list( - "", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.filters.with_raw_response.list( + "", + ) @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - filter = await async_client.filters.delete( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + filter = await async_client.filters.delete( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(FirewallFilter, filter, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.filters.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.filters.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -453,46 +502,51 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.filters.with_streaming_response.delete( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.filters.with_streaming_response.delete( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) + filter = await response.parse() + assert_matches_type(FirewallFilter, filter, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.filters.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.filters.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.filters.with_raw_response.delete( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.filters.with_raw_response.delete( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - filter = await async_client.filters.get( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + filter = await async_client.filters.get( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(FirewallFilter, filter, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.filters.with_raw_response.get( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.filters.with_raw_response.get( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -501,28 +555,30 @@ 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.filters.with_streaming_response.get( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.filters.with_streaming_response.get( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) + filter = await response.parse() + assert_matches_type(FirewallFilter, filter, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.filters.with_raw_response.get( - "372e67954025e0ba6aaa6d586b9e0b61", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.filters.with_raw_response.get( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.filters.with_raw_response.get( + "372e67954025e0ba6aaa6d586b9e0b61", + zone_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.filters.with_raw_response.get( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) From 9b140f9c74193dfe6a56609f52f19b85307795e8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 04:31:32 +0000 Subject: [PATCH 170/532] feat(api): update via SDK Studio (#651) --- src/cloudflare/resources/filters.py | 20 +- src/cloudflare/resources/firewall/rules.py | 191 ++- .../resources/pagerules/pagerules.py | 181 ++- src/cloudflare/resources/rate_limits.py | 151 +- tests/api_resources/firewall/test_rules.py | 752 ++++----- tests/api_resources/test_pagerules.py | 1364 +++++++++-------- tests/api_resources/test_rate_limits.py | 566 ++++--- 7 files changed, 1835 insertions(+), 1390 deletions(-) diff --git a/src/cloudflare/resources/filters.py b/src/cloudflare/resources/filters.py index 551ef84541b..7c71132b273 100644 --- a/src/cloudflare/resources/filters.py +++ b/src/cloudflare/resources/filters.py @@ -43,7 +43,7 @@ def with_streaming_response(self) -> FiltersResourceWithStreamingResponse: return FiltersResourceWithStreamingResponse(self) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) def create( self, @@ -87,7 +87,7 @@ def create( ) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) def update( self, @@ -136,7 +136,7 @@ def update( ) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) def list( self, @@ -213,7 +213,7 @@ def list( ) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) def delete( self, @@ -260,7 +260,7 @@ def delete( ) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) def get( self, @@ -317,7 +317,7 @@ def with_streaming_response(self) -> AsyncFiltersResourceWithStreamingResponse: return AsyncFiltersResourceWithStreamingResponse(self) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) async def create( self, @@ -361,7 +361,7 @@ async def create( ) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) async def update( self, @@ -410,7 +410,7 @@ async def update( ) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) def list( self, @@ -487,7 +487,7 @@ def list( ) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) async def delete( self, @@ -534,7 +534,7 @@ async def delete( ) @typing_extensions.deprecated( - "Filters are being deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." ) async def get( self, diff --git a/src/cloudflare/resources/firewall/rules.py b/src/cloudflare/resources/firewall/rules.py index 9a3a377e651..8e58114ac84 100644 --- a/src/cloudflare/resources/firewall/rules.py +++ b/src/cloudflare/resources/firewall/rules.py @@ -2,6 +2,7 @@ from __future__ import annotations +import typing_extensions from typing import Type, Optional, cast import httpx @@ -48,6 +49,9 @@ def with_raw_response(self) -> RulesResourceWithRawResponse: def with_streaming_response(self) -> RulesResourceWithStreamingResponse: return RulesResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def create( self, zone_identifier: str, @@ -89,6 +93,9 @@ def create( cast_to=cast(Type[Optional[RuleCreateResponse]], ResultWrapper[RuleCreateResponse]), ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def update( self, id: str, @@ -135,6 +142,9 @@ def update( cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def list( self, zone_identifier: str, @@ -205,6 +215,9 @@ def list( model=FirewallRule, ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def delete( self, id: str, @@ -249,6 +262,9 @@ def delete( cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def edit( self, id: str, @@ -295,6 +311,9 @@ def edit( cast_to=cast(Type[Optional[RuleEditResponse]], ResultWrapper[RuleEditResponse]), ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def get( self, zone_identifier: str, @@ -353,6 +372,9 @@ def with_raw_response(self) -> AsyncRulesResourceWithRawResponse: def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: return AsyncRulesResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def create( self, zone_identifier: str, @@ -394,6 +416,9 @@ async def create( cast_to=cast(Type[Optional[RuleCreateResponse]], ResultWrapper[RuleCreateResponse]), ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def update( self, id: str, @@ -440,6 +465,9 @@ async def update( cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) def list( self, zone_identifier: str, @@ -510,6 +538,9 @@ def list( model=FirewallRule, ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def delete( self, id: str, @@ -554,6 +585,9 @@ async def delete( cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def edit( self, id: str, @@ -600,6 +634,9 @@ async def edit( cast_to=cast(Type[Optional[RuleEditResponse]], ResultWrapper[RuleEditResponse]), ) + @typing_extensions.deprecated( + "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." + ) async def get( self, zone_identifier: str, @@ -653,23 +690,35 @@ class RulesResourceWithRawResponse: def __init__(self, rules: RulesResource) -> None: self._rules = rules - self.create = to_raw_response_wrapper( - rules.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rules.create # pyright: ignore[reportDeprecated], + ) ) - self.update = to_raw_response_wrapper( - rules.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rules.update # pyright: ignore[reportDeprecated], + ) ) - self.list = to_raw_response_wrapper( - rules.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rules.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_raw_response_wrapper( - rules.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rules.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_raw_response_wrapper( - rules.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rules.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - rules.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rules.get # pyright: ignore[reportDeprecated], + ) ) @@ -677,23 +726,35 @@ class AsyncRulesResourceWithRawResponse: def __init__(self, rules: AsyncRulesResource) -> None: self._rules = rules - self.create = async_to_raw_response_wrapper( - rules.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rules.create # pyright: ignore[reportDeprecated], + ) ) - self.update = async_to_raw_response_wrapper( - rules.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rules.update # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_raw_response_wrapper( - rules.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rules.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_raw_response_wrapper( - rules.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rules.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_raw_response_wrapper( - rules.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rules.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - rules.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rules.get # pyright: ignore[reportDeprecated], + ) ) @@ -701,23 +762,35 @@ class RulesResourceWithStreamingResponse: def __init__(self, rules: RulesResource) -> None: self._rules = rules - self.create = to_streamed_response_wrapper( - rules.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rules.create # pyright: ignore[reportDeprecated], + ) ) - self.update = to_streamed_response_wrapper( - rules.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rules.update # pyright: ignore[reportDeprecated], + ) ) - self.list = to_streamed_response_wrapper( - rules.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rules.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_streamed_response_wrapper( - rules.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rules.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_streamed_response_wrapper( - rules.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rules.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - rules.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rules.get # pyright: ignore[reportDeprecated], + ) ) @@ -725,21 +798,33 @@ class AsyncRulesResourceWithStreamingResponse: def __init__(self, rules: AsyncRulesResource) -> None: self._rules = rules - self.create = async_to_streamed_response_wrapper( - rules.create, - ) - self.update = async_to_streamed_response_wrapper( - rules.update, - ) - self.list = async_to_streamed_response_wrapper( - rules.list, - ) - self.delete = async_to_streamed_response_wrapper( - rules.delete, - ) - self.edit = async_to_streamed_response_wrapper( - rules.edit, - ) - self.get = async_to_streamed_response_wrapper( - rules.get, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rules.create # pyright: ignore[reportDeprecated], + ) + ) + self.update = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rules.update # pyright: ignore[reportDeprecated], + ) + ) + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rules.list # pyright: ignore[reportDeprecated], + ) + ) + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rules.delete # pyright: ignore[reportDeprecated], + ) + ) + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rules.edit # pyright: ignore[reportDeprecated], + ) + ) + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rules.get # pyright: ignore[reportDeprecated], + ) ) diff --git a/src/cloudflare/resources/pagerules/pagerules.py b/src/cloudflare/resources/pagerules/pagerules.py index e27797213d8..440b172abde 100644 --- a/src/cloudflare/resources/pagerules/pagerules.py +++ b/src/cloudflare/resources/pagerules/pagerules.py @@ -2,6 +2,7 @@ from __future__ import annotations +import typing_extensions from typing import Any, Type, Iterable, Optional, cast from typing_extensions import Literal @@ -63,6 +64,9 @@ def with_raw_response(self) -> PagerulesResourceWithRawResponse: def with_streaming_response(self) -> PagerulesResourceWithStreamingResponse: return PagerulesResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) def create( self, *, @@ -133,6 +137,9 @@ def create( ), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) def update( self, pagerule_id: str, @@ -210,6 +217,9 @@ def update( ), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) def list( self, *, @@ -271,6 +281,9 @@ def list( cast_to=cast(Type[PageruleListResponse], ResultWrapper[PageruleListResponse]), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) def delete( self, pagerule_id: str, @@ -315,6 +328,9 @@ def delete( cast_to=cast(Type[Optional[PageruleDeleteResponse]], ResultWrapper[PageruleDeleteResponse]), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) def edit( self, pagerule_id: str, @@ -390,6 +406,9 @@ def edit( ), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) def get( self, pagerule_id: str, @@ -453,6 +472,9 @@ def with_raw_response(self) -> AsyncPagerulesResourceWithRawResponse: def with_streaming_response(self) -> AsyncPagerulesResourceWithStreamingResponse: return AsyncPagerulesResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) async def create( self, *, @@ -523,6 +545,9 @@ async def create( ), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) async def update( self, pagerule_id: str, @@ -600,6 +625,9 @@ async def update( ), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) async def list( self, *, @@ -661,6 +689,9 @@ async def list( cast_to=cast(Type[PageruleListResponse], ResultWrapper[PageruleListResponse]), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) async def delete( self, pagerule_id: str, @@ -705,6 +736,9 @@ async def delete( cast_to=cast(Type[Optional[PageruleDeleteResponse]], ResultWrapper[PageruleDeleteResponse]), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) async def edit( self, pagerule_id: str, @@ -780,6 +814,9 @@ async def edit( ), ) + @typing_extensions.deprecated( + "The Page Rules API is deprecated in favour of the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#page-rules for full details." + ) async def get( self, pagerule_id: str, @@ -834,23 +871,35 @@ class PagerulesResourceWithRawResponse: def __init__(self, pagerules: PagerulesResource) -> None: self._pagerules = pagerules - self.create = to_raw_response_wrapper( - pagerules.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + pagerules.create # pyright: ignore[reportDeprecated], + ) ) - self.update = to_raw_response_wrapper( - pagerules.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + pagerules.update # pyright: ignore[reportDeprecated], + ) ) - self.list = to_raw_response_wrapper( - pagerules.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + pagerules.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_raw_response_wrapper( - pagerules.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + pagerules.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_raw_response_wrapper( - pagerules.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + pagerules.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - pagerules.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + pagerules.get # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -862,23 +911,35 @@ class AsyncPagerulesResourceWithRawResponse: def __init__(self, pagerules: AsyncPagerulesResource) -> None: self._pagerules = pagerules - self.create = async_to_raw_response_wrapper( - pagerules.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + pagerules.create # pyright: ignore[reportDeprecated], + ) ) - self.update = async_to_raw_response_wrapper( - pagerules.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + pagerules.update # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_raw_response_wrapper( - pagerules.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + pagerules.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_raw_response_wrapper( - pagerules.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + pagerules.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_raw_response_wrapper( - pagerules.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + pagerules.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - pagerules.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + pagerules.get # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -890,23 +951,35 @@ class PagerulesResourceWithStreamingResponse: def __init__(self, pagerules: PagerulesResource) -> None: self._pagerules = pagerules - self.create = to_streamed_response_wrapper( - pagerules.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + pagerules.create # pyright: ignore[reportDeprecated], + ) ) - self.update = to_streamed_response_wrapper( - pagerules.update, + self.update = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + pagerules.update # pyright: ignore[reportDeprecated], + ) ) - self.list = to_streamed_response_wrapper( - pagerules.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + pagerules.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_streamed_response_wrapper( - pagerules.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + pagerules.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_streamed_response_wrapper( - pagerules.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + pagerules.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - pagerules.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + pagerules.get # pyright: ignore[reportDeprecated], + ) ) @cached_property @@ -918,23 +991,35 @@ class AsyncPagerulesResourceWithStreamingResponse: def __init__(self, pagerules: AsyncPagerulesResource) -> None: self._pagerules = pagerules - self.create = async_to_streamed_response_wrapper( - pagerules.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + pagerules.create # pyright: ignore[reportDeprecated], + ) ) - self.update = async_to_streamed_response_wrapper( - pagerules.update, + self.update = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + pagerules.update # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_streamed_response_wrapper( - pagerules.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + pagerules.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_streamed_response_wrapper( - pagerules.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + pagerules.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_streamed_response_wrapper( - pagerules.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + pagerules.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_streamed_response_wrapper( - pagerules.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + pagerules.get # pyright: ignore[reportDeprecated], + ) ) @cached_property diff --git a/src/cloudflare/resources/rate_limits.py b/src/cloudflare/resources/rate_limits.py index caae09d9f21..37c05e4d0ac 100644 --- a/src/cloudflare/resources/rate_limits.py +++ b/src/cloudflare/resources/rate_limits.py @@ -2,6 +2,7 @@ from __future__ import annotations +import typing_extensions from typing import Any, Type, cast import httpx @@ -44,6 +45,9 @@ def with_raw_response(self) -> RateLimitsResourceWithRawResponse: def with_streaming_response(self) -> RateLimitsResourceWithStreamingResponse: return RateLimitsResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) def create( self, zone_identifier: str, @@ -92,6 +96,9 @@ def create( ), ) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) def list( self, zone_identifier: str, @@ -145,6 +152,9 @@ def list( model=RateLimit, ) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) def delete( self, id: str, @@ -189,6 +199,9 @@ def delete( cast_to=cast(Type[RateLimitDeleteResponse], ResultWrapper[RateLimitDeleteResponse]), ) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) def edit( self, id: str, @@ -240,6 +253,9 @@ def edit( ), ) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) def get( self, id: str, @@ -299,6 +315,9 @@ def with_raw_response(self) -> AsyncRateLimitsResourceWithRawResponse: def with_streaming_response(self) -> AsyncRateLimitsResourceWithStreamingResponse: return AsyncRateLimitsResourceWithStreamingResponse(self) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) async def create( self, zone_identifier: str, @@ -347,6 +366,9 @@ async def create( ), ) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) def list( self, zone_identifier: str, @@ -400,6 +422,9 @@ def list( model=RateLimit, ) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) async def delete( self, id: str, @@ -444,6 +469,9 @@ async def delete( cast_to=cast(Type[RateLimitDeleteResponse], ResultWrapper[RateLimitDeleteResponse]), ) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) async def edit( self, id: str, @@ -495,6 +523,9 @@ async def edit( ), ) + @typing_extensions.deprecated( + "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." + ) async def get( self, id: str, @@ -549,20 +580,30 @@ class RateLimitsResourceWithRawResponse: def __init__(self, rate_limits: RateLimitsResource) -> None: self._rate_limits = rate_limits - self.create = to_raw_response_wrapper( - rate_limits.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rate_limits.create # pyright: ignore[reportDeprecated], + ) ) - self.list = to_raw_response_wrapper( - rate_limits.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rate_limits.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_raw_response_wrapper( - rate_limits.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rate_limits.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_raw_response_wrapper( - rate_limits.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rate_limits.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = to_raw_response_wrapper( - rate_limits.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_raw_response_wrapper( + rate_limits.get # pyright: ignore[reportDeprecated], + ) ) @@ -570,20 +611,30 @@ class AsyncRateLimitsResourceWithRawResponse: def __init__(self, rate_limits: AsyncRateLimitsResource) -> None: self._rate_limits = rate_limits - self.create = async_to_raw_response_wrapper( - rate_limits.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rate_limits.create # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_raw_response_wrapper( - rate_limits.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rate_limits.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_raw_response_wrapper( - rate_limits.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rate_limits.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_raw_response_wrapper( - rate_limits.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rate_limits.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_raw_response_wrapper( - rate_limits.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_raw_response_wrapper( + rate_limits.get # pyright: ignore[reportDeprecated], + ) ) @@ -591,20 +642,30 @@ class RateLimitsResourceWithStreamingResponse: def __init__(self, rate_limits: RateLimitsResource) -> None: self._rate_limits = rate_limits - self.create = to_streamed_response_wrapper( - rate_limits.create, + self.create = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rate_limits.create # pyright: ignore[reportDeprecated], + ) ) - self.list = to_streamed_response_wrapper( - rate_limits.list, + self.list = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rate_limits.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = to_streamed_response_wrapper( - rate_limits.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rate_limits.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = to_streamed_response_wrapper( - rate_limits.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rate_limits.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = to_streamed_response_wrapper( - rate_limits.get, + self.get = ( # pyright: ignore[reportDeprecated] + to_streamed_response_wrapper( + rate_limits.get # pyright: ignore[reportDeprecated], + ) ) @@ -612,18 +673,28 @@ class AsyncRateLimitsResourceWithStreamingResponse: def __init__(self, rate_limits: AsyncRateLimitsResource) -> None: self._rate_limits = rate_limits - self.create = async_to_streamed_response_wrapper( - rate_limits.create, + self.create = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rate_limits.create # pyright: ignore[reportDeprecated], + ) ) - self.list = async_to_streamed_response_wrapper( - rate_limits.list, + self.list = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rate_limits.list # pyright: ignore[reportDeprecated], + ) ) - self.delete = async_to_streamed_response_wrapper( - rate_limits.delete, + self.delete = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rate_limits.delete # pyright: ignore[reportDeprecated], + ) ) - self.edit = async_to_streamed_response_wrapper( - rate_limits.edit, + self.edit = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rate_limits.edit # pyright: ignore[reportDeprecated], + ) ) - self.get = async_to_streamed_response_wrapper( - rate_limits.get, + self.get = ( # pyright: ignore[reportDeprecated] + async_to_streamed_response_wrapper( + rate_limits.get # pyright: ignore[reportDeprecated], + ) ) diff --git a/tests/api_resources/firewall/test_rules.py b/tests/api_resources/firewall/test_rules.py index 7ae57fa47e3..4864bb5a5fa 100644 --- a/tests/api_resources/firewall/test_rules.py +++ b/tests/api_resources/firewall/test_rules.py @@ -16,6 +16,8 @@ RuleCreateResponse, ) +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -25,19 +27,22 @@ class TestRules: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_create(self, client: Cloudflare) -> None: - rule = client.firewall.rules.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rule = client.firewall.rules.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.firewall.rules.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = client.firewall.rules.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -47,45 +52,50 @@ def test_raw_response_create(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.firewall.rules.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.firewall.rules.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) + rule = response.parse() + assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.firewall.rules.with_raw_response.create( - "", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.firewall.rules.with_raw_response.create( + "", + body={}, + ) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_update(self, client: Cloudflare) -> None: - rule = client.firewall.rules.update( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rule = client.firewall.rules.update( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(FirewallRule, rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.firewall.rules.with_raw_response.update( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = client.firewall.rules.with_raw_response.update( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -95,61 +105,68 @@ def test_raw_response_update(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.firewall.rules.with_streaming_response.update( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.firewall.rules.with_streaming_response.update( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) + rule = response.parse() + assert_matches_type(FirewallRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.firewall.rules.with_raw_response.update( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.firewall.rules.with_raw_response.update( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.firewall.rules.with_raw_response.update( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.firewall.rules.with_raw_response.update( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) @parametrize def test_method_list(self, client: Cloudflare) -> None: - rule = client.firewall.rules.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + rule = client.firewall.rules.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: - rule = client.firewall.rules.list( - "023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b60", - action="block", - description="mir", - page=1, - paused=False, - per_page=5, - ) + with pytest.warns(DeprecationWarning): + rule = client.firewall.rules.list( + "023e105f4ecef8ad9ca31a8372d0c353", + id="372e67954025e0ba6aaa6d586b9e0b60", + action="block", + description="mir", + page=1, + paused=False, + per_page=5, + ) + assert_matches_type(SyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.firewall.rules.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.firewall.rules.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -158,38 +175,43 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.firewall.rules.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.firewall.rules.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(SyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) + rule = response.parse() + assert_matches_type(SyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.firewall.rules.with_raw_response.list( - "", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.firewall.rules.with_raw_response.list( + "", + ) @parametrize def test_method_delete(self, client: Cloudflare) -> None: - rule = client.firewall.rules.delete( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + rule = client.firewall.rules.delete( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(FirewallRule, rule, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.firewall.rules.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.firewall.rules.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -198,50 +220,55 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.firewall.rules.with_streaming_response.delete( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.firewall.rules.with_streaming_response.delete( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) + rule = response.parse() + assert_matches_type(FirewallRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.firewall.rules.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.firewall.rules.with_raw_response.delete( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.firewall.rules.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.firewall.rules.with_raw_response.delete( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_edit(self, client: Cloudflare) -> None: - rule = client.firewall.rules.edit( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rule = client.firewall.rules.edit( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.firewall.rules.with_raw_response.edit( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = client.firewall.rules.with_raw_response.edit( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -251,59 +278,66 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.firewall.rules.with_streaming_response.edit( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.firewall.rules.with_streaming_response.edit( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) + rule = response.parse() + assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_path_params_edit(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.firewall.rules.with_raw_response.edit( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.firewall.rules.with_raw_response.edit( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.firewall.rules.with_raw_response.edit( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.firewall.rules.with_raw_response.edit( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) @parametrize def test_method_get(self, client: Cloudflare) -> None: - rule = client.firewall.rules.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - ) + with pytest.warns(DeprecationWarning): + rule = client.firewall.rules.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + ) + assert_matches_type(FirewallRule, rule, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: - rule = client.firewall.rules.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - query_id="372e67954025e0ba6aaa6d586b9e0b60", - ) + with pytest.warns(DeprecationWarning): + rule = client.firewall.rules.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + query_id="372e67954025e0ba6aaa6d586b9e0b60", + ) + assert_matches_type(FirewallRule, rule, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.firewall.rules.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - ) + with pytest.warns(DeprecationWarning): + response = client.firewall.rules.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -312,32 +346,34 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.firewall.rules.with_streaming_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.firewall.rules.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) + rule = response.parse() + assert_matches_type(FirewallRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `path_id` but received ''"): - client.firewall.rules.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="", - query_id="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `path_id` but received ''"): + client.firewall.rules.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="", + query_id="", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.firewall.rules.with_raw_response.get( - "", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.firewall.rules.with_raw_response.get( + "", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + ) class TestAsyncRules: @@ -346,19 +382,22 @@ class TestAsyncRules: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.firewall.rules.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rule = await async_client.firewall.rules.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.rules.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.firewall.rules.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -368,45 +407,50 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.rules.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.firewall.rules.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) + rule = await response.parse() + assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.firewall.rules.with_raw_response.create( - "", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.firewall.rules.with_raw_response.create( + "", + body={}, + ) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.firewall.rules.update( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rule = await async_client.firewall.rules.update( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(FirewallRule, rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.rules.with_raw_response.update( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.firewall.rules.with_raw_response.update( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -416,61 +460,68 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.rules.with_streaming_response.update( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.firewall.rules.with_streaming_response.update( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) + rule = await response.parse() + assert_matches_type(FirewallRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.firewall.rules.with_raw_response.update( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.firewall.rules.with_raw_response.update( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.firewall.rules.with_raw_response.update( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.firewall.rules.with_raw_response.update( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.firewall.rules.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + rule = await async_client.firewall.rules.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.firewall.rules.list( - "023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b60", - action="block", - description="mir", - page=1, - paused=False, - per_page=5, - ) + with pytest.warns(DeprecationWarning): + rule = await async_client.firewall.rules.list( + "023e105f4ecef8ad9ca31a8372d0c353", + id="372e67954025e0ba6aaa6d586b9e0b60", + action="block", + description="mir", + page=1, + paused=False, + per_page=5, + ) + assert_matches_type(AsyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.rules.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.firewall.rules.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -479,38 +530,43 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.rules.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.firewall.rules.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) + rule = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.firewall.rules.with_raw_response.list( - "", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.firewall.rules.with_raw_response.list( + "", + ) @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.firewall.rules.delete( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + rule = await async_client.firewall.rules.delete( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(FirewallRule, rule, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.rules.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.firewall.rules.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -519,50 +575,55 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.rules.with_streaming_response.delete( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.firewall.rules.with_streaming_response.delete( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) + rule = await response.parse() + assert_matches_type(FirewallRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.firewall.rules.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.firewall.rules.with_raw_response.delete( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.firewall.rules.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.firewall.rules.with_raw_response.delete( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.firewall.rules.edit( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rule = await async_client.firewall.rules.edit( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.rules.with_raw_response.edit( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.firewall.rules.with_raw_response.edit( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -572,59 +633,66 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.rules.with_streaming_response.edit( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.firewall.rules.with_streaming_response.edit( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) + rule = await response.parse() + assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.firewall.rules.with_raw_response.edit( - "372e67954025e0ba6aaa6d586b9e0b60", - zone_identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.firewall.rules.with_raw_response.edit( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.firewall.rules.with_raw_response.edit( + "372e67954025e0ba6aaa6d586b9e0b60", + zone_identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.firewall.rules.with_raw_response.edit( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.firewall.rules.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - ) + with pytest.warns(DeprecationWarning): + rule = await async_client.firewall.rules.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + ) + assert_matches_type(FirewallRule, rule, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.firewall.rules.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - query_id="372e67954025e0ba6aaa6d586b9e0b60", - ) + with pytest.warns(DeprecationWarning): + rule = await async_client.firewall.rules.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + query_id="372e67954025e0ba6aaa6d586b9e0b60", + ) + assert_matches_type(FirewallRule, rule, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.rules.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.firewall.rules.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -633,29 +701,31 @@ 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.firewall.rules.with_streaming_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.firewall.rules.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) + rule = await response.parse() + assert_matches_type(FirewallRule, rule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `path_id` but received ''"): - await async_client.firewall.rules.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - path_id="", - query_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.firewall.rules.with_raw_response.get( - "", - path_id="372e67954025e0ba6aaa6d586b9e0b60", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `path_id` but received ''"): + await async_client.firewall.rules.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + path_id="", + query_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.firewall.rules.with_raw_response.get( + "", + path_id="372e67954025e0ba6aaa6d586b9e0b60", + ) diff --git a/tests/api_resources/test_pagerules.py b/tests/api_resources/test_pagerules.py index fbc26716f3e..3a54b5d879f 100644 --- a/tests/api_resources/test_pagerules.py +++ b/tests/api_resources/test_pagerules.py @@ -18,6 +18,8 @@ PageruleUpdateResponse, ) +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -26,77 +28,82 @@ class TestPagerules: @parametrize def test_method_create(self, client: Cloudflare) -> None: - pagerule = client.pagerules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) + assert_matches_type(PageruleCreateResponse, pagerule, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: - pagerule = client.pagerules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[ - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", - }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[ + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - ], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - "target": "url", - } - ], - priority=0, - status="active", - ) + ], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + priority=0, + status="active", + ) + assert_matches_type(PageruleCreateResponse, pagerule, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.pagerules.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) + with pytest.warns(DeprecationWarning): + response = client.pagerules.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -105,32 +112,52 @@ def test_raw_response_create(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.pagerules.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.pagerules.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = response.parse() - assert_matches_type(PageruleCreateResponse, pagerule, path=["response"]) + pagerule = response.parse() + assert_matches_type(PageruleCreateResponse, pagerule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.pagerules.with_raw_response.create( - zone_id="", + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.pagerules.with_raw_response.create( + zone_id="", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", actions=[{}, {}, {}], targets=[ { @@ -143,118 +170,58 @@ def test_path_params_create(self, client: Cloudflare) -> None: ], ) - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - pagerule = client.pagerules.update( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: - pagerule = client.pagerules.update( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[ - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", - }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", - }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[ + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - ], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - "target": "url", - } - ], - priority=0, - status="active", - ) - assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) - - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.pagerules.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - "target": "url", - } - ], - ) + ], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + priority=0, + status="active", + ) - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = response.parse() assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.pagerules.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - pagerule = response.parse() - assert_matches_type(PageruleUpdateResponse, pagerule, 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 `zone_id` but received ''"): - client.pagerules.with_raw_response.update( + def test_raw_response_update(self, client: Cloudflare) -> None: + with pytest.warns(DeprecationWarning): + response = client.pagerules.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", actions=[{}, {}, {}], targets=[ { @@ -267,9 +234,16 @@ def test_path_params_update(self, client: Cloudflare) -> None: ], ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): - client.pagerules.with_raw_response.update( - "", + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + pagerule = response.parse() + assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with pytest.warns(DeprecationWarning): + with client.pagerules.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", actions=[{}, {}, {}], targets=[ @@ -281,31 +255,78 @@ def test_path_params_update(self, client: Cloudflare) -> None: "target": "url", } ], - ) + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + pagerule = response.parse() + assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.pagerules.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): + client.pagerules.with_raw_response.update( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) @parametrize def test_method_list(self, client: Cloudflare) -> None: - pagerule = client.pagerules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(PageruleListResponse, pagerule, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: - pagerule = client.pagerules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - direction="desc", - match="any", - order="status", - status="active", - ) + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + match="any", + order="status", + status="active", + ) + assert_matches_type(PageruleListResponse, pagerule, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.pagerules.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.pagerules.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -314,38 +335,43 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.pagerules.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.pagerules.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = response.parse() - assert_matches_type(PageruleListResponse, pagerule, path=["response"]) + pagerule = response.parse() + assert_matches_type(PageruleListResponse, pagerule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.pagerules.with_raw_response.list( - zone_id="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.pagerules.with_raw_response.list( + zone_id="", + ) @parametrize def test_method_delete(self, client: Cloudflare) -> None: - pagerule = client.pagerules.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[PageruleDeleteResponse], pagerule, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.pagerules.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.pagerules.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -354,88 +380,95 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.pagerules.with_streaming_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.pagerules.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = response.parse() - assert_matches_type(Optional[PageruleDeleteResponse], pagerule, path=["response"]) + pagerule = response.parse() + assert_matches_type(Optional[PageruleDeleteResponse], pagerule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.pagerules.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.pagerules.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): + client.pagerules.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): - client.pagerules.with_raw_response.delete( - "", + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.edit( + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - @parametrize - def test_method_edit(self, client: Cloudflare) -> None: - pagerule = client.pagerules.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) assert_matches_type(PageruleEditResponse, pagerule, path=["response"]) @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: - pagerule = client.pagerules.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[ - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", - }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[ + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - ], - priority=0, - status="active", - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - "target": "url", - } - ], - ) + ], + priority=0, + status="active", + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) + assert_matches_type(PageruleEditResponse, pagerule, path=["response"]) @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.pagerules.with_raw_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.pagerules.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -444,46 +477,51 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.pagerules.with_streaming_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.pagerules.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = response.parse() - assert_matches_type(PageruleEditResponse, pagerule, path=["response"]) + pagerule = response.parse() + assert_matches_type(PageruleEditResponse, pagerule, 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 `zone_id` but received ''"): - client.pagerules.with_raw_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.pagerules.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): + client.pagerules.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): - client.pagerules.with_raw_response.edit( - "", + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + with pytest.warns(DeprecationWarning): + pagerule = client.pagerules.get( + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - pagerule = client.pagerules.get( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) assert_matches_type(PageruleGetResponse, pagerule, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.pagerules.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.pagerules.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -492,31 +530,33 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.pagerules.with_streaming_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.pagerules.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = response.parse() - assert_matches_type(PageruleGetResponse, pagerule, path=["response"]) + pagerule = response.parse() + assert_matches_type(PageruleGetResponse, pagerule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.pagerules.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.pagerules.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): - client.pagerules.with_raw_response.get( - "", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): + client.pagerules.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) class TestAsyncPagerules: @@ -524,77 +564,82 @@ class TestAsyncPagerules: @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) + assert_matches_type(PageruleCreateResponse, pagerule, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[ - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", - }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[ + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - ], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - "target": "url", - } - ], - priority=0, - status="active", - ) + ], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + priority=0, + status="active", + ) + assert_matches_type(PageruleCreateResponse, pagerule, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.pagerules.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) + with pytest.warns(DeprecationWarning): + response = await async_client.pagerules.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -603,32 +648,52 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.pagerules.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.pagerules.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = await response.parse() - assert_matches_type(PageruleCreateResponse, pagerule, path=["response"]) + pagerule = await response.parse() + assert_matches_type(PageruleCreateResponse, pagerule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.pagerules.with_raw_response.create( - zone_id="", + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.pagerules.with_raw_response.create( + zone_id="", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", actions=[{}, {}, {}], targets=[ { @@ -641,118 +706,58 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: ], ) - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.update( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.update( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[ - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", - }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", - }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[ + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - ], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - "target": "url", - } - ], - priority=0, - status="active", - ) - assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) - - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.pagerules.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - "target": "url", - } - ], - ) + ], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + priority=0, + status="active", + ) - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = await response.parse() assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.pagerules.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[{}, {}, {}], - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", - }, - "target": "url", - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - pagerule = await response.parse() - assert_matches_type(PageruleUpdateResponse, pagerule, 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 `zone_id` but received ''"): - await async_client.pagerules.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + with pytest.warns(DeprecationWarning): + response = await async_client.pagerules.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", actions=[{}, {}, {}], targets=[ { @@ -765,9 +770,16 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: ], ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): - await async_client.pagerules.with_raw_response.update( - "", + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + pagerule = await response.parse() + assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + with pytest.warns(DeprecationWarning): + async with async_client.pagerules.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", actions=[{}, {}, {}], targets=[ @@ -779,31 +791,78 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: "target": "url", } ], - ) + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + pagerule = await response.parse() + assert_matches_type(PageruleUpdateResponse, pagerule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.pagerules.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): + await async_client.pagerules.with_raw_response.update( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[{}, {}, {}], + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(PageruleListResponse, pagerule, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - direction="desc", - match="any", - order="status", - status="active", - ) + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + match="any", + order="status", + status="active", + ) + assert_matches_type(PageruleListResponse, pagerule, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.pagerules.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.pagerules.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -812,38 +871,43 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.pagerules.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.pagerules.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = await response.parse() - assert_matches_type(PageruleListResponse, pagerule, path=["response"]) + pagerule = await response.parse() + assert_matches_type(PageruleListResponse, pagerule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.pagerules.with_raw_response.list( - zone_id="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.pagerules.with_raw_response.list( + zone_id="", + ) @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[PageruleDeleteResponse], pagerule, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.pagerules.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.pagerules.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -852,88 +916,95 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.pagerules.with_streaming_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.pagerules.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = await response.parse() - assert_matches_type(Optional[PageruleDeleteResponse], pagerule, path=["response"]) + pagerule = await response.parse() + assert_matches_type(Optional[PageruleDeleteResponse], pagerule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.pagerules.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.pagerules.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): + await async_client.pagerules.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): - await async_client.pagerules.with_raw_response.delete( - "", + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.edit( + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - @parametrize - async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) assert_matches_type(PageruleEditResponse, pagerule, path=["response"]) @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - actions=[ - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", - }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + actions=[ + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - { - "name": "forward_url", - "value": { - "type": "temporary", - "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - }, - ], - priority=0, - status="active", - targets=[ - { - "constraint": { - "operator": "matches", - "value": "*example.com/images/*", + { + "name": "forward_url", + "value": { + "type": "temporary", + "url": "http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3", + }, }, - "target": "url", - } - ], - ) + ], + priority=0, + status="active", + targets=[ + { + "constraint": { + "operator": "matches", + "value": "*example.com/images/*", + }, + "target": "url", + } + ], + ) + assert_matches_type(PageruleEditResponse, pagerule, path=["response"]) @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - response = await async_client.pagerules.with_raw_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.pagerules.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -942,46 +1013,51 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - async with async_client.pagerules.with_streaming_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.pagerules.with_streaming_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = await response.parse() - assert_matches_type(PageruleEditResponse, pagerule, path=["response"]) + pagerule = await response.parse() + assert_matches_type(PageruleEditResponse, pagerule, 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 `zone_id` but received ''"): - await async_client.pagerules.with_raw_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.pagerules.with_raw_response.edit( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): + await async_client.pagerules.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): - await async_client.pagerules.with_raw_response.edit( - "", + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + with pytest.warns(DeprecationWarning): + pagerule = await async_client.pagerules.get( + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - pagerule = await async_client.pagerules.get( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) assert_matches_type(PageruleGetResponse, pagerule, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.pagerules.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.pagerules.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -990,28 +1066,30 @@ 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.pagerules.with_streaming_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.pagerules.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - pagerule = await response.parse() - assert_matches_type(PageruleGetResponse, pagerule, path=["response"]) + pagerule = await response.parse() + assert_matches_type(PageruleGetResponse, pagerule, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.pagerules.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): - await async_client.pagerules.with_raw_response.get( - "", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.pagerules.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"): + await async_client.pagerules.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/test_rate_limits.py b/tests/api_resources/test_rate_limits.py index 2a58e6b8e02..f03e02cb30c 100644 --- a/tests/api_resources/test_rate_limits.py +++ b/tests/api_resources/test_rate_limits.py @@ -18,6 +18,8 @@ RateLimitDeleteResponse, ) +# pyright: reportDeprecated=false + base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -27,19 +29,22 @@ class TestRateLimits: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_create(self, client: Cloudflare) -> None: - rate_limit = client.rate_limits.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rate_limit = client.rate_limits.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(RateLimitCreateResponse, rate_limit, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.rate_limits.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = client.rate_limits.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -49,48 +54,55 @@ def test_raw_response_create(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.rate_limits.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.rate_limits.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(RateLimitCreateResponse, rate_limit, path=["response"]) + rate_limit = response.parse() + assert_matches_type(RateLimitCreateResponse, rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.rate_limits.with_raw_response.create( - "", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.rate_limits.with_raw_response.create( + "", + body={}, + ) @parametrize def test_method_list(self, client: Cloudflare) -> None: - rate_limit = client.rate_limits.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + rate_limit = client.rate_limits.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: - rate_limit = client.rate_limits.list( - "023e105f4ecef8ad9ca31a8372d0c353", - page=1, - per_page=1, - ) + with pytest.warns(DeprecationWarning): + rate_limit = client.rate_limits.list( + "023e105f4ecef8ad9ca31a8372d0c353", + page=1, + per_page=1, + ) + assert_matches_type(SyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.rate_limits.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.rate_limits.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -99,38 +111,43 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.rate_limits.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.rate_limits.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(SyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) + rate_limit = response.parse() + assert_matches_type(SyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.rate_limits.with_raw_response.list( - "", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.rate_limits.with_raw_response.list( + "", + ) @parametrize def test_method_delete(self, client: Cloudflare) -> None: - rate_limit = client.rate_limits.delete( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + rate_limit = client.rate_limits.delete( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.rate_limits.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.rate_limits.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -139,50 +156,55 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.rate_limits.with_streaming_response.delete( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.rate_limits.with_streaming_response.delete( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) + rate_limit = response.parse() + assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.rate_limits.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.rate_limits.with_raw_response.delete( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.rate_limits.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.rate_limits.with_raw_response.delete( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_edit(self, client: Cloudflare) -> None: - rate_limit = client.rate_limits.edit( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rate_limit = client.rate_limits.edit( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(RateLimitEditResponse, rate_limit, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.rate_limits.with_raw_response.edit( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = client.rate_limits.with_raw_response.edit( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -192,50 +214,55 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.rate_limits.with_streaming_response.edit( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.rate_limits.with_streaming_response.edit( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(RateLimitEditResponse, rate_limit, path=["response"]) + rate_limit = response.parse() + assert_matches_type(RateLimitEditResponse, rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_path_params_edit(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.rate_limits.with_raw_response.edit( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.rate_limits.with_raw_response.edit( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.rate_limits.with_raw_response.edit( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.rate_limits.with_raw_response.edit( - "", + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + with pytest.warns(DeprecationWarning): + rate_limit = client.rate_limits.get( + "372e67954025e0ba6aaa6d586b9e0b59", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, ) - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - rate_limit = client.rate_limits.get( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) assert_matches_type(RateLimitGetResponse, rate_limit, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.rate_limits.with_raw_response.get( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = client.rate_limits.with_raw_response.get( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -244,31 +271,33 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.rate_limits.with_streaming_response.get( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + with client.rate_limits.with_streaming_response.get( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(RateLimitGetResponse, rate_limit, path=["response"]) + rate_limit = response.parse() + assert_matches_type(RateLimitGetResponse, rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - client.rate_limits.with_raw_response.get( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + client.rate_limits.with_raw_response.get( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="", + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.rate_limits.with_raw_response.get( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.rate_limits.with_raw_response.get( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) class TestAsyncRateLimits: @@ -277,19 +306,22 @@ class TestAsyncRateLimits: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: - rate_limit = await async_client.rate_limits.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rate_limit = await async_client.rate_limits.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(RateLimitCreateResponse, rate_limit, 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.rate_limits.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.rate_limits.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -299,48 +331,55 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.rate_limits.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.rate_limits.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(RateLimitCreateResponse, rate_limit, path=["response"]) + rate_limit = await response.parse() + assert_matches_type(RateLimitCreateResponse, rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.rate_limits.with_raw_response.create( - "", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.rate_limits.with_raw_response.create( + "", + body={}, + ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: - rate_limit = await async_client.rate_limits.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + rate_limit = await async_client.rate_limits.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - rate_limit = await async_client.rate_limits.list( - "023e105f4ecef8ad9ca31a8372d0c353", - page=1, - per_page=1, - ) + with pytest.warns(DeprecationWarning): + rate_limit = await async_client.rate_limits.list( + "023e105f4ecef8ad9ca31a8372d0c353", + page=1, + per_page=1, + ) + assert_matches_type(AsyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rate_limits.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.rate_limits.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -349,38 +388,43 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.rate_limits.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.rate_limits.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) + rate_limit = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.rate_limits.with_raw_response.list( - "", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.rate_limits.with_raw_response.list( + "", + ) @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - rate_limit = await async_client.rate_limits.delete( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + rate_limit = await async_client.rate_limits.delete( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rate_limits.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.rate_limits.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -389,50 +433,55 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.rate_limits.with_streaming_response.delete( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.rate_limits.with_streaming_response.delete( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) + rate_limit = await response.parse() + assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.rate_limits.with_raw_response.delete( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.rate_limits.with_raw_response.delete( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.rate_limits.with_raw_response.delete( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.rate_limits.with_raw_response.delete( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - rate_limit = await async_client.rate_limits.edit( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + rate_limit = await async_client.rate_limits.edit( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(RateLimitEditResponse, rate_limit, 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.rate_limits.with_raw_response.edit( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) + with pytest.warns(DeprecationWarning): + response = await async_client.rate_limits.with_raw_response.edit( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -442,50 +491,55 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - async with async_client.rate_limits.with_streaming_response.edit( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.rate_limits.with_streaming_response.edit( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(RateLimitEditResponse, rate_limit, path=["response"]) + rate_limit = await response.parse() + assert_matches_type(RateLimitEditResponse, rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.rate_limits.with_raw_response.edit( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="", - body={}, - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.rate_limits.with_raw_response.edit( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.rate_limits.with_raw_response.edit( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.rate_limits.with_raw_response.edit( - "", + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + with pytest.warns(DeprecationWarning): + rate_limit = await async_client.rate_limits.get( + "372e67954025e0ba6aaa6d586b9e0b59", zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - body={}, ) - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - rate_limit = await async_client.rate_limits.get( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) assert_matches_type(RateLimitGetResponse, rate_limit, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rate_limits.with_raw_response.get( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + response = await async_client.rate_limits.with_raw_response.get( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -494,28 +548,30 @@ 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.rate_limits.with_streaming_response.get( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + with pytest.warns(DeprecationWarning): + async with async_client.rate_limits.with_streaming_response.get( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(RateLimitGetResponse, rate_limit, path=["response"]) + rate_limit = await response.parse() + assert_matches_type(RateLimitGetResponse, rate_limit, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): - await async_client.rate_limits.with_raw_response.get( - "372e67954025e0ba6aaa6d586b9e0b59", - zone_identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.rate_limits.with_raw_response.get( - "", - zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) + with pytest.warns(DeprecationWarning): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_identifier` but received ''"): + await async_client.rate_limits.with_raw_response.get( + "372e67954025e0ba6aaa6d586b9e0b59", + zone_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.rate_limits.with_raw_response.get( + "", + zone_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) From b4a7b95fc1db93eed0b01d63e583d1803490b915 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 05:28:51 +0000 Subject: [PATCH 171/532] feat(api): update via SDK Studio (#652) --- api.md | 2 +- src/cloudflare/types/firewall/__init__.py | 2 +- src/cloudflare/types/firewall/firewall_rule.py | 4 ++-- src/cloudflare/types/firewall/{products.py => product.py} | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename src/cloudflare/types/firewall/{products.py => product.py} (51%) diff --git a/api.md b/api.md index 405673a113d..550e230b999 100644 --- a/api.md +++ b/api.md @@ -1859,7 +1859,7 @@ Types: ```python from cloudflare.types.firewall import ( FirewallRule, - Products, + Product, DeletedFilter, RuleCreateResponse, RuleEditResponse, diff --git a/src/cloudflare/types/firewall/__init__.py b/src/cloudflare/types/firewall/__init__.py index 3c81f93f594..b93cee390ef 100644 --- a/src/cloudflare/types/firewall/__init__.py +++ b/src/cloudflare/types/firewall/__init__.py @@ -2,8 +2,8 @@ from __future__ import annotations +from .product import Product as Product from .lockdown import Lockdown as Lockdown -from .products import Products as Products from .lockdown_url import LockdownURL as LockdownURL from .configuration import Configuration as Configuration from .firewall_rule import FirewallRule as FirewallRule diff --git a/src/cloudflare/types/firewall/firewall_rule.py b/src/cloudflare/types/firewall/firewall_rule.py index 8c3a20fffad..179de38e86d 100644 --- a/src/cloudflare/types/firewall/firewall_rule.py +++ b/src/cloudflare/types/firewall/firewall_rule.py @@ -2,7 +2,7 @@ from typing import List, Union, Optional -from .products import Products +from .product import Product from ..._models import BaseModel from .deleted_filter import DeletedFilter from ..rate_limits.action import Action @@ -39,7 +39,7 @@ class FirewallRule(BaseModel): processed before rules without a priority. """ - products: Optional[List[Products]] = None + products: Optional[List[Product]] = None ref: Optional[str] = None """A short reference tag. Allows you to select related firewall rules.""" diff --git a/src/cloudflare/types/firewall/products.py b/src/cloudflare/types/firewall/product.py similarity index 51% rename from src/cloudflare/types/firewall/products.py rename to src/cloudflare/types/firewall/product.py index 0dc537616f5..5a004e3217c 100644 --- a/src/cloudflare/types/firewall/products.py +++ b/src/cloudflare/types/firewall/product.py @@ -2,6 +2,6 @@ from typing_extensions import Literal -__all__ = ["Products"] +__all__ = ["Product"] -Products = Literal["zoneLockdown", "uaBlock", "bic", "hot", "securityLevel", "rateLimit", "waf"] +Product = Literal["zoneLockdown", "uaBlock", "bic", "hot", "securityLevel", "rateLimit", "waf"] From 361ea657440eac80e10cf7ae75b279d1ad2b4b9c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 08:58:08 +0000 Subject: [PATCH 172/532] feat(api): OpenAPI spec update via Stainless API (#653) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5e1891fd453..497b4379eaa 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1297 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaf3cf93b4b0566484405b918a65aeca6e5ad4cc194989298a633601684fa0c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58dd5f372a5541a8dc05fb00967feee663eb81b0a8a1eb23e4318335bdb98a8.yml diff --git a/api.md b/api.md index 550e230b999..2874708a221 100644 --- a/api.md +++ b/api.md @@ -3655,7 +3655,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7496,14 +7496,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7519,10 +7519,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7539,11 +7539,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From cedd157d6e5f50ec792e48616d905325b47861d3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 09:00:13 +0000 Subject: [PATCH 173/532] feat(api): OpenAPI spec update via Stainless API (#654) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 497b4379eaa..5e1891fd453 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1297 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58dd5f372a5541a8dc05fb00967feee663eb81b0a8a1eb23e4318335bdb98a8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaf3cf93b4b0566484405b918a65aeca6e5ad4cc194989298a633601684fa0c1.yml diff --git a/api.md b/api.md index 2874708a221..550e230b999 100644 --- a/api.md +++ b/api.md @@ -3655,7 +3655,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7496,14 +7496,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7519,10 +7519,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7539,11 +7539,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From c7129498b1440e01beefca6cf9e8ee40348c537f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 09:51:20 +0000 Subject: [PATCH 174/532] feat(api): OpenAPI spec update via Stainless API (#655) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5e1891fd453..497b4379eaa 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1297 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaf3cf93b4b0566484405b918a65aeca6e5ad4cc194989298a633601684fa0c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58dd5f372a5541a8dc05fb00967feee663eb81b0a8a1eb23e4318335bdb98a8.yml diff --git a/api.md b/api.md index 550e230b999..2874708a221 100644 --- a/api.md +++ b/api.md @@ -3655,7 +3655,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7496,14 +7496,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7519,10 +7519,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7539,11 +7539,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 1f439342499e40cd2d9417c31cbcd713893e8ef3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 09:53:25 +0000 Subject: [PATCH 175/532] feat(api): OpenAPI spec update via Stainless API (#656) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 497b4379eaa..2c80d1ccf15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1297 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58dd5f372a5541a8dc05fb00967feee663eb81b0a8a1eb23e4318335bdb98a8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d798919f06fdb766d1e047f3a387fa78bdee979130963b425176a00429b842b9.yml From ccf7bfd16d285a57c897e8e299623a10543d08ef Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 13:28:21 +0000 Subject: [PATCH 176/532] feat(api): OpenAPI spec update via Stainless API (#657) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2c80d1ccf15..719796ae247 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1297 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d798919f06fdb766d1e047f3a387fa78bdee979130963b425176a00429b842b9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5cc7607a4825bf9606463ee28fc976b8498b237c981bcb896211b60b6fe5c146.yml diff --git a/api.md b/api.md index 2874708a221..550e230b999 100644 --- a/api.md +++ b/api.md @@ -3655,7 +3655,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7496,14 +7496,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7519,10 +7519,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7539,11 +7539,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From dcd2dcb7d59ae9ba0bf2caabd184c92348657982 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 02:53:14 +0000 Subject: [PATCH 177/532] feat(api): update via SDK Studio (#658) --- api.md | 4 +- .../uuid.py => dcv_delegation.py} | 68 ++++++++-------- .../resources/dcv_delegation/__init__.py | 33 -------- .../dcv_delegation/dcv_delegation.py | 80 ------------------- .../api_resources/dcv_delegation/__init__.py | 1 - .../test_uuid.py => test_dcv_delegation.py} | 40 +++++----- 6 files changed, 55 insertions(+), 171 deletions(-) rename src/cloudflare/resources/{dcv_delegation/uuid.py => dcv_delegation.py} (67%) delete mode 100644 src/cloudflare/resources/dcv_delegation/__init__.py delete mode 100644 src/cloudflare/resources/dcv_delegation/dcv_delegation.py delete mode 100644 tests/api_resources/dcv_delegation/__init__.py rename tests/api_resources/{dcv_delegation/test_uuid.py => test_dcv_delegation.py} (67%) diff --git a/api.md b/api.md index 550e230b999..400b9ec5faa 100644 --- a/api.md +++ b/api.md @@ -7368,8 +7368,6 @@ Methods: # DCVDelegation -## UUID - Types: ```python @@ -7378,7 +7376,7 @@ from cloudflare.types.dcv_delegation import DCVDelegationUUID Methods: -- client.dcv_delegation.uuid.get(\*, zone_id) -> Optional +- client.dcv_delegation.get(\*, zone_id) -> Optional # Hostnames diff --git a/src/cloudflare/resources/dcv_delegation/uuid.py b/src/cloudflare/resources/dcv_delegation.py similarity index 67% rename from src/cloudflare/resources/dcv_delegation/uuid.py rename to src/cloudflare/resources/dcv_delegation.py index c0c57c0ea2c..18aa2d28f43 100644 --- a/src/cloudflare/resources/dcv_delegation/uuid.py +++ b/src/cloudflare/resources/dcv_delegation.py @@ -6,32 +6,32 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( +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 ( +from .._wrappers import ResultWrapper +from .._base_client import ( make_request_options, ) -from ...types.dcv_delegation.dcv_delegation_uuid import DCVDelegationUUID +from ..types.dcv_delegation.dcv_delegation_uuid import DCVDelegationUUID -__all__ = ["UUIDResource", "AsyncUUIDResource"] +__all__ = ["DCVDelegationResource", "AsyncDCVDelegationResource"] -class UUIDResource(SyncAPIResource): +class DCVDelegationResource(SyncAPIResource): @cached_property - def with_raw_response(self) -> UUIDResourceWithRawResponse: - return UUIDResourceWithRawResponse(self) + def with_raw_response(self) -> DCVDelegationResourceWithRawResponse: + return DCVDelegationResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> UUIDResourceWithStreamingResponse: - return UUIDResourceWithStreamingResponse(self) + def with_streaming_response(self) -> DCVDelegationResourceWithStreamingResponse: + return DCVDelegationResourceWithStreamingResponse(self) def get( self, @@ -74,14 +74,14 @@ def get( ) -class AsyncUUIDResource(AsyncAPIResource): +class AsyncDCVDelegationResource(AsyncAPIResource): @cached_property - def with_raw_response(self) -> AsyncUUIDResourceWithRawResponse: - return AsyncUUIDResourceWithRawResponse(self) + def with_raw_response(self) -> AsyncDCVDelegationResourceWithRawResponse: + return AsyncDCVDelegationResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncUUIDResourceWithStreamingResponse: - return AsyncUUIDResourceWithStreamingResponse(self) + def with_streaming_response(self) -> AsyncDCVDelegationResourceWithStreamingResponse: + return AsyncDCVDelegationResourceWithStreamingResponse(self) async def get( self, @@ -124,37 +124,37 @@ async def get( ) -class UUIDResourceWithRawResponse: - def __init__(self, uuid: UUIDResource) -> None: - self._uuid = uuid +class DCVDelegationResourceWithRawResponse: + def __init__(self, dcv_delegation: DCVDelegationResource) -> None: + self._dcv_delegation = dcv_delegation self.get = to_raw_response_wrapper( - uuid.get, + dcv_delegation.get, ) -class AsyncUUIDResourceWithRawResponse: - def __init__(self, uuid: AsyncUUIDResource) -> None: - self._uuid = uuid +class AsyncDCVDelegationResourceWithRawResponse: + def __init__(self, dcv_delegation: AsyncDCVDelegationResource) -> None: + self._dcv_delegation = dcv_delegation self.get = async_to_raw_response_wrapper( - uuid.get, + dcv_delegation.get, ) -class UUIDResourceWithStreamingResponse: - def __init__(self, uuid: UUIDResource) -> None: - self._uuid = uuid +class DCVDelegationResourceWithStreamingResponse: + def __init__(self, dcv_delegation: DCVDelegationResource) -> None: + self._dcv_delegation = dcv_delegation self.get = to_streamed_response_wrapper( - uuid.get, + dcv_delegation.get, ) -class AsyncUUIDResourceWithStreamingResponse: - def __init__(self, uuid: AsyncUUIDResource) -> None: - self._uuid = uuid +class AsyncDCVDelegationResourceWithStreamingResponse: + def __init__(self, dcv_delegation: AsyncDCVDelegationResource) -> None: + self._dcv_delegation = dcv_delegation self.get = async_to_streamed_response_wrapper( - uuid.get, + dcv_delegation.get, ) diff --git a/src/cloudflare/resources/dcv_delegation/__init__.py b/src/cloudflare/resources/dcv_delegation/__init__.py deleted file mode 100644 index 774c44e1985..00000000000 --- a/src/cloudflare/resources/dcv_delegation/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .uuid import ( - UUIDResource, - AsyncUUIDResource, - UUIDResourceWithRawResponse, - AsyncUUIDResourceWithRawResponse, - UUIDResourceWithStreamingResponse, - AsyncUUIDResourceWithStreamingResponse, -) -from .dcv_delegation import ( - DCVDelegationResource, - AsyncDCVDelegationResource, - DCVDelegationResourceWithRawResponse, - AsyncDCVDelegationResourceWithRawResponse, - DCVDelegationResourceWithStreamingResponse, - AsyncDCVDelegationResourceWithStreamingResponse, -) - -__all__ = [ - "UUIDResource", - "AsyncUUIDResource", - "UUIDResourceWithRawResponse", - "AsyncUUIDResourceWithRawResponse", - "UUIDResourceWithStreamingResponse", - "AsyncUUIDResourceWithStreamingResponse", - "DCVDelegationResource", - "AsyncDCVDelegationResource", - "DCVDelegationResourceWithRawResponse", - "AsyncDCVDelegationResourceWithRawResponse", - "DCVDelegationResourceWithStreamingResponse", - "AsyncDCVDelegationResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/dcv_delegation/dcv_delegation.py b/src/cloudflare/resources/dcv_delegation/dcv_delegation.py deleted file mode 100644 index d09a30ea18c..00000000000 --- a/src/cloudflare/resources/dcv_delegation/dcv_delegation.py +++ /dev/null @@ -1,80 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .uuid import ( - UUIDResource, - AsyncUUIDResource, - UUIDResourceWithRawResponse, - AsyncUUIDResourceWithRawResponse, - UUIDResourceWithStreamingResponse, - AsyncUUIDResourceWithStreamingResponse, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource - -__all__ = ["DCVDelegationResource", "AsyncDCVDelegationResource"] - - -class DCVDelegationResource(SyncAPIResource): - @cached_property - def uuid(self) -> UUIDResource: - return UUIDResource(self._client) - - @cached_property - def with_raw_response(self) -> DCVDelegationResourceWithRawResponse: - return DCVDelegationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> DCVDelegationResourceWithStreamingResponse: - return DCVDelegationResourceWithStreamingResponse(self) - - -class AsyncDCVDelegationResource(AsyncAPIResource): - @cached_property - def uuid(self) -> AsyncUUIDResource: - return AsyncUUIDResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncDCVDelegationResourceWithRawResponse: - return AsyncDCVDelegationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncDCVDelegationResourceWithStreamingResponse: - return AsyncDCVDelegationResourceWithStreamingResponse(self) - - -class DCVDelegationResourceWithRawResponse: - def __init__(self, dcv_delegation: DCVDelegationResource) -> None: - self._dcv_delegation = dcv_delegation - - @cached_property - def uuid(self) -> UUIDResourceWithRawResponse: - return UUIDResourceWithRawResponse(self._dcv_delegation.uuid) - - -class AsyncDCVDelegationResourceWithRawResponse: - def __init__(self, dcv_delegation: AsyncDCVDelegationResource) -> None: - self._dcv_delegation = dcv_delegation - - @cached_property - def uuid(self) -> AsyncUUIDResourceWithRawResponse: - return AsyncUUIDResourceWithRawResponse(self._dcv_delegation.uuid) - - -class DCVDelegationResourceWithStreamingResponse: - def __init__(self, dcv_delegation: DCVDelegationResource) -> None: - self._dcv_delegation = dcv_delegation - - @cached_property - def uuid(self) -> UUIDResourceWithStreamingResponse: - return UUIDResourceWithStreamingResponse(self._dcv_delegation.uuid) - - -class AsyncDCVDelegationResourceWithStreamingResponse: - def __init__(self, dcv_delegation: AsyncDCVDelegationResource) -> None: - self._dcv_delegation = dcv_delegation - - @cached_property - def uuid(self) -> AsyncUUIDResourceWithStreamingResponse: - return AsyncUUIDResourceWithStreamingResponse(self._dcv_delegation.uuid) diff --git a/tests/api_resources/dcv_delegation/__init__.py b/tests/api_resources/dcv_delegation/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/dcv_delegation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/dcv_delegation/test_uuid.py b/tests/api_resources/test_dcv_delegation.py similarity index 67% rename from tests/api_resources/dcv_delegation/test_uuid.py rename to tests/api_resources/test_dcv_delegation.py index a1d65863aa7..0f04ca1a893 100644 --- a/tests/api_resources/dcv_delegation/test_uuid.py +++ b/tests/api_resources/test_dcv_delegation.py @@ -14,85 +14,85 @@ base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -class TestUUID: +class TestDCVDelegation: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize def test_method_get(self, client: Cloudflare) -> None: - uuid = client.dcv_delegation.uuid.get( + dcv_delegation = client.dcv_delegation.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[DCVDelegationUUID], uuid, path=["response"]) + assert_matches_type(Optional[DCVDelegationUUID], dcv_delegation, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.dcv_delegation.uuid.with_raw_response.get( + response = client.dcv_delegation.with_raw_response.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - uuid = response.parse() - assert_matches_type(Optional[DCVDelegationUUID], uuid, path=["response"]) + dcv_delegation = response.parse() + assert_matches_type(Optional[DCVDelegationUUID], dcv_delegation, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.dcv_delegation.uuid.with_streaming_response.get( + with client.dcv_delegation.with_streaming_response.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - uuid = response.parse() - assert_matches_type(Optional[DCVDelegationUUID], uuid, path=["response"]) + dcv_delegation = response.parse() + assert_matches_type(Optional[DCVDelegationUUID], dcv_delegation, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.dcv_delegation.uuid.with_raw_response.get( + client.dcv_delegation.with_raw_response.get( zone_id="", ) -class TestAsyncUUID: +class TestAsyncDCVDelegation: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - uuid = await async_client.dcv_delegation.uuid.get( + dcv_delegation = await async_client.dcv_delegation.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[DCVDelegationUUID], uuid, path=["response"]) + assert_matches_type(Optional[DCVDelegationUUID], dcv_delegation, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.dcv_delegation.uuid.with_raw_response.get( + response = await async_client.dcv_delegation.with_raw_response.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - uuid = await response.parse() - assert_matches_type(Optional[DCVDelegationUUID], uuid, path=["response"]) + dcv_delegation = await response.parse() + assert_matches_type(Optional[DCVDelegationUUID], dcv_delegation, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.dcv_delegation.uuid.with_streaming_response.get( + async with async_client.dcv_delegation.with_streaming_response.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - uuid = await response.parse() - assert_matches_type(Optional[DCVDelegationUUID], uuid, path=["response"]) + dcv_delegation = await response.parse() + assert_matches_type(Optional[DCVDelegationUUID], dcv_delegation, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.dcv_delegation.uuid.with_raw_response.get( + await async_client.dcv_delegation.with_raw_response.get( zone_id="", ) From c7c44b4ee0d1c77083b3390ad72169274df6c412 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 03:54:28 +0000 Subject: [PATCH 178/532] feat(api): update via SDK Studio (#659) --- .stats.yml | 2 +- api.md | 140 ++++ src/cloudflare/_client.py | 8 + src/cloudflare/resources/__init__.py | 14 + .../resources/api_gateway/__init__.py | 117 +++ .../resources/api_gateway/api_gateway.py | 276 +++++++ .../resources/api_gateway/configurations.py | 285 +++++++ .../api_gateway/discovery/__init__.py | 33 + .../api_gateway/discovery/discovery.py | 192 +++++ .../api_gateway/discovery/operations.py | 399 ++++++++++ .../api_gateway/operations/__init__.py | 33 + .../api_gateway/operations/operations.py | 598 +++++++++++++++ .../operations/schema_validation.py | 379 ++++++++++ .../api_gateway/schema_validation.py | 211 ++++++ .../resources/api_gateway/schemas.py | 194 +++++ .../api_gateway/settings/__init__.py | 33 + .../api_gateway/settings/schema_validation.py | 291 +++++++ .../api_gateway/settings/settings.py | 80 ++ .../api_gateway/user_schemas/__init__.py | 33 + .../api_gateway/user_schemas/operations.py | 248 ++++++ .../api_gateway/user_schemas/user_schemas.py | 715 ++++++++++++++++++ src/cloudflare/types/api_gateway/__init__.py | 28 + .../types/api_gateway/api_shield.py | 99 +++ .../types/api_gateway/configuration.py | 46 ++ .../api_gateway/configuration_get_params.py | 16 + .../configuration_update_params.py | 49 ++ .../configuration_update_response.py | 7 + .../types/api_gateway/discovery/__init__.py | 7 + .../discovery/operation_edit_params.py | 19 + .../discovery/operation_edit_response.py | 18 + .../discovery/operation_list_params.py | 62 ++ .../api_gateway/discovery_get_response.py | 14 + .../types/api_gateway/discovery_operation.py | 57 ++ src/cloudflare/types/api_gateway/message.py | 9 + .../api_gateway/operation_create_params.py | 31 + .../api_gateway/operation_create_response.py | 9 + .../api_gateway/operation_delete_response.py | 7 + .../types/api_gateway/operation_get_params.py | 21 + .../api_gateway/operation_list_params.py | 46 ++ .../types/api_gateway/operations/__init__.py | 10 + .../schema_validation_edit_params.py | 16 + .../schema_validation_get_response.py | 21 + .../schema_validation_update_params.py | 24 + .../schema_validation_update_response.py | 21 + .../operations/settings_multiple_request.py | 24 + .../settings_multiple_request_param.py | 24 + .../types/api_gateway/public_schema.py | 28 + src/cloudflare/types/api_gateway/schema.py | 19 + .../types/api_gateway/schema_list_params.py | 24 + .../types/api_gateway/schema_list_response.py | 13 + .../types/api_gateway/schema_upload.py | 40 + .../schema_validation_edit_params.py | 37 + .../types/api_gateway/settings/__init__.py | 6 + .../schema_validation_update_params.py | 36 + .../types/api_gateway/settings/settings.py | 31 + .../api_gateway/user_schema_create_params.py | 26 + .../user_schema_delete_response.py | 7 + .../api_gateway/user_schema_edit_params.py | 15 + .../api_gateway/user_schema_get_params.py | 15 + .../api_gateway/user_schema_list_params.py | 24 + .../api_gateway/user_schemas/__init__.py | 6 + .../user_schemas/operation_list_params.py | 44 ++ .../user_schemas/operation_list_response.py | 28 + tests/api_resources/api_gateway/__init__.py | 1 + .../api_gateway/discovery/__init__.py | 1 + .../api_gateway/discovery/test_operations.py | 248 ++++++ .../api_gateway/operations/__init__.py | 1 + .../operations/test_schema_validation.py | 344 +++++++++ .../api_gateway/settings/__init__.py | 1 + .../settings/test_schema_validation.py | 200 +++++ .../api_gateway/test_configurations.py | 219 ++++++ .../api_gateway/test_discovery.py | 98 +++ .../api_gateway/test_operations.py | 555 ++++++++++++++ .../api_gateway/test_schema_validation.py | 116 +++ .../api_resources/api_gateway/test_schemas.py | 116 +++ .../api_gateway/test_user_schemas.py | 563 ++++++++++++++ .../api_gateway/user_schemas/__init__.py | 1 + .../user_schemas/test_operations.py | 149 ++++ 78 files changed, 7977 insertions(+), 1 deletion(-) create mode 100644 src/cloudflare/resources/api_gateway/__init__.py create mode 100644 src/cloudflare/resources/api_gateway/api_gateway.py create mode 100644 src/cloudflare/resources/api_gateway/configurations.py create mode 100644 src/cloudflare/resources/api_gateway/discovery/__init__.py create mode 100644 src/cloudflare/resources/api_gateway/discovery/discovery.py create mode 100644 src/cloudflare/resources/api_gateway/discovery/operations.py create mode 100644 src/cloudflare/resources/api_gateway/operations/__init__.py create mode 100644 src/cloudflare/resources/api_gateway/operations/operations.py create mode 100644 src/cloudflare/resources/api_gateway/operations/schema_validation.py create mode 100644 src/cloudflare/resources/api_gateway/schema_validation.py create mode 100644 src/cloudflare/resources/api_gateway/schemas.py create mode 100644 src/cloudflare/resources/api_gateway/settings/__init__.py create mode 100644 src/cloudflare/resources/api_gateway/settings/schema_validation.py create mode 100644 src/cloudflare/resources/api_gateway/settings/settings.py create mode 100644 src/cloudflare/resources/api_gateway/user_schemas/__init__.py create mode 100644 src/cloudflare/resources/api_gateway/user_schemas/operations.py create mode 100644 src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py create mode 100644 src/cloudflare/types/api_gateway/__init__.py create mode 100644 src/cloudflare/types/api_gateway/api_shield.py create mode 100644 src/cloudflare/types/api_gateway/configuration.py create mode 100644 src/cloudflare/types/api_gateway/configuration_get_params.py create mode 100644 src/cloudflare/types/api_gateway/configuration_update_params.py create mode 100644 src/cloudflare/types/api_gateway/configuration_update_response.py create mode 100644 src/cloudflare/types/api_gateway/discovery/__init__.py create mode 100644 src/cloudflare/types/api_gateway/discovery/operation_edit_params.py create mode 100644 src/cloudflare/types/api_gateway/discovery/operation_edit_response.py create mode 100644 src/cloudflare/types/api_gateway/discovery/operation_list_params.py create mode 100644 src/cloudflare/types/api_gateway/discovery_get_response.py create mode 100644 src/cloudflare/types/api_gateway/discovery_operation.py create mode 100644 src/cloudflare/types/api_gateway/message.py create mode 100644 src/cloudflare/types/api_gateway/operation_create_params.py create mode 100644 src/cloudflare/types/api_gateway/operation_create_response.py create mode 100644 src/cloudflare/types/api_gateway/operation_delete_response.py create mode 100644 src/cloudflare/types/api_gateway/operation_get_params.py create mode 100644 src/cloudflare/types/api_gateway/operation_list_params.py create mode 100644 src/cloudflare/types/api_gateway/operations/__init__.py create mode 100644 src/cloudflare/types/api_gateway/operations/schema_validation_edit_params.py create mode 100644 src/cloudflare/types/api_gateway/operations/schema_validation_get_response.py create mode 100644 src/cloudflare/types/api_gateway/operations/schema_validation_update_params.py create mode 100644 src/cloudflare/types/api_gateway/operations/schema_validation_update_response.py create mode 100644 src/cloudflare/types/api_gateway/operations/settings_multiple_request.py create mode 100644 src/cloudflare/types/api_gateway/operations/settings_multiple_request_param.py create mode 100644 src/cloudflare/types/api_gateway/public_schema.py create mode 100644 src/cloudflare/types/api_gateway/schema.py create mode 100644 src/cloudflare/types/api_gateway/schema_list_params.py create mode 100644 src/cloudflare/types/api_gateway/schema_list_response.py create mode 100644 src/cloudflare/types/api_gateway/schema_upload.py create mode 100644 src/cloudflare/types/api_gateway/schema_validation_edit_params.py create mode 100644 src/cloudflare/types/api_gateway/settings/__init__.py create mode 100644 src/cloudflare/types/api_gateway/settings/schema_validation_update_params.py create mode 100644 src/cloudflare/types/api_gateway/settings/settings.py create mode 100644 src/cloudflare/types/api_gateway/user_schema_create_params.py create mode 100644 src/cloudflare/types/api_gateway/user_schema_delete_response.py create mode 100644 src/cloudflare/types/api_gateway/user_schema_edit_params.py create mode 100644 src/cloudflare/types/api_gateway/user_schema_get_params.py create mode 100644 src/cloudflare/types/api_gateway/user_schema_list_params.py create mode 100644 src/cloudflare/types/api_gateway/user_schemas/__init__.py create mode 100644 src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py create mode 100644 src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py create mode 100644 tests/api_resources/api_gateway/__init__.py create mode 100644 tests/api_resources/api_gateway/discovery/__init__.py create mode 100644 tests/api_resources/api_gateway/discovery/test_operations.py create mode 100644 tests/api_resources/api_gateway/operations/__init__.py create mode 100644 tests/api_resources/api_gateway/operations/test_schema_validation.py create mode 100644 tests/api_resources/api_gateway/settings/__init__.py create mode 100644 tests/api_resources/api_gateway/settings/test_schema_validation.py create mode 100644 tests/api_resources/api_gateway/test_configurations.py create mode 100644 tests/api_resources/api_gateway/test_discovery.py create mode 100644 tests/api_resources/api_gateway/test_operations.py create mode 100644 tests/api_resources/api_gateway/test_schema_validation.py create mode 100644 tests/api_resources/api_gateway/test_schemas.py create mode 100644 tests/api_resources/api_gateway/test_user_schemas.py create mode 100644 tests/api_resources/api_gateway/user_schemas/__init__.py create mode 100644 tests/api_resources/api_gateway/user_schemas/test_operations.py diff --git a/.stats.yml b/.stats.yml index 719796ae247..aaef851a064 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1297 +configured_endpoints: 1319 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5cc7607a4825bf9606463ee28fc976b8498b237c981bcb896211b60b6fe5c146.yml diff --git a/api.md b/api.md index 400b9ec5faa..f96a63ddc67 100644 --- a/api.md +++ b/api.md @@ -2942,6 +2942,146 @@ Methods: - client.queues.messages.ack(queue_id, \*, account_id, \*\*params) -> Optional - client.queues.messages.pull(queue_id, \*, account_id, \*\*params) -> Optional +# APIGateway + +## Configurations + +Types: + +```python +from cloudflare.types.api_gateway import Configuration, ConfigurationUpdateResponse +``` + +Methods: + +- client.api_gateway.configurations.update(\*, zone_id, \*\*params) -> ConfigurationUpdateResponse +- client.api_gateway.configurations.get(\*, zone_id, \*\*params) -> Configuration + +## Discovery + +Types: + +```python +from cloudflare.types.api_gateway import DiscoveryOperation, DiscoveryGetResponse +``` + +Methods: + +- client.api_gateway.discovery.get(\*, zone_id) -> DiscoveryGetResponse + +### Operations + +Types: + +```python +from cloudflare.types.api_gateway.discovery import OperationEditResponse +``` + +Methods: + +- client.api_gateway.discovery.operations.list(\*, zone_id, \*\*params) -> SyncSinglePage[DiscoveryOperation] +- client.api_gateway.discovery.operations.edit(operation_id, \*, zone_id, \*\*params) -> OperationEditResponse + +## Operations + +Types: + +```python +from cloudflare.types.api_gateway import APIShield, OperationCreateResponse, OperationDeleteResponse +``` + +Methods: + +- client.api_gateway.operations.create(\*, zone_id, \*\*params) -> Optional +- client.api_gateway.operations.list(\*, zone_id, \*\*params) -> SyncSinglePage[APIShield] +- client.api_gateway.operations.delete(operation_id, \*, zone_id) -> OperationDeleteResponse +- client.api_gateway.operations.get(operation_id, \*, zone_id, \*\*params) -> APIShield + +### SchemaValidation + +Types: + +```python +from cloudflare.types.api_gateway.operations import ( + SettingsMultipleRequest, + SchemaValidationUpdateResponse, + SchemaValidationGetResponse, +) +``` + +Methods: + +- client.api_gateway.operations.schema_validation.update(operation_id, \*, zone_id, \*\*params) -> SchemaValidationUpdateResponse +- client.api_gateway.operations.schema_validation.edit(\*, zone_id, \*\*params) -> SettingsMultipleRequest +- client.api_gateway.operations.schema_validation.get(operation_id, \*, zone_id) -> SchemaValidationGetResponse + +## Schemas + +Types: + +```python +from cloudflare.types.api_gateway import SchemaListResponse +``` + +Methods: + +- client.api_gateway.schemas.list(\*, zone_id, \*\*params) -> SchemaListResponse + +## Settings + +### SchemaValidation + +Types: + +```python +from cloudflare.types.api_gateway.settings import Settings +``` + +Methods: + +- client.api_gateway.settings.schema_validation.update(\*, zone_id, \*\*params) -> Settings +- client.api_gateway.settings.schema_validation.get(\*, zone_id) -> Settings + +## UserSchemas + +Types: + +```python +from cloudflare.types.api_gateway import ( + Message, + PublicSchema, + Schema, + SchemaUpload, + UserSchemaDeleteResponse, +) +``` + +Methods: + +- client.api_gateway.user_schemas.create(\*, zone_id, \*\*params) -> SchemaUpload +- client.api_gateway.user_schemas.list(\*, zone_id, \*\*params) -> SyncSinglePage[PublicSchema] +- client.api_gateway.user_schemas.delete(schema_id, \*, zone_id) -> UserSchemaDeleteResponse +- client.api_gateway.user_schemas.edit(schema_id, \*, zone_id, \*\*params) -> PublicSchema +- client.api_gateway.user_schemas.get(schema_id, \*, zone_id, \*\*params) -> PublicSchema + +### Operations + +Types: + +```python +from cloudflare.types.api_gateway.user_schemas import OperationListResponse +``` + +Methods: + +- client.api_gateway.user_schemas.operations.list(schema_id, \*, zone_id, \*\*params) -> SyncSinglePage[OperationListResponse] + +## SchemaValidation + +Methods: + +- client.api_gateway.schema_validation.edit(\*, zone_id, \*\*params) -> Settings + # ManagedHeaders Types: diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 529638ece6d..c31dee6829f 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -85,6 +85,7 @@ class Cloudflare(SyncAPIClient): kv: resources.KVResource durable_objects: resources.DurableObjectsResource queues: resources.QueuesResource + api_gateway: resources.APIGatewayResource managed_headers: resources.ManagedHeadersResource page_shield: resources.PageShieldResource rulesets: resources.RulesetsResource @@ -242,6 +243,7 @@ def __init__( self.kv = resources.KVResource(self) self.durable_objects = resources.DurableObjectsResource(self) self.queues = resources.QueuesResource(self) + self.api_gateway = resources.APIGatewayResource(self) self.managed_headers = resources.ManagedHeadersResource(self) self.page_shield = resources.PageShieldResource(self) self.rulesets = resources.RulesetsResource(self) @@ -502,6 +504,7 @@ class AsyncCloudflare(AsyncAPIClient): kv: resources.AsyncKVResource durable_objects: resources.AsyncDurableObjectsResource queues: resources.AsyncQueuesResource + api_gateway: resources.AsyncAPIGatewayResource managed_headers: resources.AsyncManagedHeadersResource page_shield: resources.AsyncPageShieldResource rulesets: resources.AsyncRulesetsResource @@ -659,6 +662,7 @@ def __init__( self.kv = resources.AsyncKVResource(self) self.durable_objects = resources.AsyncDurableObjectsResource(self) self.queues = resources.AsyncQueuesResource(self) + self.api_gateway = resources.AsyncAPIGatewayResource(self) self.managed_headers = resources.AsyncManagedHeadersResource(self) self.page_shield = resources.AsyncPageShieldResource(self) self.rulesets = resources.AsyncRulesetsResource(self) @@ -926,6 +930,7 @@ def __init__(self, client: Cloudflare) -> None: self.kv = resources.KVResourceWithRawResponse(client.kv) self.durable_objects = resources.DurableObjectsResourceWithRawResponse(client.durable_objects) self.queues = resources.QueuesResourceWithRawResponse(client.queues) + self.api_gateway = resources.APIGatewayResourceWithRawResponse(client.api_gateway) self.managed_headers = resources.ManagedHeadersResourceWithRawResponse(client.managed_headers) self.page_shield = resources.PageShieldResourceWithRawResponse(client.page_shield) self.rulesets = resources.RulesetsResourceWithRawResponse(client.rulesets) @@ -1024,6 +1029,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.kv = resources.AsyncKVResourceWithRawResponse(client.kv) self.durable_objects = resources.AsyncDurableObjectsResourceWithRawResponse(client.durable_objects) self.queues = resources.AsyncQueuesResourceWithRawResponse(client.queues) + self.api_gateway = resources.AsyncAPIGatewayResourceWithRawResponse(client.api_gateway) self.managed_headers = resources.AsyncManagedHeadersResourceWithRawResponse(client.managed_headers) self.page_shield = resources.AsyncPageShieldResourceWithRawResponse(client.page_shield) self.rulesets = resources.AsyncRulesetsResourceWithRawResponse(client.rulesets) @@ -1124,6 +1130,7 @@ def __init__(self, client: Cloudflare) -> None: self.kv = resources.KVResourceWithStreamingResponse(client.kv) self.durable_objects = resources.DurableObjectsResourceWithStreamingResponse(client.durable_objects) self.queues = resources.QueuesResourceWithStreamingResponse(client.queues) + self.api_gateway = resources.APIGatewayResourceWithStreamingResponse(client.api_gateway) self.managed_headers = resources.ManagedHeadersResourceWithStreamingResponse(client.managed_headers) self.page_shield = resources.PageShieldResourceWithStreamingResponse(client.page_shield) self.rulesets = resources.RulesetsResourceWithStreamingResponse(client.rulesets) @@ -1230,6 +1237,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.kv = resources.AsyncKVResourceWithStreamingResponse(client.kv) self.durable_objects = resources.AsyncDurableObjectsResourceWithStreamingResponse(client.durable_objects) self.queues = resources.AsyncQueuesResourceWithStreamingResponse(client.queues) + self.api_gateway = resources.AsyncAPIGatewayResourceWithStreamingResponse(client.api_gateway) self.managed_headers = resources.AsyncManagedHeadersResourceWithStreamingResponse(client.managed_headers) self.page_shield = resources.AsyncPageShieldResourceWithStreamingResponse(client.page_shield) self.rulesets = resources.AsyncRulesetsResourceWithStreamingResponse(client.rulesets) diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index 4d7acbc7a4c..5eacc4bdd5c 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -384,6 +384,14 @@ ZeroTrustResourceWithStreamingResponse, AsyncZeroTrustResourceWithStreamingResponse, ) +from .api_gateway import ( + APIGatewayResource, + AsyncAPIGatewayResource, + APIGatewayResourceWithRawResponse, + AsyncAPIGatewayResourceWithRawResponse, + APIGatewayResourceWithStreamingResponse, + AsyncAPIGatewayResourceWithStreamingResponse, +) from .diagnostics import ( DiagnosticsResource, AsyncDiagnosticsResource, @@ -886,6 +894,12 @@ "AsyncQueuesResourceWithRawResponse", "QueuesResourceWithStreamingResponse", "AsyncQueuesResourceWithStreamingResponse", + "APIGatewayResource", + "AsyncAPIGatewayResource", + "APIGatewayResourceWithRawResponse", + "AsyncAPIGatewayResourceWithRawResponse", + "APIGatewayResourceWithStreamingResponse", + "AsyncAPIGatewayResourceWithStreamingResponse", "ManagedHeadersResource", "AsyncManagedHeadersResource", "ManagedHeadersResourceWithRawResponse", diff --git a/src/cloudflare/resources/api_gateway/__init__.py b/src/cloudflare/resources/api_gateway/__init__.py new file mode 100644 index 00000000000..4adb2b18211 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/__init__.py @@ -0,0 +1,117 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .schemas import ( + SchemasResource, + AsyncSchemasResource, + SchemasResourceWithRawResponse, + AsyncSchemasResourceWithRawResponse, + SchemasResourceWithStreamingResponse, + AsyncSchemasResourceWithStreamingResponse, +) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) +from .discovery import ( + DiscoveryResource, + AsyncDiscoveryResource, + DiscoveryResourceWithRawResponse, + AsyncDiscoveryResourceWithRawResponse, + DiscoveryResourceWithStreamingResponse, + AsyncDiscoveryResourceWithStreamingResponse, +) +from .operations import ( + OperationsResource, + AsyncOperationsResource, + OperationsResourceWithRawResponse, + AsyncOperationsResourceWithRawResponse, + OperationsResourceWithStreamingResponse, + AsyncOperationsResourceWithStreamingResponse, +) +from .api_gateway import ( + APIGatewayResource, + AsyncAPIGatewayResource, + APIGatewayResourceWithRawResponse, + AsyncAPIGatewayResourceWithRawResponse, + APIGatewayResourceWithStreamingResponse, + AsyncAPIGatewayResourceWithStreamingResponse, +) +from .user_schemas import ( + UserSchemasResource, + AsyncUserSchemasResource, + UserSchemasResourceWithRawResponse, + AsyncUserSchemasResourceWithRawResponse, + UserSchemasResourceWithStreamingResponse, + AsyncUserSchemasResourceWithStreamingResponse, +) +from .configurations import ( + ConfigurationsResource, + AsyncConfigurationsResource, + ConfigurationsResourceWithRawResponse, + AsyncConfigurationsResourceWithRawResponse, + ConfigurationsResourceWithStreamingResponse, + AsyncConfigurationsResourceWithStreamingResponse, +) +from .schema_validation import ( + SchemaValidationResource, + AsyncSchemaValidationResource, + SchemaValidationResourceWithRawResponse, + AsyncSchemaValidationResourceWithRawResponse, + SchemaValidationResourceWithStreamingResponse, + AsyncSchemaValidationResourceWithStreamingResponse, +) + +__all__ = [ + "ConfigurationsResource", + "AsyncConfigurationsResource", + "ConfigurationsResourceWithRawResponse", + "AsyncConfigurationsResourceWithRawResponse", + "ConfigurationsResourceWithStreamingResponse", + "AsyncConfigurationsResourceWithStreamingResponse", + "DiscoveryResource", + "AsyncDiscoveryResource", + "DiscoveryResourceWithRawResponse", + "AsyncDiscoveryResourceWithRawResponse", + "DiscoveryResourceWithStreamingResponse", + "AsyncDiscoveryResourceWithStreamingResponse", + "OperationsResource", + "AsyncOperationsResource", + "OperationsResourceWithRawResponse", + "AsyncOperationsResourceWithRawResponse", + "OperationsResourceWithStreamingResponse", + "AsyncOperationsResourceWithStreamingResponse", + "SchemasResource", + "AsyncSchemasResource", + "SchemasResourceWithRawResponse", + "AsyncSchemasResourceWithRawResponse", + "SchemasResourceWithStreamingResponse", + "AsyncSchemasResourceWithStreamingResponse", + "SettingsResource", + "AsyncSettingsResource", + "SettingsResourceWithRawResponse", + "AsyncSettingsResourceWithRawResponse", + "SettingsResourceWithStreamingResponse", + "AsyncSettingsResourceWithStreamingResponse", + "UserSchemasResource", + "AsyncUserSchemasResource", + "UserSchemasResourceWithRawResponse", + "AsyncUserSchemasResourceWithRawResponse", + "UserSchemasResourceWithStreamingResponse", + "AsyncUserSchemasResourceWithStreamingResponse", + "SchemaValidationResource", + "AsyncSchemaValidationResource", + "SchemaValidationResourceWithRawResponse", + "AsyncSchemaValidationResourceWithRawResponse", + "SchemaValidationResourceWithStreamingResponse", + "AsyncSchemaValidationResourceWithStreamingResponse", + "APIGatewayResource", + "AsyncAPIGatewayResource", + "APIGatewayResourceWithRawResponse", + "AsyncAPIGatewayResourceWithRawResponse", + "APIGatewayResourceWithStreamingResponse", + "AsyncAPIGatewayResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/api_gateway.py b/src/cloudflare/resources/api_gateway/api_gateway.py new file mode 100644 index 00000000000..baae4ee7e3b --- /dev/null +++ b/src/cloudflare/resources/api_gateway/api_gateway.py @@ -0,0 +1,276 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .schemas import ( + SchemasResource, + AsyncSchemasResource, + SchemasResourceWithRawResponse, + AsyncSchemasResourceWithRawResponse, + SchemasResourceWithStreamingResponse, + AsyncSchemasResourceWithStreamingResponse, +) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) +from ..._compat import cached_property +from .discovery import ( + DiscoveryResource, + AsyncDiscoveryResource, + DiscoveryResourceWithRawResponse, + AsyncDiscoveryResourceWithRawResponse, + DiscoveryResourceWithStreamingResponse, + AsyncDiscoveryResourceWithStreamingResponse, +) +from .operations import ( + OperationsResource, + AsyncOperationsResource, + OperationsResourceWithRawResponse, + AsyncOperationsResourceWithRawResponse, + OperationsResourceWithStreamingResponse, + AsyncOperationsResourceWithStreamingResponse, +) +from ..._resource import SyncAPIResource, AsyncAPIResource +from .user_schemas import ( + UserSchemasResource, + AsyncUserSchemasResource, + UserSchemasResourceWithRawResponse, + AsyncUserSchemasResourceWithRawResponse, + UserSchemasResourceWithStreamingResponse, + AsyncUserSchemasResourceWithStreamingResponse, +) +from .configurations import ( + ConfigurationsResource, + AsyncConfigurationsResource, + ConfigurationsResourceWithRawResponse, + AsyncConfigurationsResourceWithRawResponse, + ConfigurationsResourceWithStreamingResponse, + AsyncConfigurationsResourceWithStreamingResponse, +) +from .schema_validation import ( + SchemaValidationResource, + AsyncSchemaValidationResource, + SchemaValidationResourceWithRawResponse, + AsyncSchemaValidationResourceWithRawResponse, + SchemaValidationResourceWithStreamingResponse, + AsyncSchemaValidationResourceWithStreamingResponse, +) +from .settings.settings import SettingsResource, AsyncSettingsResource +from .discovery.discovery import DiscoveryResource, AsyncDiscoveryResource +from .operations.operations import OperationsResource, AsyncOperationsResource +from .user_schemas.user_schemas import UserSchemasResource, AsyncUserSchemasResource + +__all__ = ["APIGatewayResource", "AsyncAPIGatewayResource"] + + +class APIGatewayResource(SyncAPIResource): + @cached_property + def configurations(self) -> ConfigurationsResource: + return ConfigurationsResource(self._client) + + @cached_property + def discovery(self) -> DiscoveryResource: + return DiscoveryResource(self._client) + + @cached_property + def operations(self) -> OperationsResource: + return OperationsResource(self._client) + + @cached_property + def schemas(self) -> SchemasResource: + return SchemasResource(self._client) + + @cached_property + def settings(self) -> SettingsResource: + return SettingsResource(self._client) + + @cached_property + def user_schemas(self) -> UserSchemasResource: + return UserSchemasResource(self._client) + + @cached_property + def schema_validation(self) -> SchemaValidationResource: + return SchemaValidationResource(self._client) + + @cached_property + def with_raw_response(self) -> APIGatewayResourceWithRawResponse: + return APIGatewayResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> APIGatewayResourceWithStreamingResponse: + return APIGatewayResourceWithStreamingResponse(self) + + +class AsyncAPIGatewayResource(AsyncAPIResource): + @cached_property + def configurations(self) -> AsyncConfigurationsResource: + return AsyncConfigurationsResource(self._client) + + @cached_property + def discovery(self) -> AsyncDiscoveryResource: + return AsyncDiscoveryResource(self._client) + + @cached_property + def operations(self) -> AsyncOperationsResource: + return AsyncOperationsResource(self._client) + + @cached_property + def schemas(self) -> AsyncSchemasResource: + return AsyncSchemasResource(self._client) + + @cached_property + def settings(self) -> AsyncSettingsResource: + return AsyncSettingsResource(self._client) + + @cached_property + def user_schemas(self) -> AsyncUserSchemasResource: + return AsyncUserSchemasResource(self._client) + + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResource: + return AsyncSchemaValidationResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncAPIGatewayResourceWithRawResponse: + return AsyncAPIGatewayResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAPIGatewayResourceWithStreamingResponse: + return AsyncAPIGatewayResourceWithStreamingResponse(self) + + +class APIGatewayResourceWithRawResponse: + def __init__(self, api_gateway: APIGatewayResource) -> None: + self._api_gateway = api_gateway + + @cached_property + def configurations(self) -> ConfigurationsResourceWithRawResponse: + return ConfigurationsResourceWithRawResponse(self._api_gateway.configurations) + + @cached_property + def discovery(self) -> DiscoveryResourceWithRawResponse: + return DiscoveryResourceWithRawResponse(self._api_gateway.discovery) + + @cached_property + def operations(self) -> OperationsResourceWithRawResponse: + return OperationsResourceWithRawResponse(self._api_gateway.operations) + + @cached_property + def schemas(self) -> SchemasResourceWithRawResponse: + return SchemasResourceWithRawResponse(self._api_gateway.schemas) + + @cached_property + def settings(self) -> SettingsResourceWithRawResponse: + return SettingsResourceWithRawResponse(self._api_gateway.settings) + + @cached_property + def user_schemas(self) -> UserSchemasResourceWithRawResponse: + return UserSchemasResourceWithRawResponse(self._api_gateway.user_schemas) + + @cached_property + def schema_validation(self) -> SchemaValidationResourceWithRawResponse: + return SchemaValidationResourceWithRawResponse(self._api_gateway.schema_validation) + + +class AsyncAPIGatewayResourceWithRawResponse: + def __init__(self, api_gateway: AsyncAPIGatewayResource) -> None: + self._api_gateway = api_gateway + + @cached_property + def configurations(self) -> AsyncConfigurationsResourceWithRawResponse: + return AsyncConfigurationsResourceWithRawResponse(self._api_gateway.configurations) + + @cached_property + def discovery(self) -> AsyncDiscoveryResourceWithRawResponse: + return AsyncDiscoveryResourceWithRawResponse(self._api_gateway.discovery) + + @cached_property + def operations(self) -> AsyncOperationsResourceWithRawResponse: + return AsyncOperationsResourceWithRawResponse(self._api_gateway.operations) + + @cached_property + def schemas(self) -> AsyncSchemasResourceWithRawResponse: + return AsyncSchemasResourceWithRawResponse(self._api_gateway.schemas) + + @cached_property + def settings(self) -> AsyncSettingsResourceWithRawResponse: + return AsyncSettingsResourceWithRawResponse(self._api_gateway.settings) + + @cached_property + def user_schemas(self) -> AsyncUserSchemasResourceWithRawResponse: + return AsyncUserSchemasResourceWithRawResponse(self._api_gateway.user_schemas) + + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResourceWithRawResponse: + return AsyncSchemaValidationResourceWithRawResponse(self._api_gateway.schema_validation) + + +class APIGatewayResourceWithStreamingResponse: + def __init__(self, api_gateway: APIGatewayResource) -> None: + self._api_gateway = api_gateway + + @cached_property + def configurations(self) -> ConfigurationsResourceWithStreamingResponse: + return ConfigurationsResourceWithStreamingResponse(self._api_gateway.configurations) + + @cached_property + def discovery(self) -> DiscoveryResourceWithStreamingResponse: + return DiscoveryResourceWithStreamingResponse(self._api_gateway.discovery) + + @cached_property + def operations(self) -> OperationsResourceWithStreamingResponse: + return OperationsResourceWithStreamingResponse(self._api_gateway.operations) + + @cached_property + def schemas(self) -> SchemasResourceWithStreamingResponse: + return SchemasResourceWithStreamingResponse(self._api_gateway.schemas) + + @cached_property + def settings(self) -> SettingsResourceWithStreamingResponse: + return SettingsResourceWithStreamingResponse(self._api_gateway.settings) + + @cached_property + def user_schemas(self) -> UserSchemasResourceWithStreamingResponse: + return UserSchemasResourceWithStreamingResponse(self._api_gateway.user_schemas) + + @cached_property + def schema_validation(self) -> SchemaValidationResourceWithStreamingResponse: + return SchemaValidationResourceWithStreamingResponse(self._api_gateway.schema_validation) + + +class AsyncAPIGatewayResourceWithStreamingResponse: + def __init__(self, api_gateway: AsyncAPIGatewayResource) -> None: + self._api_gateway = api_gateway + + @cached_property + def configurations(self) -> AsyncConfigurationsResourceWithStreamingResponse: + return AsyncConfigurationsResourceWithStreamingResponse(self._api_gateway.configurations) + + @cached_property + def discovery(self) -> AsyncDiscoveryResourceWithStreamingResponse: + return AsyncDiscoveryResourceWithStreamingResponse(self._api_gateway.discovery) + + @cached_property + def operations(self) -> AsyncOperationsResourceWithStreamingResponse: + return AsyncOperationsResourceWithStreamingResponse(self._api_gateway.operations) + + @cached_property + def schemas(self) -> AsyncSchemasResourceWithStreamingResponse: + return AsyncSchemasResourceWithStreamingResponse(self._api_gateway.schemas) + + @cached_property + def settings(self) -> AsyncSettingsResourceWithStreamingResponse: + return AsyncSettingsResourceWithStreamingResponse(self._api_gateway.settings) + + @cached_property + def user_schemas(self) -> AsyncUserSchemasResourceWithStreamingResponse: + return AsyncUserSchemasResourceWithStreamingResponse(self._api_gateway.user_schemas) + + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResourceWithStreamingResponse: + return AsyncSchemaValidationResourceWithStreamingResponse(self._api_gateway.schema_validation) diff --git a/src/cloudflare/resources/api_gateway/configurations.py b/src/cloudflare/resources/api_gateway/configurations.py new file mode 100644 index 00000000000..4e02d4359d6 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/configurations.py @@ -0,0 +1,285 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, List, Type, Iterable, cast +from typing_extensions import Literal + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) +from ...types.api_gateway import configuration_get_params, configuration_update_params +from ...types.api_gateway.configuration import Configuration +from ...types.api_gateway.configuration_update_response import ConfigurationUpdateResponse + +__all__ = ["ConfigurationsResource", "AsyncConfigurationsResource"] + + +class ConfigurationsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ConfigurationsResourceWithRawResponse: + return ConfigurationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ConfigurationsResourceWithStreamingResponse: + return ConfigurationsResourceWithStreamingResponse(self) + + def update( + self, + *, + zone_id: str, + auth_id_characteristics: Iterable[configuration_update_params.AuthIDCharacteristic] | 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, + ) -> ConfigurationUpdateResponse: + """ + Set configuration properties + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return cast( + ConfigurationUpdateResponse, + self._put( + f"/zones/{zone_id}/api_gateway/configuration", + body=maybe_transform( + {"auth_id_characteristics": auth_id_characteristics}, + configuration_update_params.ConfigurationUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ConfigurationUpdateResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[ConfigurationUpdateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + def get( + self, + *, + zone_id: str, + properties: List[Literal["auth_id_characteristics"]] | 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, + ) -> Configuration: + """ + Retrieve information about specific configuration properties + + Args: + zone_id: Identifier + + properties: Requests information about certain properties. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get( + f"/zones/{zone_id}/api_gateway/configuration", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"properties": properties}, configuration_get_params.ConfigurationGetParams), + post_parser=ResultWrapper[Configuration]._unwrapper, + ), + cast_to=cast(Type[Configuration], ResultWrapper[Configuration]), + ) + + +class AsyncConfigurationsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncConfigurationsResourceWithRawResponse: + return AsyncConfigurationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncConfigurationsResourceWithStreamingResponse: + return AsyncConfigurationsResourceWithStreamingResponse(self) + + async def update( + self, + *, + zone_id: str, + auth_id_characteristics: Iterable[configuration_update_params.AuthIDCharacteristic] | 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, + ) -> ConfigurationUpdateResponse: + """ + Set configuration properties + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return cast( + ConfigurationUpdateResponse, + await self._put( + f"/zones/{zone_id}/api_gateway/configuration", + body=await async_maybe_transform( + {"auth_id_characteristics": auth_id_characteristics}, + configuration_update_params.ConfigurationUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ConfigurationUpdateResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[ConfigurationUpdateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + async def get( + self, + *, + zone_id: str, + properties: List[Literal["auth_id_characteristics"]] | 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, + ) -> Configuration: + """ + Retrieve information about specific configuration properties + + Args: + zone_id: Identifier + + properties: Requests information about certain properties. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._get( + f"/zones/{zone_id}/api_gateway/configuration", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"properties": properties}, configuration_get_params.ConfigurationGetParams + ), + post_parser=ResultWrapper[Configuration]._unwrapper, + ), + cast_to=cast(Type[Configuration], ResultWrapper[Configuration]), + ) + + +class ConfigurationsResourceWithRawResponse: + def __init__(self, configurations: ConfigurationsResource) -> None: + self._configurations = configurations + + self.update = to_raw_response_wrapper( + configurations.update, + ) + self.get = to_raw_response_wrapper( + configurations.get, + ) + + +class AsyncConfigurationsResourceWithRawResponse: + def __init__(self, configurations: AsyncConfigurationsResource) -> None: + self._configurations = configurations + + self.update = async_to_raw_response_wrapper( + configurations.update, + ) + self.get = async_to_raw_response_wrapper( + configurations.get, + ) + + +class ConfigurationsResourceWithStreamingResponse: + def __init__(self, configurations: ConfigurationsResource) -> None: + self._configurations = configurations + + self.update = to_streamed_response_wrapper( + configurations.update, + ) + self.get = to_streamed_response_wrapper( + configurations.get, + ) + + +class AsyncConfigurationsResourceWithStreamingResponse: + def __init__(self, configurations: AsyncConfigurationsResource) -> None: + self._configurations = configurations + + self.update = async_to_streamed_response_wrapper( + configurations.update, + ) + self.get = async_to_streamed_response_wrapper( + configurations.get, + ) diff --git a/src/cloudflare/resources/api_gateway/discovery/__init__.py b/src/cloudflare/resources/api_gateway/discovery/__init__.py new file mode 100644 index 00000000000..b126c44ef71 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/discovery/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .discovery import ( + DiscoveryResource, + AsyncDiscoveryResource, + DiscoveryResourceWithRawResponse, + AsyncDiscoveryResourceWithRawResponse, + DiscoveryResourceWithStreamingResponse, + AsyncDiscoveryResourceWithStreamingResponse, +) +from .operations import ( + OperationsResource, + AsyncOperationsResource, + OperationsResourceWithRawResponse, + AsyncOperationsResourceWithRawResponse, + OperationsResourceWithStreamingResponse, + AsyncOperationsResourceWithStreamingResponse, +) + +__all__ = [ + "OperationsResource", + "AsyncOperationsResource", + "OperationsResourceWithRawResponse", + "AsyncOperationsResourceWithRawResponse", + "OperationsResourceWithStreamingResponse", + "AsyncOperationsResourceWithStreamingResponse", + "DiscoveryResource", + "AsyncDiscoveryResource", + "DiscoveryResourceWithRawResponse", + "AsyncDiscoveryResourceWithRawResponse", + "DiscoveryResourceWithStreamingResponse", + "AsyncDiscoveryResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/discovery/discovery.py b/src/cloudflare/resources/api_gateway/discovery/discovery.py new file mode 100644 index 00000000000..f4aed13c07e --- /dev/null +++ b/src/cloudflare/resources/api_gateway/discovery/discovery.py @@ -0,0 +1,192 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._compat import cached_property +from .operations import ( + OperationsResource, + AsyncOperationsResource, + OperationsResourceWithRawResponse, + AsyncOperationsResourceWithRawResponse, + OperationsResourceWithStreamingResponse, + AsyncOperationsResourceWithStreamingResponse, +) +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.api_gateway.discovery_get_response import DiscoveryGetResponse + +__all__ = ["DiscoveryResource", "AsyncDiscoveryResource"] + + +class DiscoveryResource(SyncAPIResource): + @cached_property + def operations(self) -> OperationsResource: + return OperationsResource(self._client) + + @cached_property + def with_raw_response(self) -> DiscoveryResourceWithRawResponse: + return DiscoveryResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DiscoveryResourceWithStreamingResponse: + return DiscoveryResourceWithStreamingResponse(self) + + def get( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DiscoveryGetResponse: + """ + Retrieve the most up to date view of discovered operations, rendered as OpenAPI + schemas + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get( + f"/zones/{zone_id}/api_gateway/discovery", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DiscoveryGetResponse]._unwrapper, + ), + cast_to=cast(Type[DiscoveryGetResponse], ResultWrapper[DiscoveryGetResponse]), + ) + + +class AsyncDiscoveryResource(AsyncAPIResource): + @cached_property + def operations(self) -> AsyncOperationsResource: + return AsyncOperationsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncDiscoveryResourceWithRawResponse: + return AsyncDiscoveryResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDiscoveryResourceWithStreamingResponse: + return AsyncDiscoveryResourceWithStreamingResponse(self) + + async def get( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DiscoveryGetResponse: + """ + Retrieve the most up to date view of discovered operations, rendered as OpenAPI + schemas + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._get( + f"/zones/{zone_id}/api_gateway/discovery", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DiscoveryGetResponse]._unwrapper, + ), + cast_to=cast(Type[DiscoveryGetResponse], ResultWrapper[DiscoveryGetResponse]), + ) + + +class DiscoveryResourceWithRawResponse: + def __init__(self, discovery: DiscoveryResource) -> None: + self._discovery = discovery + + self.get = to_raw_response_wrapper( + discovery.get, + ) + + @cached_property + def operations(self) -> OperationsResourceWithRawResponse: + return OperationsResourceWithRawResponse(self._discovery.operations) + + +class AsyncDiscoveryResourceWithRawResponse: + def __init__(self, discovery: AsyncDiscoveryResource) -> None: + self._discovery = discovery + + self.get = async_to_raw_response_wrapper( + discovery.get, + ) + + @cached_property + def operations(self) -> AsyncOperationsResourceWithRawResponse: + return AsyncOperationsResourceWithRawResponse(self._discovery.operations) + + +class DiscoveryResourceWithStreamingResponse: + def __init__(self, discovery: DiscoveryResource) -> None: + self._discovery = discovery + + self.get = to_streamed_response_wrapper( + discovery.get, + ) + + @cached_property + def operations(self) -> OperationsResourceWithStreamingResponse: + return OperationsResourceWithStreamingResponse(self._discovery.operations) + + +class AsyncDiscoveryResourceWithStreamingResponse: + def __init__(self, discovery: AsyncDiscoveryResource) -> None: + self._discovery = discovery + + self.get = async_to_streamed_response_wrapper( + discovery.get, + ) + + @cached_property + def operations(self) -> AsyncOperationsResourceWithStreamingResponse: + return AsyncOperationsResourceWithStreamingResponse(self._discovery.operations) diff --git a/src/cloudflare/resources/api_gateway/discovery/operations.py b/src/cloudflare/resources/api_gateway/discovery/operations.py new file mode 100644 index 00000000000..d893457fcdb --- /dev/null +++ b/src/cloudflare/resources/api_gateway/discovery/operations.py @@ -0,0 +1,399 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, cast +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.api_gateway.discovery import operation_edit_params, operation_list_params +from ....types.api_gateway.discovery_operation import DiscoveryOperation +from ....types.api_gateway.discovery.operation_edit_response import OperationEditResponse + +__all__ = ["OperationsResource", "AsyncOperationsResource"] + + +class OperationsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OperationsResourceWithRawResponse: + return OperationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OperationsResourceWithStreamingResponse: + return OperationsResourceWithStreamingResponse(self) + + def list( + self, + *, + zone_id: str, + diff: bool | NotGiven = NOT_GIVEN, + direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + endpoint: str | NotGiven = NOT_GIVEN, + host: List[str] | NotGiven = NOT_GIVEN, + method: List[str] | NotGiven = NOT_GIVEN, + order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"] + | NotGiven = NOT_GIVEN, + origin: Literal["ML", "SessionIdentifier"] | NotGiven = NOT_GIVEN, + page: object | NotGiven = NOT_GIVEN, + per_page: object | NotGiven = NOT_GIVEN, + state: Literal["review", "saved", "ignored"] | 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, + ) -> SyncSinglePage[DiscoveryOperation]: + """ + Retrieve the most up to date view of discovered operations + + Args: + zone_id: Identifier + + diff: When `true`, only return API Discovery results that are not saved into API + Shield Endpoint Management + + direction: Direction to order results. + + endpoint: Filter results to only include endpoints containing this pattern. + + host: Filter results to only include the specified hosts. + + method: Filter results to only include the specified HTTP methods. + + order: Field to order by + + origin: Filter results to only include discovery results sourced from a particular + discovery engine + + - `ML` - Discovered operations that were sourced using ML API Discovery + - `SessionIdentifier` - Discovered operations that were sourced using Session + Identifier API Discovery + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + state: Filter results to only include discovery results in a particular state. States + are as follows + + - `review` - Discovered operations that are not saved into API Shield Endpoint + Management + - `saved` - Discovered operations that are already saved into API Shield + Endpoint Management + - `ignored` - Discovered operations that have been marked as ignored + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/discovery/operations", + page=SyncSinglePage[DiscoveryOperation], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "diff": diff, + "direction": direction, + "endpoint": endpoint, + "host": host, + "method": method, + "order": order, + "origin": origin, + "page": page, + "per_page": per_page, + "state": state, + }, + operation_list_params.OperationListParams, + ), + ), + model=DiscoveryOperation, + ) + + def edit( + self, + operation_id: str, + *, + zone_id: str, + state: Literal["review", "ignored"] | 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, + ) -> OperationEditResponse: + """ + Update the `state` on a discovered operation + + Args: + zone_id: Identifier + + operation_id: UUID identifier + + state: Mark state of operation in API Discovery + + - `review` - Mark operation as for review + - `ignored` - Mark operation as ignored + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return self._patch( + f"/zones/{zone_id}/api_gateway/discovery/operations/{operation_id}", + body=maybe_transform({"state": state}, operation_edit_params.OperationEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationEditResponse]._unwrapper, + ), + cast_to=cast(Type[OperationEditResponse], ResultWrapper[OperationEditResponse]), + ) + + +class AsyncOperationsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOperationsResourceWithRawResponse: + return AsyncOperationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOperationsResourceWithStreamingResponse: + return AsyncOperationsResourceWithStreamingResponse(self) + + def list( + self, + *, + zone_id: str, + diff: bool | NotGiven = NOT_GIVEN, + direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + endpoint: str | NotGiven = NOT_GIVEN, + host: List[str] | NotGiven = NOT_GIVEN, + method: List[str] | NotGiven = NOT_GIVEN, + order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"] + | NotGiven = NOT_GIVEN, + origin: Literal["ML", "SessionIdentifier"] | NotGiven = NOT_GIVEN, + page: object | NotGiven = NOT_GIVEN, + per_page: object | NotGiven = NOT_GIVEN, + state: Literal["review", "saved", "ignored"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[DiscoveryOperation, AsyncSinglePage[DiscoveryOperation]]: + """ + Retrieve the most up to date view of discovered operations + + Args: + zone_id: Identifier + + diff: When `true`, only return API Discovery results that are not saved into API + Shield Endpoint Management + + direction: Direction to order results. + + endpoint: Filter results to only include endpoints containing this pattern. + + host: Filter results to only include the specified hosts. + + method: Filter results to only include the specified HTTP methods. + + order: Field to order by + + origin: Filter results to only include discovery results sourced from a particular + discovery engine + + - `ML` - Discovered operations that were sourced using ML API Discovery + - `SessionIdentifier` - Discovered operations that were sourced using Session + Identifier API Discovery + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + state: Filter results to only include discovery results in a particular state. States + are as follows + + - `review` - Discovered operations that are not saved into API Shield Endpoint + Management + - `saved` - Discovered operations that are already saved into API Shield + Endpoint Management + - `ignored` - Discovered operations that have been marked as ignored + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/discovery/operations", + page=AsyncSinglePage[DiscoveryOperation], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "diff": diff, + "direction": direction, + "endpoint": endpoint, + "host": host, + "method": method, + "order": order, + "origin": origin, + "page": page, + "per_page": per_page, + "state": state, + }, + operation_list_params.OperationListParams, + ), + ), + model=DiscoveryOperation, + ) + + async def edit( + self, + operation_id: str, + *, + zone_id: str, + state: Literal["review", "ignored"] | 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, + ) -> OperationEditResponse: + """ + Update the `state` on a discovered operation + + Args: + zone_id: Identifier + + operation_id: UUID identifier + + state: Mark state of operation in API Discovery + + - `review` - Mark operation as for review + - `ignored` - Mark operation as ignored + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return await self._patch( + f"/zones/{zone_id}/api_gateway/discovery/operations/{operation_id}", + body=await async_maybe_transform({"state": state}, operation_edit_params.OperationEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationEditResponse]._unwrapper, + ), + cast_to=cast(Type[OperationEditResponse], ResultWrapper[OperationEditResponse]), + ) + + +class OperationsResourceWithRawResponse: + def __init__(self, operations: OperationsResource) -> None: + self._operations = operations + + self.list = to_raw_response_wrapper( + operations.list, + ) + self.edit = to_raw_response_wrapper( + operations.edit, + ) + + +class AsyncOperationsResourceWithRawResponse: + def __init__(self, operations: AsyncOperationsResource) -> None: + self._operations = operations + + self.list = async_to_raw_response_wrapper( + operations.list, + ) + self.edit = async_to_raw_response_wrapper( + operations.edit, + ) + + +class OperationsResourceWithStreamingResponse: + def __init__(self, operations: OperationsResource) -> None: + self._operations = operations + + self.list = to_streamed_response_wrapper( + operations.list, + ) + self.edit = to_streamed_response_wrapper( + operations.edit, + ) + + +class AsyncOperationsResourceWithStreamingResponse: + def __init__(self, operations: AsyncOperationsResource) -> None: + self._operations = operations + + self.list = async_to_streamed_response_wrapper( + operations.list, + ) + self.edit = async_to_streamed_response_wrapper( + operations.edit, + ) diff --git a/src/cloudflare/resources/api_gateway/operations/__init__.py b/src/cloudflare/resources/api_gateway/operations/__init__.py new file mode 100644 index 00000000000..d50a9df3f11 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/operations/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .operations import ( + OperationsResource, + AsyncOperationsResource, + OperationsResourceWithRawResponse, + AsyncOperationsResourceWithRawResponse, + OperationsResourceWithStreamingResponse, + AsyncOperationsResourceWithStreamingResponse, +) +from .schema_validation import ( + SchemaValidationResource, + AsyncSchemaValidationResource, + SchemaValidationResourceWithRawResponse, + AsyncSchemaValidationResourceWithRawResponse, + SchemaValidationResourceWithStreamingResponse, + AsyncSchemaValidationResourceWithStreamingResponse, +) + +__all__ = [ + "SchemaValidationResource", + "AsyncSchemaValidationResource", + "SchemaValidationResourceWithRawResponse", + "AsyncSchemaValidationResourceWithRawResponse", + "SchemaValidationResourceWithStreamingResponse", + "AsyncSchemaValidationResourceWithStreamingResponse", + "OperationsResource", + "AsyncOperationsResource", + "OperationsResourceWithRawResponse", + "AsyncOperationsResourceWithRawResponse", + "OperationsResourceWithStreamingResponse", + "AsyncOperationsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/operations/operations.py b/src/cloudflare/resources/api_gateway/operations/operations.py new file mode 100644 index 00000000000..90c7b6dd975 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/operations/operations.py @@ -0,0 +1,598 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, List, Type, Iterable, Optional, cast +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from .schema_validation import ( + SchemaValidationResource, + AsyncSchemaValidationResource, + SchemaValidationResourceWithRawResponse, + AsyncSchemaValidationResourceWithRawResponse, + SchemaValidationResourceWithStreamingResponse, + AsyncSchemaValidationResourceWithStreamingResponse, +) +from ....types.api_gateway import operation_get_params, operation_list_params, operation_create_params +from ....types.api_gateway.api_shield import APIShield +from ....types.api_gateway.operation_create_response import OperationCreateResponse +from ....types.api_gateway.operation_delete_response import OperationDeleteResponse + +__all__ = ["OperationsResource", "AsyncOperationsResource"] + + +class OperationsResource(SyncAPIResource): + @cached_property + def schema_validation(self) -> SchemaValidationResource: + return SchemaValidationResource(self._client) + + @cached_property + def with_raw_response(self) -> OperationsResourceWithRawResponse: + return OperationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OperationsResourceWithStreamingResponse: + return OperationsResourceWithStreamingResponse(self) + + def create( + self, + *, + zone_id: str, + body: Iterable[operation_create_params.Body], + # 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[OperationCreateResponse]: + """Add one or more operations to a zone. + + Endpoints can contain path variables. + Host, method, endpoint will be normalized to a canoncial form when creating an + operation and must be unique on the zone. Inserting an operation that matches an + existing one will return the record of the already existing operation and update + its last_updated date. + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._post( + f"/zones/{zone_id}/api_gateway/operations", + body=maybe_transform(body, operation_create_params.OperationCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[OperationCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[OperationCreateResponse]], ResultWrapper[OperationCreateResponse]), + ) + + def list( + self, + *, + zone_id: str, + direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + endpoint: str | NotGiven = NOT_GIVEN, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, + host: List[str] | NotGiven = NOT_GIVEN, + method: List[str] | NotGiven = NOT_GIVEN, + order: Literal["method", "host", "endpoint", "thresholds.$key"] | NotGiven = NOT_GIVEN, + page: object | NotGiven = NOT_GIVEN, + per_page: float | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[APIShield]: + """ + Retrieve information about all operations on a zone + + Args: + zone_id: Identifier + + direction: Direction to order results. + + endpoint: Filter results to only include endpoints containing this pattern. + + feature: Add feature(s) to the results. The feature name that is given here corresponds + to the resulting feature object. Have a look at the top-level object description + for more details on the specific meaning. + + host: Filter results to only include the specified hosts. + + method: Filter results to only include the specified HTTP methods. + + order: Field to order by. When requesting a feature, the feature keys are available for + ordering as well, e.g., `thresholds.suggested_threshold`. + + page: Page number of paginated results. + + per_page: Number of results to return per page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/operations", + page=SyncSinglePage[APIShield], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "endpoint": endpoint, + "feature": feature, + "host": host, + "method": method, + "order": order, + "page": page, + "per_page": per_page, + }, + operation_list_params.OperationListParams, + ), + ), + model=APIShield, + ) + + def delete( + self, + operation_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> OperationDeleteResponse: + """ + Delete an operation + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return cast( + OperationDeleteResponse, + self._delete( + f"/zones/{zone_id}/api_gateway/operations/{operation_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[OperationDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + def get( + self, + operation_id: str, + *, + zone_id: str, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | 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, + ) -> APIShield: + """ + Retrieve information about an operation + + Args: + zone_id: Identifier + + feature: Add feature(s) to the results. The feature name that is given here corresponds + to the resulting feature object. Have a look at the top-level object description + for more details on the specific meaning. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return self._get( + f"/zones/{zone_id}/api_gateway/operations/{operation_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"feature": feature}, operation_get_params.OperationGetParams), + post_parser=ResultWrapper[APIShield]._unwrapper, + ), + cast_to=cast(Type[APIShield], ResultWrapper[APIShield]), + ) + + +class AsyncOperationsResource(AsyncAPIResource): + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResource: + return AsyncSchemaValidationResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncOperationsResourceWithRawResponse: + return AsyncOperationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOperationsResourceWithStreamingResponse: + return AsyncOperationsResourceWithStreamingResponse(self) + + async def create( + self, + *, + zone_id: str, + body: Iterable[operation_create_params.Body], + # 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[OperationCreateResponse]: + """Add one or more operations to a zone. + + Endpoints can contain path variables. + Host, method, endpoint will be normalized to a canoncial form when creating an + operation and must be unique on the zone. Inserting an operation that matches an + existing one will return the record of the already existing operation and update + its last_updated date. + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._post( + f"/zones/{zone_id}/api_gateway/operations", + body=await async_maybe_transform(body, operation_create_params.OperationCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[OperationCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[OperationCreateResponse]], ResultWrapper[OperationCreateResponse]), + ) + + def list( + self, + *, + zone_id: str, + direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + endpoint: str | NotGiven = NOT_GIVEN, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, + host: List[str] | NotGiven = NOT_GIVEN, + method: List[str] | NotGiven = NOT_GIVEN, + order: Literal["method", "host", "endpoint", "thresholds.$key"] | NotGiven = NOT_GIVEN, + page: object | NotGiven = NOT_GIVEN, + per_page: float | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[APIShield, AsyncSinglePage[APIShield]]: + """ + Retrieve information about all operations on a zone + + Args: + zone_id: Identifier + + direction: Direction to order results. + + endpoint: Filter results to only include endpoints containing this pattern. + + feature: Add feature(s) to the results. The feature name that is given here corresponds + to the resulting feature object. Have a look at the top-level object description + for more details on the specific meaning. + + host: Filter results to only include the specified hosts. + + method: Filter results to only include the specified HTTP methods. + + order: Field to order by. When requesting a feature, the feature keys are available for + ordering as well, e.g., `thresholds.suggested_threshold`. + + page: Page number of paginated results. + + per_page: Number of results to return per page + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/operations", + page=AsyncSinglePage[APIShield], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "endpoint": endpoint, + "feature": feature, + "host": host, + "method": method, + "order": order, + "page": page, + "per_page": per_page, + }, + operation_list_params.OperationListParams, + ), + ), + model=APIShield, + ) + + async def delete( + self, + operation_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> OperationDeleteResponse: + """ + Delete an operation + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return cast( + OperationDeleteResponse, + await self._delete( + f"/zones/{zone_id}/api_gateway/operations/{operation_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[OperationDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[OperationDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + async def get( + self, + operation_id: str, + *, + zone_id: str, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | 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, + ) -> APIShield: + """ + Retrieve information about an operation + + Args: + zone_id: Identifier + + feature: Add feature(s) to the results. The feature name that is given here corresponds + to the resulting feature object. Have a look at the top-level object description + for more details on the specific meaning. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return await self._get( + f"/zones/{zone_id}/api_gateway/operations/{operation_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"feature": feature}, operation_get_params.OperationGetParams), + post_parser=ResultWrapper[APIShield]._unwrapper, + ), + cast_to=cast(Type[APIShield], ResultWrapper[APIShield]), + ) + + +class OperationsResourceWithRawResponse: + def __init__(self, operations: OperationsResource) -> None: + self._operations = operations + + self.create = to_raw_response_wrapper( + operations.create, + ) + self.list = to_raw_response_wrapper( + operations.list, + ) + self.delete = to_raw_response_wrapper( + operations.delete, + ) + self.get = to_raw_response_wrapper( + operations.get, + ) + + @cached_property + def schema_validation(self) -> SchemaValidationResourceWithRawResponse: + return SchemaValidationResourceWithRawResponse(self._operations.schema_validation) + + +class AsyncOperationsResourceWithRawResponse: + def __init__(self, operations: AsyncOperationsResource) -> None: + self._operations = operations + + self.create = async_to_raw_response_wrapper( + operations.create, + ) + self.list = async_to_raw_response_wrapper( + operations.list, + ) + self.delete = async_to_raw_response_wrapper( + operations.delete, + ) + self.get = async_to_raw_response_wrapper( + operations.get, + ) + + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResourceWithRawResponse: + return AsyncSchemaValidationResourceWithRawResponse(self._operations.schema_validation) + + +class OperationsResourceWithStreamingResponse: + def __init__(self, operations: OperationsResource) -> None: + self._operations = operations + + self.create = to_streamed_response_wrapper( + operations.create, + ) + self.list = to_streamed_response_wrapper( + operations.list, + ) + self.delete = to_streamed_response_wrapper( + operations.delete, + ) + self.get = to_streamed_response_wrapper( + operations.get, + ) + + @cached_property + def schema_validation(self) -> SchemaValidationResourceWithStreamingResponse: + return SchemaValidationResourceWithStreamingResponse(self._operations.schema_validation) + + +class AsyncOperationsResourceWithStreamingResponse: + def __init__(self, operations: AsyncOperationsResource) -> None: + self._operations = operations + + self.create = async_to_streamed_response_wrapper( + operations.create, + ) + self.list = async_to_streamed_response_wrapper( + operations.list, + ) + self.delete = async_to_streamed_response_wrapper( + operations.delete, + ) + self.get = async_to_streamed_response_wrapper( + operations.get, + ) + + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResourceWithStreamingResponse: + return AsyncSchemaValidationResourceWithStreamingResponse(self._operations.schema_validation) diff --git a/src/cloudflare/resources/api_gateway/operations/schema_validation.py b/src/cloudflare/resources/api_gateway/operations/schema_validation.py new file mode 100644 index 00000000000..b8bd7a0cdcb --- /dev/null +++ b/src/cloudflare/resources/api_gateway/operations/schema_validation.py @@ -0,0 +1,379 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import ( + make_request_options, +) +from ....types.api_gateway.operations import ( + SettingsMultipleRequest, + schema_validation_edit_params, + schema_validation_update_params, +) +from ....types.api_gateway.operations.settings_multiple_request import SettingsMultipleRequest +from ....types.api_gateway.operations.schema_validation_get_response import SchemaValidationGetResponse +from ....types.api_gateway.operations.settings_multiple_request_param import SettingsMultipleRequestParam +from ....types.api_gateway.operations.schema_validation_update_response import SchemaValidationUpdateResponse + +__all__ = ["SchemaValidationResource", "AsyncSchemaValidationResource"] + + +class SchemaValidationResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SchemaValidationResourceWithRawResponse: + return SchemaValidationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SchemaValidationResourceWithStreamingResponse: + return SchemaValidationResourceWithStreamingResponse(self) + + def update( + self, + operation_id: str, + *, + zone_id: str, + mitigation_action: Optional[Literal["log", "block", "none"]] | 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, + ) -> SchemaValidationUpdateResponse: + """ + Updates operation-level schema validation settings on the zone + + Args: + zone_id: Identifier + + mitigation_action: When set, this applies a mitigation action to this operation + + - `log` log request when request does not conform to schema for this operation + - `block` deny access to the site when request does not conform to schema for + this operation + - `none` will skip mitigation for this operation + - `null` indicates that no operation level mitigation is in place, see Zone + Level Schema Validation Settings for mitigation action that will be applied + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return self._put( + f"/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + body=maybe_transform( + {"mitigation_action": mitigation_action}, schema_validation_update_params.SchemaValidationUpdateParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SchemaValidationUpdateResponse, + ) + + def edit( + self, + *, + zone_id: str, + settings_multiple_request: SettingsMultipleRequestParam, + # 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, + ) -> SettingsMultipleRequest: + """ + Updates multiple operation-level schema validation settings on the zone + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._patch( + f"/zones/{zone_id}/api_gateway/operations/schema_validation", + body=maybe_transform(settings_multiple_request, schema_validation_edit_params.SchemaValidationEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SettingsMultipleRequest]._unwrapper, + ), + cast_to=cast(Type[SettingsMultipleRequest], ResultWrapper[SettingsMultipleRequest]), + ) + + def get( + self, + operation_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SchemaValidationGetResponse: + """ + Retrieves operation-level schema validation settings on the zone + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return self._get( + f"/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SchemaValidationGetResponse, + ) + + +class AsyncSchemaValidationResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSchemaValidationResourceWithRawResponse: + return AsyncSchemaValidationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSchemaValidationResourceWithStreamingResponse: + return AsyncSchemaValidationResourceWithStreamingResponse(self) + + async def update( + self, + operation_id: str, + *, + zone_id: str, + mitigation_action: Optional[Literal["log", "block", "none"]] | 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, + ) -> SchemaValidationUpdateResponse: + """ + Updates operation-level schema validation settings on the zone + + Args: + zone_id: Identifier + + mitigation_action: When set, this applies a mitigation action to this operation + + - `log` log request when request does not conform to schema for this operation + - `block` deny access to the site when request does not conform to schema for + this operation + - `none` will skip mitigation for this operation + - `null` indicates that no operation level mitigation is in place, see Zone + Level Schema Validation Settings for mitigation action that will be applied + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return await self._put( + f"/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + body=await async_maybe_transform( + {"mitigation_action": mitigation_action}, schema_validation_update_params.SchemaValidationUpdateParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SchemaValidationUpdateResponse, + ) + + async def edit( + self, + *, + zone_id: str, + settings_multiple_request: SettingsMultipleRequestParam, + # 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, + ) -> SettingsMultipleRequest: + """ + Updates multiple operation-level schema validation settings on the zone + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._patch( + f"/zones/{zone_id}/api_gateway/operations/schema_validation", + body=await async_maybe_transform( + settings_multiple_request, schema_validation_edit_params.SchemaValidationEditParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SettingsMultipleRequest]._unwrapper, + ), + cast_to=cast(Type[SettingsMultipleRequest], ResultWrapper[SettingsMultipleRequest]), + ) + + async def get( + self, + operation_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SchemaValidationGetResponse: + """ + Retrieves operation-level schema validation settings on the zone + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not operation_id: + raise ValueError(f"Expected a non-empty value for `operation_id` but received {operation_id!r}") + return await self._get( + f"/zones/{zone_id}/api_gateway/operations/{operation_id}/schema_validation", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SchemaValidationGetResponse, + ) + + +class SchemaValidationResourceWithRawResponse: + def __init__(self, schema_validation: SchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.update = to_raw_response_wrapper( + schema_validation.update, + ) + self.edit = to_raw_response_wrapper( + schema_validation.edit, + ) + self.get = to_raw_response_wrapper( + schema_validation.get, + ) + + +class AsyncSchemaValidationResourceWithRawResponse: + def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.update = async_to_raw_response_wrapper( + schema_validation.update, + ) + self.edit = async_to_raw_response_wrapper( + schema_validation.edit, + ) + self.get = async_to_raw_response_wrapper( + schema_validation.get, + ) + + +class SchemaValidationResourceWithStreamingResponse: + def __init__(self, schema_validation: SchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.update = to_streamed_response_wrapper( + schema_validation.update, + ) + self.edit = to_streamed_response_wrapper( + schema_validation.edit, + ) + self.get = to_streamed_response_wrapper( + schema_validation.get, + ) + + +class AsyncSchemaValidationResourceWithStreamingResponse: + def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.update = async_to_streamed_response_wrapper( + schema_validation.update, + ) + self.edit = async_to_streamed_response_wrapper( + schema_validation.edit, + ) + self.get = async_to_streamed_response_wrapper( + schema_validation.get, + ) diff --git a/src/cloudflare/resources/api_gateway/schema_validation.py b/src/cloudflare/resources/api_gateway/schema_validation.py new file mode 100644 index 00000000000..e1d210edd73 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/schema_validation.py @@ -0,0 +1,211 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._base_client import ( + make_request_options, +) +from ...types.api_gateway import schema_validation_edit_params +from ...types.api_gateway.settings.settings import Settings + +__all__ = ["SchemaValidationResource", "AsyncSchemaValidationResource"] + + +class SchemaValidationResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SchemaValidationResourceWithRawResponse: + return SchemaValidationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SchemaValidationResourceWithStreamingResponse: + return SchemaValidationResourceWithStreamingResponse(self) + + def edit( + self, + *, + zone_id: str, + validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | NotGiven = NOT_GIVEN, + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | 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, + ) -> Settings: + """ + Updates zone level schema validation settings on the zone + + Args: + zone_id: Identifier + + validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on + the operation Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + + `null` will have no effect. + + validation_override_mitigation_action: When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + + To clear any override, use the special value `disable_override` + + `null` will have no effect. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._patch( + f"/zones/{zone_id}/api_gateway/settings/schema_validation", + body=maybe_transform( + { + "validation_default_mitigation_action": validation_default_mitigation_action, + "validation_override_mitigation_action": validation_override_mitigation_action, + }, + schema_validation_edit_params.SchemaValidationEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Settings, + ) + + +class AsyncSchemaValidationResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSchemaValidationResourceWithRawResponse: + return AsyncSchemaValidationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSchemaValidationResourceWithStreamingResponse: + return AsyncSchemaValidationResourceWithStreamingResponse(self) + + async def edit( + self, + *, + zone_id: str, + validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | NotGiven = NOT_GIVEN, + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | 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, + ) -> Settings: + """ + Updates zone level schema validation settings on the zone + + Args: + zone_id: Identifier + + validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on + the operation Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + + `null` will have no effect. + + validation_override_mitigation_action: When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + + To clear any override, use the special value `disable_override` + + `null` will have no effect. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._patch( + f"/zones/{zone_id}/api_gateway/settings/schema_validation", + body=await async_maybe_transform( + { + "validation_default_mitigation_action": validation_default_mitigation_action, + "validation_override_mitigation_action": validation_override_mitigation_action, + }, + schema_validation_edit_params.SchemaValidationEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Settings, + ) + + +class SchemaValidationResourceWithRawResponse: + def __init__(self, schema_validation: SchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.edit = to_raw_response_wrapper( + schema_validation.edit, + ) + + +class AsyncSchemaValidationResourceWithRawResponse: + def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.edit = async_to_raw_response_wrapper( + schema_validation.edit, + ) + + +class SchemaValidationResourceWithStreamingResponse: + def __init__(self, schema_validation: SchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.edit = to_streamed_response_wrapper( + schema_validation.edit, + ) + + +class AsyncSchemaValidationResourceWithStreamingResponse: + def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.edit = async_to_streamed_response_wrapper( + schema_validation.edit, + ) diff --git a/src/cloudflare/resources/api_gateway/schemas.py b/src/cloudflare/resources/api_gateway/schemas.py new file mode 100644 index 00000000000..d2d1976f847 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/schemas.py @@ -0,0 +1,194 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, cast +from typing_extensions import Literal + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) +from ...types.api_gateway import schema_list_params +from ...types.api_gateway.schema_list_response import SchemaListResponse + +__all__ = ["SchemasResource", "AsyncSchemasResource"] + + +class SchemasResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SchemasResourceWithRawResponse: + return SchemasResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SchemasResourceWithStreamingResponse: + return SchemasResourceWithStreamingResponse(self) + + def list( + self, + *, + zone_id: str, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, + host: List[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, + ) -> SchemaListResponse: + """ + Retrieve operations and features as OpenAPI schemas + + Args: + zone_id: Identifier + + feature: Add feature(s) to the results. The feature name that is given here corresponds + to the resulting feature object. Have a look at the top-level object description + for more details on the specific meaning. + + host: Receive schema only for the given host(s). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get( + f"/zones/{zone_id}/api_gateway/schemas", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "feature": feature, + "host": host, + }, + schema_list_params.SchemaListParams, + ), + post_parser=ResultWrapper[SchemaListResponse]._unwrapper, + ), + cast_to=cast(Type[SchemaListResponse], ResultWrapper[SchemaListResponse]), + ) + + +class AsyncSchemasResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSchemasResourceWithRawResponse: + return AsyncSchemasResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSchemasResourceWithStreamingResponse: + return AsyncSchemasResourceWithStreamingResponse(self) + + async def list( + self, + *, + zone_id: str, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, + host: List[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, + ) -> SchemaListResponse: + """ + Retrieve operations and features as OpenAPI schemas + + Args: + zone_id: Identifier + + feature: Add feature(s) to the results. The feature name that is given here corresponds + to the resulting feature object. Have a look at the top-level object description + for more details on the specific meaning. + + host: Receive schema only for the given host(s). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._get( + f"/zones/{zone_id}/api_gateway/schemas", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "feature": feature, + "host": host, + }, + schema_list_params.SchemaListParams, + ), + post_parser=ResultWrapper[SchemaListResponse]._unwrapper, + ), + cast_to=cast(Type[SchemaListResponse], ResultWrapper[SchemaListResponse]), + ) + + +class SchemasResourceWithRawResponse: + def __init__(self, schemas: SchemasResource) -> None: + self._schemas = schemas + + self.list = to_raw_response_wrapper( + schemas.list, + ) + + +class AsyncSchemasResourceWithRawResponse: + def __init__(self, schemas: AsyncSchemasResource) -> None: + self._schemas = schemas + + self.list = async_to_raw_response_wrapper( + schemas.list, + ) + + +class SchemasResourceWithStreamingResponse: + def __init__(self, schemas: SchemasResource) -> None: + self._schemas = schemas + + self.list = to_streamed_response_wrapper( + schemas.list, + ) + + +class AsyncSchemasResourceWithStreamingResponse: + def __init__(self, schemas: AsyncSchemasResource) -> None: + self._schemas = schemas + + self.list = async_to_streamed_response_wrapper( + schemas.list, + ) diff --git a/src/cloudflare/resources/api_gateway/settings/__init__.py b/src/cloudflare/resources/api_gateway/settings/__init__.py new file mode 100644 index 00000000000..747e388f807 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/settings/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) +from .schema_validation import ( + SchemaValidationResource, + AsyncSchemaValidationResource, + SchemaValidationResourceWithRawResponse, + AsyncSchemaValidationResourceWithRawResponse, + SchemaValidationResourceWithStreamingResponse, + AsyncSchemaValidationResourceWithStreamingResponse, +) + +__all__ = [ + "SchemaValidationResource", + "AsyncSchemaValidationResource", + "SchemaValidationResourceWithRawResponse", + "AsyncSchemaValidationResourceWithRawResponse", + "SchemaValidationResourceWithStreamingResponse", + "AsyncSchemaValidationResourceWithStreamingResponse", + "SettingsResource", + "AsyncSettingsResource", + "SettingsResourceWithRawResponse", + "AsyncSettingsResourceWithRawResponse", + "SettingsResourceWithStreamingResponse", + "AsyncSettingsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/settings/schema_validation.py b/src/cloudflare/resources/api_gateway/settings/schema_validation.py new file mode 100644 index 00000000000..f750f0775b3 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/settings/schema_validation.py @@ -0,0 +1,291 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import ( + make_request_options, +) +from ....types.api_gateway.settings import schema_validation_update_params +from ....types.api_gateway.settings.settings import Settings + +__all__ = ["SchemaValidationResource", "AsyncSchemaValidationResource"] + + +class SchemaValidationResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SchemaValidationResourceWithRawResponse: + return SchemaValidationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SchemaValidationResourceWithStreamingResponse: + return SchemaValidationResourceWithStreamingResponse(self) + + def update( + self, + *, + zone_id: str, + validation_default_mitigation_action: Literal["none", "log", "block"], + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | 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, + ) -> Settings: + """ + Updates zone level schema validation settings on the zone + + Args: + zone_id: Identifier + + validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on + the operation + + Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + + validation_override_mitigation_action: When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + - `null` indicates that no override is in place + + To clear any override, use the special value `disable_override` or `null` + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._put( + f"/zones/{zone_id}/api_gateway/settings/schema_validation", + body=maybe_transform( + { + "validation_default_mitigation_action": validation_default_mitigation_action, + "validation_override_mitigation_action": validation_override_mitigation_action, + }, + schema_validation_update_params.SchemaValidationUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Settings, + ) + + def get( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Settings: + """ + Retrieves zone level schema validation settings currently set on the zone + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get( + f"/zones/{zone_id}/api_gateway/settings/schema_validation", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Settings, + ) + + +class AsyncSchemaValidationResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSchemaValidationResourceWithRawResponse: + return AsyncSchemaValidationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSchemaValidationResourceWithStreamingResponse: + return AsyncSchemaValidationResourceWithStreamingResponse(self) + + async def update( + self, + *, + zone_id: str, + validation_default_mitigation_action: Literal["none", "log", "block"], + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | 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, + ) -> Settings: + """ + Updates zone level schema validation settings on the zone + + Args: + zone_id: Identifier + + validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on + the operation + + Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + + validation_override_mitigation_action: When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + - `null` indicates that no override is in place + + To clear any override, use the special value `disable_override` or `null` + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._put( + f"/zones/{zone_id}/api_gateway/settings/schema_validation", + body=await async_maybe_transform( + { + "validation_default_mitigation_action": validation_default_mitigation_action, + "validation_override_mitigation_action": validation_override_mitigation_action, + }, + schema_validation_update_params.SchemaValidationUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Settings, + ) + + async def get( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Settings: + """ + Retrieves zone level schema validation settings currently set on the zone + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._get( + f"/zones/{zone_id}/api_gateway/settings/schema_validation", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Settings, + ) + + +class SchemaValidationResourceWithRawResponse: + def __init__(self, schema_validation: SchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.update = to_raw_response_wrapper( + schema_validation.update, + ) + self.get = to_raw_response_wrapper( + schema_validation.get, + ) + + +class AsyncSchemaValidationResourceWithRawResponse: + def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.update = async_to_raw_response_wrapper( + schema_validation.update, + ) + self.get = async_to_raw_response_wrapper( + schema_validation.get, + ) + + +class SchemaValidationResourceWithStreamingResponse: + def __init__(self, schema_validation: SchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.update = to_streamed_response_wrapper( + schema_validation.update, + ) + self.get = to_streamed_response_wrapper( + schema_validation.get, + ) + + +class AsyncSchemaValidationResourceWithStreamingResponse: + def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: + self._schema_validation = schema_validation + + self.update = async_to_streamed_response_wrapper( + schema_validation.update, + ) + self.get = async_to_streamed_response_wrapper( + schema_validation.get, + ) diff --git a/src/cloudflare/resources/api_gateway/settings/settings.py b/src/cloudflare/resources/api_gateway/settings/settings.py new file mode 100644 index 00000000000..867736caef9 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/settings/settings.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from .schema_validation import ( + SchemaValidationResource, + AsyncSchemaValidationResource, + SchemaValidationResourceWithRawResponse, + AsyncSchemaValidationResourceWithRawResponse, + SchemaValidationResourceWithStreamingResponse, + AsyncSchemaValidationResourceWithStreamingResponse, +) + +__all__ = ["SettingsResource", "AsyncSettingsResource"] + + +class SettingsResource(SyncAPIResource): + @cached_property + def schema_validation(self) -> SchemaValidationResource: + return SchemaValidationResource(self._client) + + @cached_property + def with_raw_response(self) -> SettingsResourceWithRawResponse: + return SettingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: + return SettingsResourceWithStreamingResponse(self) + + +class AsyncSettingsResource(AsyncAPIResource): + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResource: + return AsyncSchemaValidationResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSettingsResourceWithRawResponse: + return AsyncSettingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: + return AsyncSettingsResourceWithStreamingResponse(self) + + +class SettingsResourceWithRawResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + @cached_property + def schema_validation(self) -> SchemaValidationResourceWithRawResponse: + return SchemaValidationResourceWithRawResponse(self._settings.schema_validation) + + +class AsyncSettingsResourceWithRawResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResourceWithRawResponse: + return AsyncSchemaValidationResourceWithRawResponse(self._settings.schema_validation) + + +class SettingsResourceWithStreamingResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + @cached_property + def schema_validation(self) -> SchemaValidationResourceWithStreamingResponse: + return SchemaValidationResourceWithStreamingResponse(self._settings.schema_validation) + + +class AsyncSettingsResourceWithStreamingResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + @cached_property + def schema_validation(self) -> AsyncSchemaValidationResourceWithStreamingResponse: + return AsyncSchemaValidationResourceWithStreamingResponse(self._settings.schema_validation) diff --git a/src/cloudflare/resources/api_gateway/user_schemas/__init__.py b/src/cloudflare/resources/api_gateway/user_schemas/__init__.py new file mode 100644 index 00000000000..40bf4737372 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/user_schemas/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .operations import ( + OperationsResource, + AsyncOperationsResource, + OperationsResourceWithRawResponse, + AsyncOperationsResourceWithRawResponse, + OperationsResourceWithStreamingResponse, + AsyncOperationsResourceWithStreamingResponse, +) +from .user_schemas import ( + UserSchemasResource, + AsyncUserSchemasResource, + UserSchemasResourceWithRawResponse, + AsyncUserSchemasResourceWithRawResponse, + UserSchemasResourceWithStreamingResponse, + AsyncUserSchemasResourceWithStreamingResponse, +) + +__all__ = [ + "OperationsResource", + "AsyncOperationsResource", + "OperationsResourceWithRawResponse", + "AsyncOperationsResourceWithRawResponse", + "OperationsResourceWithStreamingResponse", + "AsyncOperationsResourceWithStreamingResponse", + "UserSchemasResource", + "AsyncUserSchemasResource", + "UserSchemasResourceWithRawResponse", + "AsyncUserSchemasResourceWithRawResponse", + "UserSchemasResourceWithStreamingResponse", + "AsyncUserSchemasResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/api_gateway/user_schemas/operations.py b/src/cloudflare/resources/api_gateway/user_schemas/operations.py new file mode 100644 index 00000000000..171f80b2aef --- /dev/null +++ b/src/cloudflare/resources/api_gateway/user_schemas/operations.py @@ -0,0 +1,248 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, List, cast +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.api_gateway.user_schemas import operation_list_params +from ....types.api_gateway.user_schemas.operation_list_response import OperationListResponse + +__all__ = ["OperationsResource", "AsyncOperationsResource"] + + +class OperationsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> OperationsResourceWithRawResponse: + return OperationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> OperationsResourceWithStreamingResponse: + return OperationsResourceWithStreamingResponse(self) + + def list( + self, + schema_id: str, + *, + zone_id: str, + endpoint: str | NotGiven = NOT_GIVEN, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, + host: List[str] | NotGiven = NOT_GIVEN, + method: List[str] | NotGiven = NOT_GIVEN, + operation_status: Literal["new", "existing"] | NotGiven = NOT_GIVEN, + page: object | NotGiven = NOT_GIVEN, + per_page: object | 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, + ) -> SyncSinglePage[OperationListResponse]: + """Retrieves all operations from the schema. + + Operations that already exist in API + Shield Endpoint Management will be returned as full operations. + + Args: + zone_id: Identifier + + endpoint: Filter results to only include endpoints containing this pattern. + + feature: Add feature(s) to the results. The feature name that is given here corresponds + to the resulting feature object. Have a look at the top-level object description + for more details on the specific meaning. + + host: Filter results to only include the specified hosts. + + method: Filter results to only include the specified HTTP methods. + + operation_status: Filter results by whether operations exist in API Shield Endpoint Management or + not. `new` will just return operations from the schema that do not exist in API + Shield Endpoint Management. `existing` will just return operations from the + schema that already exist in API Shield Endpoint Management. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not schema_id: + raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations", + page=SyncSinglePage[OperationListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "endpoint": endpoint, + "feature": feature, + "host": host, + "method": method, + "operation_status": operation_status, + "page": page, + "per_page": per_page, + }, + operation_list_params.OperationListParams, + ), + ), + model=cast(Any, OperationListResponse), # Union types cannot be passed in as arguments in the type system + ) + + +class AsyncOperationsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncOperationsResourceWithRawResponse: + return AsyncOperationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncOperationsResourceWithStreamingResponse: + return AsyncOperationsResourceWithStreamingResponse(self) + + def list( + self, + schema_id: str, + *, + zone_id: str, + endpoint: str | NotGiven = NOT_GIVEN, + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] | NotGiven = NOT_GIVEN, + host: List[str] | NotGiven = NOT_GIVEN, + method: List[str] | NotGiven = NOT_GIVEN, + operation_status: Literal["new", "existing"] | NotGiven = NOT_GIVEN, + page: object | NotGiven = NOT_GIVEN, + per_page: object | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[OperationListResponse, AsyncSinglePage[OperationListResponse]]: + """Retrieves all operations from the schema. + + Operations that already exist in API + Shield Endpoint Management will be returned as full operations. + + Args: + zone_id: Identifier + + endpoint: Filter results to only include endpoints containing this pattern. + + feature: Add feature(s) to the results. The feature name that is given here corresponds + to the resulting feature object. Have a look at the top-level object description + for more details on the specific meaning. + + host: Filter results to only include the specified hosts. + + method: Filter results to only include the specified HTTP methods. + + operation_status: Filter results by whether operations exist in API Shield Endpoint Management or + not. `new` will just return operations from the schema that do not exist in API + Shield Endpoint Management. `existing` will just return operations from the + schema that already exist in API Shield Endpoint Management. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not schema_id: + raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}/operations", + page=AsyncSinglePage[OperationListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "endpoint": endpoint, + "feature": feature, + "host": host, + "method": method, + "operation_status": operation_status, + "page": page, + "per_page": per_page, + }, + operation_list_params.OperationListParams, + ), + ), + model=cast(Any, OperationListResponse), # Union types cannot be passed in as arguments in the type system + ) + + +class OperationsResourceWithRawResponse: + def __init__(self, operations: OperationsResource) -> None: + self._operations = operations + + self.list = to_raw_response_wrapper( + operations.list, + ) + + +class AsyncOperationsResourceWithRawResponse: + def __init__(self, operations: AsyncOperationsResource) -> None: + self._operations = operations + + self.list = async_to_raw_response_wrapper( + operations.list, + ) + + +class OperationsResourceWithStreamingResponse: + def __init__(self, operations: OperationsResource) -> None: + self._operations = operations + + self.list = to_streamed_response_wrapper( + operations.list, + ) + + +class AsyncOperationsResourceWithStreamingResponse: + def __init__(self, operations: AsyncOperationsResource) -> None: + self._operations = operations + + self.list = async_to_streamed_response_wrapper( + operations.list, + ) diff --git a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py new file mode 100644 index 00000000000..25fc670bd03 --- /dev/null +++ b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py @@ -0,0 +1,715 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, Type, Mapping, cast +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes +from ...._utils import ( + extract_files, + maybe_transform, + deepcopy_minimal, + async_maybe_transform, +) +from ...._compat import cached_property +from .operations import ( + OperationsResource, + AsyncOperationsResource, + OperationsResourceWithRawResponse, + AsyncOperationsResourceWithRawResponse, + OperationsResourceWithStreamingResponse, + AsyncOperationsResourceWithStreamingResponse, +) +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.api_gateway import ( + user_schema_get_params, + user_schema_edit_params, + user_schema_list_params, + user_schema_create_params, +) +from ....types.api_gateway.public_schema import PublicSchema +from ....types.api_gateway.schema_upload import SchemaUpload +from ....types.api_gateway.user_schema_delete_response import UserSchemaDeleteResponse + +__all__ = ["UserSchemasResource", "AsyncUserSchemasResource"] + + +class UserSchemasResource(SyncAPIResource): + @cached_property + def operations(self) -> OperationsResource: + return OperationsResource(self._client) + + @cached_property + def with_raw_response(self) -> UserSchemasResourceWithRawResponse: + return UserSchemasResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> UserSchemasResourceWithStreamingResponse: + return UserSchemasResourceWithStreamingResponse(self) + + def create( + self, + *, + zone_id: str, + file: FileTypes, + kind: Literal["openapi_v3"], + name: str | NotGiven = NOT_GIVEN, + validation_enabled: Literal["true", "false"] | 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, + ) -> SchemaUpload: + """ + Upload a schema to a zone + + Args: + zone_id: Identifier + + file: Schema file bytes + + kind: Kind of schema + + name: Name of the schema + + validation_enabled: Flag whether schema is enabled for validation. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + body = deepcopy_minimal( + { + "file": file, + "kind": kind, + "name": name, + "validation_enabled": validation_enabled, + } + ) + files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) + if files: + # It should be noted that the actual Content-Type header that will be + # sent to the server will contain a `boundary` parameter, e.g. + # multipart/form-data; boundary=---abc-- + extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} + return self._post( + f"/zones/{zone_id}/api_gateway/user_schemas", + body=maybe_transform(body, user_schema_create_params.UserSchemaCreateParams), + files=files, + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SchemaUpload]._unwrapper, + ), + cast_to=cast(Type[SchemaUpload], ResultWrapper[SchemaUpload]), + ) + + def list( + self, + *, + zone_id: str, + omit_source: bool | NotGiven = NOT_GIVEN, + page: object | NotGiven = NOT_GIVEN, + per_page: object | NotGiven = NOT_GIVEN, + validation_enabled: bool | 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, + ) -> SyncSinglePage[PublicSchema]: + """ + Retrieve information about all schemas on a zone + + Args: + zone_id: Identifier + + omit_source: Omit the source-files of schemas and only retrieve their meta-data. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + validation_enabled: Flag whether schema is enabled for validation. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/user_schemas", + page=SyncSinglePage[PublicSchema], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "omit_source": omit_source, + "page": page, + "per_page": per_page, + "validation_enabled": validation_enabled, + }, + user_schema_list_params.UserSchemaListParams, + ), + ), + model=PublicSchema, + ) + + def delete( + self, + schema_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> UserSchemaDeleteResponse: + """ + Delete a schema + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not schema_id: + raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") + return cast( + UserSchemaDeleteResponse, + self._delete( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[UserSchemaDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[UserSchemaDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + def edit( + self, + schema_id: str, + *, + zone_id: str, + validation_enabled: Literal[True] | 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, + ) -> PublicSchema: + """ + Enable validation for a schema + + Args: + zone_id: Identifier + + validation_enabled: Flag whether schema is enabled for validation. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not schema_id: + raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") + return self._patch( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + body=maybe_transform( + {"validation_enabled": validation_enabled}, user_schema_edit_params.UserSchemaEditParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PublicSchema]._unwrapper, + ), + cast_to=cast(Type[PublicSchema], ResultWrapper[PublicSchema]), + ) + + def get( + self, + schema_id: str, + *, + zone_id: str, + omit_source: bool | 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, + ) -> PublicSchema: + """ + Retrieve information about a specific schema on a zone + + Args: + zone_id: Identifier + + omit_source: Omit the source-files of schemas and only retrieve their meta-data. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not schema_id: + raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") + return self._get( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"omit_source": omit_source}, user_schema_get_params.UserSchemaGetParams), + post_parser=ResultWrapper[PublicSchema]._unwrapper, + ), + cast_to=cast(Type[PublicSchema], ResultWrapper[PublicSchema]), + ) + + +class AsyncUserSchemasResource(AsyncAPIResource): + @cached_property + def operations(self) -> AsyncOperationsResource: + return AsyncOperationsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncUserSchemasResourceWithRawResponse: + return AsyncUserSchemasResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncUserSchemasResourceWithStreamingResponse: + return AsyncUserSchemasResourceWithStreamingResponse(self) + + async def create( + self, + *, + zone_id: str, + file: FileTypes, + kind: Literal["openapi_v3"], + name: str | NotGiven = NOT_GIVEN, + validation_enabled: Literal["true", "false"] | 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, + ) -> SchemaUpload: + """ + Upload a schema to a zone + + Args: + zone_id: Identifier + + file: Schema file bytes + + kind: Kind of schema + + name: Name of the schema + + validation_enabled: Flag whether schema is enabled for validation. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + body = deepcopy_minimal( + { + "file": file, + "kind": kind, + "name": name, + "validation_enabled": validation_enabled, + } + ) + files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) + if files: + # It should be noted that the actual Content-Type header that will be + # sent to the server will contain a `boundary` parameter, e.g. + # multipart/form-data; boundary=---abc-- + extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} + return await self._post( + f"/zones/{zone_id}/api_gateway/user_schemas", + body=await async_maybe_transform(body, user_schema_create_params.UserSchemaCreateParams), + files=files, + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[SchemaUpload]._unwrapper, + ), + cast_to=cast(Type[SchemaUpload], ResultWrapper[SchemaUpload]), + ) + + def list( + self, + *, + zone_id: str, + omit_source: bool | NotGiven = NOT_GIVEN, + page: object | NotGiven = NOT_GIVEN, + per_page: object | NotGiven = NOT_GIVEN, + validation_enabled: bool | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[PublicSchema, AsyncSinglePage[PublicSchema]]: + """ + Retrieve information about all schemas on a zone + + Args: + zone_id: Identifier + + omit_source: Omit the source-files of schemas and only retrieve their meta-data. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + validation_enabled: Flag whether schema is enabled for validation. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/api_gateway/user_schemas", + page=AsyncSinglePage[PublicSchema], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "omit_source": omit_source, + "page": page, + "per_page": per_page, + "validation_enabled": validation_enabled, + }, + user_schema_list_params.UserSchemaListParams, + ), + ), + model=PublicSchema, + ) + + async def delete( + self, + schema_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> UserSchemaDeleteResponse: + """ + Delete a schema + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not schema_id: + raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") + return cast( + UserSchemaDeleteResponse, + await self._delete( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[UserSchemaDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[UserSchemaDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + async def edit( + self, + schema_id: str, + *, + zone_id: str, + validation_enabled: Literal[True] | 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, + ) -> PublicSchema: + """ + Enable validation for a schema + + Args: + zone_id: Identifier + + validation_enabled: Flag whether schema is enabled for validation. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not schema_id: + raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") + return await self._patch( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + body=await async_maybe_transform( + {"validation_enabled": validation_enabled}, user_schema_edit_params.UserSchemaEditParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PublicSchema]._unwrapper, + ), + cast_to=cast(Type[PublicSchema], ResultWrapper[PublicSchema]), + ) + + async def get( + self, + schema_id: str, + *, + zone_id: str, + omit_source: bool | 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, + ) -> PublicSchema: + """ + Retrieve information about a specific schema on a zone + + Args: + zone_id: Identifier + + omit_source: Omit the source-files of schemas and only retrieve their meta-data. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not schema_id: + raise ValueError(f"Expected a non-empty value for `schema_id` but received {schema_id!r}") + return await self._get( + f"/zones/{zone_id}/api_gateway/user_schemas/{schema_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"omit_source": omit_source}, user_schema_get_params.UserSchemaGetParams + ), + post_parser=ResultWrapper[PublicSchema]._unwrapper, + ), + cast_to=cast(Type[PublicSchema], ResultWrapper[PublicSchema]), + ) + + +class UserSchemasResourceWithRawResponse: + def __init__(self, user_schemas: UserSchemasResource) -> None: + self._user_schemas = user_schemas + + self.create = to_raw_response_wrapper( + user_schemas.create, + ) + self.list = to_raw_response_wrapper( + user_schemas.list, + ) + self.delete = to_raw_response_wrapper( + user_schemas.delete, + ) + self.edit = to_raw_response_wrapper( + user_schemas.edit, + ) + self.get = to_raw_response_wrapper( + user_schemas.get, + ) + + @cached_property + def operations(self) -> OperationsResourceWithRawResponse: + return OperationsResourceWithRawResponse(self._user_schemas.operations) + + +class AsyncUserSchemasResourceWithRawResponse: + def __init__(self, user_schemas: AsyncUserSchemasResource) -> None: + self._user_schemas = user_schemas + + self.create = async_to_raw_response_wrapper( + user_schemas.create, + ) + self.list = async_to_raw_response_wrapper( + user_schemas.list, + ) + self.delete = async_to_raw_response_wrapper( + user_schemas.delete, + ) + self.edit = async_to_raw_response_wrapper( + user_schemas.edit, + ) + self.get = async_to_raw_response_wrapper( + user_schemas.get, + ) + + @cached_property + def operations(self) -> AsyncOperationsResourceWithRawResponse: + return AsyncOperationsResourceWithRawResponse(self._user_schemas.operations) + + +class UserSchemasResourceWithStreamingResponse: + def __init__(self, user_schemas: UserSchemasResource) -> None: + self._user_schemas = user_schemas + + self.create = to_streamed_response_wrapper( + user_schemas.create, + ) + self.list = to_streamed_response_wrapper( + user_schemas.list, + ) + self.delete = to_streamed_response_wrapper( + user_schemas.delete, + ) + self.edit = to_streamed_response_wrapper( + user_schemas.edit, + ) + self.get = to_streamed_response_wrapper( + user_schemas.get, + ) + + @cached_property + def operations(self) -> OperationsResourceWithStreamingResponse: + return OperationsResourceWithStreamingResponse(self._user_schemas.operations) + + +class AsyncUserSchemasResourceWithStreamingResponse: + def __init__(self, user_schemas: AsyncUserSchemasResource) -> None: + self._user_schemas = user_schemas + + self.create = async_to_streamed_response_wrapper( + user_schemas.create, + ) + self.list = async_to_streamed_response_wrapper( + user_schemas.list, + ) + self.delete = async_to_streamed_response_wrapper( + user_schemas.delete, + ) + self.edit = async_to_streamed_response_wrapper( + user_schemas.edit, + ) + self.get = async_to_streamed_response_wrapper( + user_schemas.get, + ) + + @cached_property + def operations(self) -> AsyncOperationsResourceWithStreamingResponse: + return AsyncOperationsResourceWithStreamingResponse(self._user_schemas.operations) diff --git a/src/cloudflare/types/api_gateway/__init__.py b/src/cloudflare/types/api_gateway/__init__.py new file mode 100644 index 00000000000..9b7ba5574de --- /dev/null +++ b/src/cloudflare/types/api_gateway/__init__.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .schema import Schema as Schema +from .message import Message as Message +from .api_shield import APIShield as APIShield +from .configuration import Configuration as Configuration +from .public_schema import PublicSchema as PublicSchema +from .schema_upload import SchemaUpload as SchemaUpload +from .schema_list_params import SchemaListParams as SchemaListParams +from .discovery_operation import DiscoveryOperation as DiscoveryOperation +from .operation_get_params import OperationGetParams as OperationGetParams +from .schema_list_response import SchemaListResponse as SchemaListResponse +from .operation_list_params import OperationListParams as OperationListParams +from .discovery_get_response import DiscoveryGetResponse as DiscoveryGetResponse +from .user_schema_get_params import UserSchemaGetParams as UserSchemaGetParams +from .operation_create_params import OperationCreateParams as OperationCreateParams +from .user_schema_edit_params import UserSchemaEditParams as UserSchemaEditParams +from .user_schema_list_params import UserSchemaListParams as UserSchemaListParams +from .configuration_get_params import ConfigurationGetParams as ConfigurationGetParams +from .operation_create_response import OperationCreateResponse as OperationCreateResponse +from .operation_delete_response import OperationDeleteResponse as OperationDeleteResponse +from .user_schema_create_params import UserSchemaCreateParams as UserSchemaCreateParams +from .configuration_update_params import ConfigurationUpdateParams as ConfigurationUpdateParams +from .user_schema_delete_response import UserSchemaDeleteResponse as UserSchemaDeleteResponse +from .configuration_update_response import ConfigurationUpdateResponse as ConfigurationUpdateResponse +from .schema_validation_edit_params import SchemaValidationEditParams as SchemaValidationEditParams diff --git a/src/cloudflare/types/api_gateway/api_shield.py b/src/cloudflare/types/api_gateway/api_shield.py new file mode 100644 index 00000000000..5bb350083c2 --- /dev/null +++ b/src/cloudflare/types/api_gateway/api_shield.py @@ -0,0 +1,99 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = [ + "APIShield", + "Features", + "FeaturesAPIShieldOperationFeatureThresholds", + "FeaturesAPIShieldOperationFeatureThresholdsThresholds", + "FeaturesAPIShieldOperationFeatureParameterSchemas", + "FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas", + "FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas", +] + + +class FeaturesAPIShieldOperationFeatureThresholdsThresholds(BaseModel): + auth_id_tokens: Optional[int] = None + """The total number of auth-ids seen across this calculation.""" + + data_points: Optional[int] = None + """The number of data points used for the threshold suggestion calculation.""" + + last_updated: Optional[datetime] = None + + p50: Optional[int] = None + """The p50 quantile of requests (in period_seconds).""" + + p90: Optional[int] = None + """The p90 quantile of requests (in period_seconds).""" + + p99: Optional[int] = None + """The p99 quantile of requests (in period_seconds).""" + + period_seconds: Optional[int] = None + """The period over which this threshold is suggested.""" + + requests: Optional[int] = None + """The estimated number of requests covered by these calculations.""" + + suggested_threshold: Optional[int] = None + """The suggested threshold in requests done by the same auth_id or period_seconds.""" + + +class FeaturesAPIShieldOperationFeatureThresholds(BaseModel): + thresholds: Optional[FeaturesAPIShieldOperationFeatureThresholdsThresholds] = None + + +class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas(BaseModel): + parameters: Optional[List[object]] = None + """An array containing the learned parameter schemas.""" + + responses: Optional[object] = None + """An empty response object. + + This field is required to yield a valid operation schema. + """ + + +class FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas(BaseModel): + last_updated: Optional[datetime] = None + + parameter_schemas: Optional[ + FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemasParameterSchemas + ] = None + """An operation schema object containing a response.""" + + +class FeaturesAPIShieldOperationFeatureParameterSchemas(BaseModel): + parameter_schemas: FeaturesAPIShieldOperationFeatureParameterSchemasParameterSchemas + + +Features = Union[FeaturesAPIShieldOperationFeatureThresholds, FeaturesAPIShieldOperationFeatureParameterSchemas] + + +class APIShield(BaseModel): + endpoint: str + """ + The endpoint which can contain path parameter templates in curly braces, each + will be replaced from left to right with {varN}, starting with {var1}, during + insertion. This will further be Cloudflare-normalized upon insertion. See: + https://developers.cloudflare.com/rules/normalization/how-it-works/. + """ + + host: str + """RFC3986-compliant host.""" + + last_updated: datetime + + method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"] + """The HTTP method used to access the endpoint.""" + + operation_id: str + """UUID identifier""" + + features: Optional[Features] = None diff --git a/src/cloudflare/types/api_gateway/configuration.py b/src/cloudflare/types/api_gateway/configuration.py new file mode 100644 index 00000000000..855946241b2 --- /dev/null +++ b/src/cloudflare/types/api_gateway/configuration.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = [ + "Configuration", + "AuthIDCharacteristic", + "AuthIDCharacteristicAPIShieldAuthIDCharacteristic", + "AuthIDCharacteristicAPIShieldAuthIDCharacteristicJwtClaim", +] + + +class AuthIDCharacteristicAPIShieldAuthIDCharacteristic(BaseModel): + name: str + """The name of the characteristic field, i.e., the header or cookie name.""" + + type: Literal["header", "cookie"] + """The type of characteristic.""" + + +class AuthIDCharacteristicAPIShieldAuthIDCharacteristicJwtClaim(BaseModel): + name: str + """ + Claim location expressed as `$(token_config_id):$(json_path)`, where + `token_config_id` is the ID of the token configuration used in validating the + JWT, and `json_path` is a RFC 9535 JSONPath + (https://goessner.net/articles/JsonPath/, + https://www.rfc-editor.org/rfc/rfc9535.html). The JSONPath expression may be in + dot or bracket notation, may only specify literal keys or array indexes, and + must return a singleton value, which will be interpreted as a string. + """ + + type: Literal["jwt"] + """The type of characteristic.""" + + +AuthIDCharacteristic = Union[ + AuthIDCharacteristicAPIShieldAuthIDCharacteristic, AuthIDCharacteristicAPIShieldAuthIDCharacteristicJwtClaim +] + + +class Configuration(BaseModel): + auth_id_characteristics: Optional[List[AuthIDCharacteristic]] = None diff --git a/src/cloudflare/types/api_gateway/configuration_get_params.py b/src/cloudflare/types/api_gateway/configuration_get_params.py new file mode 100644 index 00000000000..c1be0a862e8 --- /dev/null +++ b/src/cloudflare/types/api_gateway/configuration_get_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 List +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ConfigurationGetParams"] + + +class ConfigurationGetParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + properties: List[Literal["auth_id_characteristics"]] + """Requests information about certain properties.""" diff --git a/src/cloudflare/types/api_gateway/configuration_update_params.py b/src/cloudflare/types/api_gateway/configuration_update_params.py new file mode 100644 index 00000000000..52c7aff9ed0 --- /dev/null +++ b/src/cloudflare/types/api_gateway/configuration_update_params.py @@ -0,0 +1,49 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Literal, Required, TypedDict + +__all__ = [ + "ConfigurationUpdateParams", + "AuthIDCharacteristic", + "AuthIDCharacteristicAPIShieldAuthIDCharacteristic", + "AuthIDCharacteristicAPIShieldAuthIDCharacteristicJwtClaim", +] + + +class ConfigurationUpdateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + auth_id_characteristics: Iterable[AuthIDCharacteristic] + + +class AuthIDCharacteristicAPIShieldAuthIDCharacteristic(TypedDict, total=False): + name: Required[str] + """The name of the characteristic field, i.e., the header or cookie name.""" + + type: Required[Literal["header", "cookie"]] + """The type of characteristic.""" + + +class AuthIDCharacteristicAPIShieldAuthIDCharacteristicJwtClaim(TypedDict, total=False): + name: Required[str] + """ + Claim location expressed as `$(token_config_id):$(json_path)`, where + `token_config_id` is the ID of the token configuration used in validating the + JWT, and `json_path` is a RFC 9535 JSONPath + (https://goessner.net/articles/JsonPath/, + https://www.rfc-editor.org/rfc/rfc9535.html). The JSONPath expression may be in + dot or bracket notation, may only specify literal keys or array indexes, and + must return a singleton value, which will be interpreted as a string. + """ + + type: Required[Literal["jwt"]] + """The type of characteristic.""" + + +AuthIDCharacteristic = Union[ + AuthIDCharacteristicAPIShieldAuthIDCharacteristic, AuthIDCharacteristicAPIShieldAuthIDCharacteristicJwtClaim +] diff --git a/src/cloudflare/types/api_gateway/configuration_update_response.py b/src/cloudflare/types/api_gateway/configuration_update_response.py new file mode 100644 index 00000000000..efe6f827dda --- /dev/null +++ b/src/cloudflare/types/api_gateway/configuration_update_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +__all__ = ["ConfigurationUpdateResponse"] + +ConfigurationUpdateResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/api_gateway/discovery/__init__.py b/src/cloudflare/types/api_gateway/discovery/__init__.py new file mode 100644 index 00000000000..91d80c2cedc --- /dev/null +++ b/src/cloudflare/types/api_gateway/discovery/__init__.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .operation_edit_params import OperationEditParams as OperationEditParams +from .operation_list_params import OperationListParams as OperationListParams +from .operation_edit_response import OperationEditResponse as OperationEditResponse diff --git a/src/cloudflare/types/api_gateway/discovery/operation_edit_params.py b/src/cloudflare/types/api_gateway/discovery/operation_edit_params.py new file mode 100644 index 00000000000..903d84d39fc --- /dev/null +++ b/src/cloudflare/types/api_gateway/discovery/operation_edit_params.py @@ -0,0 +1,19 @@ +# 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__ = ["OperationEditParams"] + + +class OperationEditParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + state: Literal["review", "ignored"] + """Mark state of operation in API Discovery + + - `review` - Mark operation as for review + - `ignored` - Mark operation as ignored + """ diff --git a/src/cloudflare/types/api_gateway/discovery/operation_edit_response.py b/src/cloudflare/types/api_gateway/discovery/operation_edit_response.py new file mode 100644 index 00000000000..ff7f58a5efc --- /dev/null +++ b/src/cloudflare/types/api_gateway/discovery/operation_edit_response.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["OperationEditResponse"] + + +class OperationEditResponse(BaseModel): + state: Optional[Literal["review", "saved", "ignored"]] = None + """State of operation in API Discovery + + - `review` - Operation is not saved into API Shield Endpoint Management + - `saved` - Operation is saved into API Shield Endpoint Management + - `ignored` - Operation is marked as ignored + """ diff --git a/src/cloudflare/types/api_gateway/discovery/operation_list_params.py b/src/cloudflare/types/api_gateway/discovery/operation_list_params.py new file mode 100644 index 00000000000..978fee2d4bb --- /dev/null +++ b/src/cloudflare/types/api_gateway/discovery/operation_list_params.py @@ -0,0 +1,62 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["OperationListParams"] + + +class OperationListParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + diff: bool + """ + When `true`, only return API Discovery results that are not saved into API + Shield Endpoint Management + """ + + direction: Literal["asc", "desc"] + """Direction to order results.""" + + endpoint: str + """Filter results to only include endpoints containing this pattern.""" + + host: List[str] + """Filter results to only include the specified hosts.""" + + method: List[str] + """Filter results to only include the specified HTTP methods.""" + + order: Literal["host", "method", "endpoint", "traffic_stats.requests", "traffic_stats.last_updated"] + """Field to order by""" + + origin: Literal["ML", "SessionIdentifier"] + """ + Filter results to only include discovery results sourced from a particular + discovery engine + + - `ML` - Discovered operations that were sourced using ML API Discovery + - `SessionIdentifier` - Discovered operations that were sourced using Session + Identifier API Discovery + """ + + page: object + """Page number of paginated results.""" + + per_page: object + """Maximum number of results per page.""" + + state: Literal["review", "saved", "ignored"] + """Filter results to only include discovery results in a particular state. + + States are as follows + + - `review` - Discovered operations that are not saved into API Shield Endpoint + Management + - `saved` - Discovered operations that are already saved into API Shield + Endpoint Management + - `ignored` - Discovered operations that have been marked as ignored + """ diff --git a/src/cloudflare/types/api_gateway/discovery_get_response.py b/src/cloudflare/types/api_gateway/discovery_get_response.py new file mode 100644 index 00000000000..ac55c572760 --- /dev/null +++ b/src/cloudflare/types/api_gateway/discovery_get_response.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["DiscoveryGetResponse"] + + +class DiscoveryGetResponse(BaseModel): + schemas: Optional[List[object]] = None + + timestamp: Optional[datetime] = None diff --git a/src/cloudflare/types/api_gateway/discovery_operation.py b/src/cloudflare/types/api_gateway/discovery_operation.py new file mode 100644 index 00000000000..bf9570a9176 --- /dev/null +++ b/src/cloudflare/types/api_gateway/discovery_operation.py @@ -0,0 +1,57 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["DiscoveryOperation", "Features", "FeaturesTrafficStats"] + + +class FeaturesTrafficStats(BaseModel): + last_updated: datetime + + period_seconds: int + """The period in seconds these statistics were computed over""" + + requests: float + """The average number of requests seen during this period""" + + +class Features(BaseModel): + traffic_stats: Optional[FeaturesTrafficStats] = None + + +class DiscoveryOperation(BaseModel): + id: str + """UUID identifier""" + + endpoint: str + """ + The endpoint which can contain path parameter templates in curly braces, each + will be replaced from left to right with {varN}, starting with {var1}, during + insertion. This will further be Cloudflare-normalized upon insertion. See: + https://developers.cloudflare.com/rules/normalization/how-it-works/. + """ + + host: str + """RFC3986-compliant host.""" + + last_updated: datetime + + method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"] + """The HTTP method used to access the endpoint.""" + + origin: List[Literal["ML", "SessionIdentifier"]] + """API discovery engine(s) that discovered this operation""" + + state: Literal["review", "saved", "ignored"] + """State of operation in API Discovery + + - `review` - Operation is not saved into API Shield Endpoint Management + - `saved` - Operation is saved into API Shield Endpoint Management + - `ignored` - Operation is marked as ignored + """ + + features: Optional[Features] = None diff --git a/src/cloudflare/types/api_gateway/message.py b/src/cloudflare/types/api_gateway/message.py new file mode 100644 index 00000000000..a09437a8d14 --- /dev/null +++ b/src/cloudflare/types/api_gateway/message.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from ..shared.response_info import ResponseInfo + +__all__ = ["Message"] + +Message = List[ResponseInfo] diff --git a/src/cloudflare/types/api_gateway/operation_create_params.py b/src/cloudflare/types/api_gateway/operation_create_params.py new file mode 100644 index 00000000000..dbfa97bf6e8 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operation_create_params.py @@ -0,0 +1,31 @@ +# 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 Literal, Required, TypedDict + +__all__ = ["OperationCreateParams", "Body"] + + +class OperationCreateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + body: Required[Iterable[Body]] + + +class Body(TypedDict, total=False): + endpoint: Required[str] + """ + The endpoint which can contain path parameter templates in curly braces, each + will be replaced from left to right with {varN}, starting with {var1}, during + insertion. This will further be Cloudflare-normalized upon insertion. See: + https://developers.cloudflare.com/rules/normalization/how-it-works/. + """ + + host: Required[str] + """RFC3986-compliant host.""" + + method: Required[Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"]] + """The HTTP method used to access the endpoint.""" diff --git a/src/cloudflare/types/api_gateway/operation_create_response.py b/src/cloudflare/types/api_gateway/operation_create_response.py new file mode 100644 index 00000000000..2244d14cf30 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operation_create_response.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .api_shield import APIShield + +__all__ = ["OperationCreateResponse"] + +OperationCreateResponse = List[APIShield] diff --git a/src/cloudflare/types/api_gateway/operation_delete_response.py b/src/cloudflare/types/api_gateway/operation_delete_response.py new file mode 100644 index 00000000000..5c1266decb6 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operation_delete_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +__all__ = ["OperationDeleteResponse"] + +OperationDeleteResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/api_gateway/operation_get_params.py b/src/cloudflare/types/api_gateway/operation_get_params.py new file mode 100644 index 00000000000..e752e501aae --- /dev/null +++ b/src/cloudflare/types/api_gateway/operation_get_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["OperationGetParams"] + + +class OperationGetParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] + """Add feature(s) to the results. + + The feature name that is given here corresponds to the resulting feature object. + Have a look at the top-level object description for more details on the specific + meaning. + """ diff --git a/src/cloudflare/types/api_gateway/operation_list_params.py b/src/cloudflare/types/api_gateway/operation_list_params.py new file mode 100644 index 00000000000..d36dac5d172 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operation_list_params.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["OperationListParams"] + + +class OperationListParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + direction: Literal["asc", "desc"] + """Direction to order results.""" + + endpoint: str + """Filter results to only include endpoints containing this pattern.""" + + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] + """Add feature(s) to the results. + + The feature name that is given here corresponds to the resulting feature object. + Have a look at the top-level object description for more details on the specific + meaning. + """ + + host: List[str] + """Filter results to only include the specified hosts.""" + + method: List[str] + """Filter results to only include the specified HTTP methods.""" + + order: Literal["method", "host", "endpoint", "thresholds.$key"] + """Field to order by. + + When requesting a feature, the feature keys are available for ordering as well, + e.g., `thresholds.suggested_threshold`. + """ + + page: object + """Page number of paginated results.""" + + per_page: float + """Number of results to return per page""" diff --git a/src/cloudflare/types/api_gateway/operations/__init__.py b/src/cloudflare/types/api_gateway/operations/__init__.py new file mode 100644 index 00000000000..12668aae6be --- /dev/null +++ b/src/cloudflare/types/api_gateway/operations/__init__.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .settings_multiple_request import SettingsMultipleRequest as SettingsMultipleRequest +from .schema_validation_edit_params import SchemaValidationEditParams as SchemaValidationEditParams +from .schema_validation_get_response import SchemaValidationGetResponse as SchemaValidationGetResponse +from .schema_validation_update_params import SchemaValidationUpdateParams as SchemaValidationUpdateParams +from .settings_multiple_request_param import SettingsMultipleRequestParam as SettingsMultipleRequestParam +from .schema_validation_update_response import SchemaValidationUpdateResponse as SchemaValidationUpdateResponse diff --git a/src/cloudflare/types/api_gateway/operations/schema_validation_edit_params.py b/src/cloudflare/types/api_gateway/operations/schema_validation_edit_params.py new file mode 100644 index 00000000000..45926402aa5 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operations/schema_validation_edit_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_extensions import Required, TypedDict + +from .settings_multiple_request_param import SettingsMultipleRequestParam + +__all__ = ["SchemaValidationEditParams"] + + +class SchemaValidationEditParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + settings_multiple_request: Required[SettingsMultipleRequestParam] diff --git a/src/cloudflare/types/api_gateway/operations/schema_validation_get_response.py b/src/cloudflare/types/api_gateway/operations/schema_validation_get_response.py new file mode 100644 index 00000000000..32fdc4cb3d4 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operations/schema_validation_get_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["SchemaValidationGetResponse"] + + +class SchemaValidationGetResponse(BaseModel): + mitigation_action: Optional[Literal["log", "block", "none"]] = None + """When set, this applies a mitigation action to this operation + + - `log` log request when request does not conform to schema for this operation + - `block` deny access to the site when request does not conform to schema for + this operation + - `none` will skip mitigation for this operation + - `null` indicates that no operation level mitigation is in place, see Zone + Level Schema Validation Settings for mitigation action that will be applied + """ diff --git a/src/cloudflare/types/api_gateway/operations/schema_validation_update_params.py b/src/cloudflare/types/api_gateway/operations/schema_validation_update_params.py new file mode 100644 index 00000000000..e9975b01cda --- /dev/null +++ b/src/cloudflare/types/api_gateway/operations/schema_validation_update_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["SchemaValidationUpdateParams"] + + +class SchemaValidationUpdateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + mitigation_action: Optional[Literal["log", "block", "none"]] + """When set, this applies a mitigation action to this operation + + - `log` log request when request does not conform to schema for this operation + - `block` deny access to the site when request does not conform to schema for + this operation + - `none` will skip mitigation for this operation + - `null` indicates that no operation level mitigation is in place, see Zone + Level Schema Validation Settings for mitigation action that will be applied + """ diff --git a/src/cloudflare/types/api_gateway/operations/schema_validation_update_response.py b/src/cloudflare/types/api_gateway/operations/schema_validation_update_response.py new file mode 100644 index 00000000000..ab2d8ffd967 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operations/schema_validation_update_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["SchemaValidationUpdateResponse"] + + +class SchemaValidationUpdateResponse(BaseModel): + mitigation_action: Optional[Literal["log", "block", "none"]] = None + """When set, this applies a mitigation action to this operation + + - `log` log request when request does not conform to schema for this operation + - `block` deny access to the site when request does not conform to schema for + this operation + - `none` will skip mitigation for this operation + - `null` indicates that no operation level mitigation is in place, see Zone + Level Schema Validation Settings for mitigation action that will be applied + """ diff --git a/src/cloudflare/types/api_gateway/operations/settings_multiple_request.py b/src/cloudflare/types/api_gateway/operations/settings_multiple_request.py new file mode 100644 index 00000000000..b55c1a48c87 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operations/settings_multiple_request.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["SettingsMultipleRequest", "SettingsMultipleRequestItem"] + + +class SettingsMultipleRequestItem(BaseModel): + mitigation_action: Optional[Literal["log", "block", "none"]] = None + """When set, this applies a mitigation action to this operation + + - `log` log request when request does not conform to schema for this operation + - `block` deny access to the site when request does not conform to schema for + this operation + - `none` will skip mitigation for this operation + - `null` indicates that no operation level mitigation is in place, see Zone + Level Schema Validation Settings for mitigation action that will be applied + """ + + +SettingsMultipleRequest = Dict[str, SettingsMultipleRequestItem] diff --git a/src/cloudflare/types/api_gateway/operations/settings_multiple_request_param.py b/src/cloudflare/types/api_gateway/operations/settings_multiple_request_param.py new file mode 100644 index 00000000000..ec180487534 --- /dev/null +++ b/src/cloudflare/types/api_gateway/operations/settings_multiple_request_param.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Optional +from typing_extensions import Literal, TypedDict + +__all__ = ["SettingsMultipleRequestParam", "SettingsMultipleRequestParamItem"] + + +class SettingsMultipleRequestParamItem(TypedDict, total=False): + mitigation_action: Optional[Literal["log", "block", "none"]] + """When set, this applies a mitigation action to this operation + + - `log` log request when request does not conform to schema for this operation + - `block` deny access to the site when request does not conform to schema for + this operation + - `none` will skip mitigation for this operation + - `null` indicates that no operation level mitigation is in place, see Zone + Level Schema Validation Settings for mitigation action that will be applied + """ + + +SettingsMultipleRequestParam = Dict[str, SettingsMultipleRequestParamItem] diff --git a/src/cloudflare/types/api_gateway/public_schema.py b/src/cloudflare/types/api_gateway/public_schema.py new file mode 100644 index 00000000000..6dabec42f5c --- /dev/null +++ b/src/cloudflare/types/api_gateway/public_schema.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["PublicSchema"] + + +class PublicSchema(BaseModel): + created_at: datetime + + kind: Literal["openapi_v3"] + """Kind of schema""" + + name: str + """Name of the schema""" + + schema_id: str + """UUID identifier""" + + source: Optional[str] = None + """Source of the schema""" + + validation_enabled: Optional[bool] = None + """Flag whether schema is enabled for validation.""" diff --git a/src/cloudflare/types/api_gateway/schema.py b/src/cloudflare/types/api_gateway/schema.py new file mode 100644 index 00000000000..5b44bcf0853 --- /dev/null +++ b/src/cloudflare/types/api_gateway/schema.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +from .message import Message +from ..._models import BaseModel + +__all__ = ["Schema"] + + +class Schema(BaseModel): + errors: Message + + messages: Message + + result: Union[Optional[str], Optional[object]] + + success: bool + """Whether the API call was successful""" diff --git a/src/cloudflare/types/api_gateway/schema_list_params.py b/src/cloudflare/types/api_gateway/schema_list_params.py new file mode 100644 index 00000000000..7bc4f9ac025 --- /dev/null +++ b/src/cloudflare/types/api_gateway/schema_list_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["SchemaListParams"] + + +class SchemaListParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] + """Add feature(s) to the results. + + The feature name that is given here corresponds to the resulting feature object. + Have a look at the top-level object description for more details on the specific + meaning. + """ + + host: List[str] + """Receive schema only for the given host(s).""" diff --git a/src/cloudflare/types/api_gateway/schema_list_response.py b/src/cloudflare/types/api_gateway/schema_list_response.py new file mode 100644 index 00000000000..9b7b5b00ae8 --- /dev/null +++ b/src/cloudflare/types/api_gateway/schema_list_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["SchemaListResponse"] + + +class SchemaListResponse(BaseModel): + schemas: Optional[List[object]] = None + + timestamp: Optional[str] = None diff --git a/src/cloudflare/types/api_gateway/schema_upload.py b/src/cloudflare/types/api_gateway/schema_upload.py new file mode 100644 index 00000000000..3df20a038b4 --- /dev/null +++ b/src/cloudflare/types/api_gateway/schema_upload.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel +from .public_schema import PublicSchema + +__all__ = ["SchemaUpload", "UploadDetails", "UploadDetailsWarning"] + + +class UploadDetailsWarning(BaseModel): + code: int + """Code that identifies the event that occurred.""" + + locations: Optional[List[str]] = None + """JSONPath location(s) in the schema where these events were encountered. + + See + [https://goessner.net/articles/JsonPath/](https://goessner.net/articles/JsonPath/) + for JSONPath specification. + """ + + message: Optional[str] = None + """Diagnostic message that describes the event.""" + + +class UploadDetails(BaseModel): + warnings: Optional[List[UploadDetailsWarning]] = None + """Diagnostic warning events that occurred during processing. + + These events are non-critical errors found within the schema. + """ + + +class SchemaUpload(BaseModel): + schema_: PublicSchema = FieldInfo(alias="schema") + + upload_details: Optional[UploadDetails] = None diff --git a/src/cloudflare/types/api_gateway/schema_validation_edit_params.py b/src/cloudflare/types/api_gateway/schema_validation_edit_params.py new file mode 100644 index 00000000000..424471b1283 --- /dev/null +++ b/src/cloudflare/types/api_gateway/schema_validation_edit_params.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["SchemaValidationEditParams"] + + +class SchemaValidationEditParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] + """ + The default mitigation action used when there is no mitigation action defined on + the operation Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + + `null` will have no effect. + """ + + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] + """When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + + To clear any override, use the special value `disable_override` + + `null` will have no effect. + """ diff --git a/src/cloudflare/types/api_gateway/settings/__init__.py b/src/cloudflare/types/api_gateway/settings/__init__.py new file mode 100644 index 00000000000..6bf117b4acd --- /dev/null +++ b/src/cloudflare/types/api_gateway/settings/__init__.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .settings import Settings as Settings +from .schema_validation_update_params import SchemaValidationUpdateParams as SchemaValidationUpdateParams diff --git a/src/cloudflare/types/api_gateway/settings/schema_validation_update_params.py b/src/cloudflare/types/api_gateway/settings/schema_validation_update_params.py new file mode 100644 index 00000000000..e7ffb4e6bdd --- /dev/null +++ b/src/cloudflare/types/api_gateway/settings/schema_validation_update_params.py @@ -0,0 +1,36 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["SchemaValidationUpdateParams"] + + +class SchemaValidationUpdateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + validation_default_mitigation_action: Required[Literal["none", "log", "block"]] + """ + The default mitigation action used when there is no mitigation action defined on + the operation + + Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + """ + + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] + """When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + - `null` indicates that no override is in place + + To clear any override, use the special value `disable_override` or `null` + """ diff --git a/src/cloudflare/types/api_gateway/settings/settings.py b/src/cloudflare/types/api_gateway/settings/settings.py new file mode 100644 index 00000000000..b8d1b00260c --- /dev/null +++ b/src/cloudflare/types/api_gateway/settings/settings.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["Settings"] + + +class Settings(BaseModel): + validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] = None + """ + The default mitigation action used when there is no mitigation action defined on + the operation + + Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + """ + + validation_override_mitigation_action: Optional[Literal["none"]] = None + """When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + - `null` indicates that no override is in place + """ diff --git a/src/cloudflare/types/api_gateway/user_schema_create_params.py b/src/cloudflare/types/api_gateway/user_schema_create_params.py new file mode 100644 index 00000000000..10d9593240a --- /dev/null +++ b/src/cloudflare/types/api_gateway/user_schema_create_params.py @@ -0,0 +1,26 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..._types import FileTypes + +__all__ = ["UserSchemaCreateParams"] + + +class UserSchemaCreateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + file: Required[FileTypes] + """Schema file bytes""" + + kind: Required[Literal["openapi_v3"]] + """Kind of schema""" + + name: str + """Name of the schema""" + + validation_enabled: Literal["true", "false"] + """Flag whether schema is enabled for validation.""" diff --git a/src/cloudflare/types/api_gateway/user_schema_delete_response.py b/src/cloudflare/types/api_gateway/user_schema_delete_response.py new file mode 100644 index 00000000000..5a901e1de91 --- /dev/null +++ b/src/cloudflare/types/api_gateway/user_schema_delete_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +__all__ = ["UserSchemaDeleteResponse"] + +UserSchemaDeleteResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/api_gateway/user_schema_edit_params.py b/src/cloudflare/types/api_gateway/user_schema_edit_params.py new file mode 100644 index 00000000000..99e15349c77 --- /dev/null +++ b/src/cloudflare/types/api_gateway/user_schema_edit_params.py @@ -0,0 +1,15 @@ +# 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__ = ["UserSchemaEditParams"] + + +class UserSchemaEditParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + validation_enabled: Literal[True] + """Flag whether schema is enabled for validation.""" diff --git a/src/cloudflare/types/api_gateway/user_schema_get_params.py b/src/cloudflare/types/api_gateway/user_schema_get_params.py new file mode 100644 index 00000000000..dbaee3dee47 --- /dev/null +++ b/src/cloudflare/types/api_gateway/user_schema_get_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["UserSchemaGetParams"] + + +class UserSchemaGetParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + omit_source: bool + """Omit the source-files of schemas and only retrieve their meta-data.""" diff --git a/src/cloudflare/types/api_gateway/user_schema_list_params.py b/src/cloudflare/types/api_gateway/user_schema_list_params.py new file mode 100644 index 00000000000..a46fd077690 --- /dev/null +++ b/src/cloudflare/types/api_gateway/user_schema_list_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["UserSchemaListParams"] + + +class UserSchemaListParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + omit_source: bool + """Omit the source-files of schemas and only retrieve their meta-data.""" + + page: object + """Page number of paginated results.""" + + per_page: object + """Maximum number of results per page.""" + + validation_enabled: bool + """Flag whether schema is enabled for validation.""" diff --git a/src/cloudflare/types/api_gateway/user_schemas/__init__.py b/src/cloudflare/types/api_gateway/user_schemas/__init__.py new file mode 100644 index 00000000000..597343a578b --- /dev/null +++ b/src/cloudflare/types/api_gateway/user_schemas/__init__.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .operation_list_params import OperationListParams as OperationListParams +from .operation_list_response import OperationListResponse as OperationListResponse diff --git a/src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py b/src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py new file mode 100644 index 00000000000..8e6eaebd97b --- /dev/null +++ b/src/cloudflare/types/api_gateway/user_schemas/operation_list_params.py @@ -0,0 +1,44 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["OperationListParams"] + + +class OperationListParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + endpoint: str + """Filter results to only include endpoints containing this pattern.""" + + feature: List[Literal["thresholds", "parameter_schemas", "schema_info"]] + """Add feature(s) to the results. + + The feature name that is given here corresponds to the resulting feature object. + Have a look at the top-level object description for more details on the specific + meaning. + """ + + host: List[str] + """Filter results to only include the specified hosts.""" + + method: List[str] + """Filter results to only include the specified HTTP methods.""" + + operation_status: Literal["new", "existing"] + """ + Filter results by whether operations exist in API Shield Endpoint Management or + not. `new` will just return operations from the schema that do not exist in API + Shield Endpoint Management. `existing` will just return operations from the + schema that already exist in API Shield Endpoint Management. + """ + + page: object + """Page number of paginated results.""" + + per_page: object + """Maximum number of results per page.""" diff --git a/src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py b/src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py new file mode 100644 index 00000000000..b4ff6af36be --- /dev/null +++ b/src/cloudflare/types/api_gateway/user_schemas/operation_list_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import Literal + +from ...._models import BaseModel +from ..api_shield import APIShield + +__all__ = ["OperationListResponse", "APIShieldBasicOperation"] + + +class APIShieldBasicOperation(BaseModel): + endpoint: str + """ + The endpoint which can contain path parameter templates in curly braces, each + will be replaced from left to right with {varN}, starting with {var1}, during + insertion. This will further be Cloudflare-normalized upon insertion. See: + https://developers.cloudflare.com/rules/normalization/how-it-works/. + """ + + host: str + """RFC3986-compliant host.""" + + method: Literal["GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "CONNECT", "PATCH", "TRACE"] + """The HTTP method used to access the endpoint.""" + + +OperationListResponse = Union[APIShield, APIShieldBasicOperation] diff --git a/tests/api_resources/api_gateway/__init__.py b/tests/api_resources/api_gateway/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/api_gateway/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/api_gateway/discovery/__init__.py b/tests/api_resources/api_gateway/discovery/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/api_gateway/discovery/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/api_gateway/discovery/test_operations.py b/tests/api_resources/api_gateway/discovery/test_operations.py new file mode 100644 index 00000000000..3318acf896a --- /dev/null +++ b/tests/api_resources/api_gateway/discovery/test_operations.py @@ -0,0 +1,248 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.api_gateway import DiscoveryOperation +from cloudflare.types.api_gateway.discovery import OperationEditResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestOperations: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + operation = client.api_gateway.discovery.operations.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[DiscoveryOperation], operation, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + operation = client.api_gateway.discovery.operations.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + diff=True, + direction="desc", + endpoint="/api/v1", + host=["api.cloudflare.com"], + method=["GET"], + order="method", + origin="ML", + page={}, + per_page={}, + state="review", + ) + assert_matches_type(SyncSinglePage[DiscoveryOperation], operation, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.api_gateway.discovery.operations.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = response.parse() + assert_matches_type(SyncSinglePage[DiscoveryOperation], operation, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.api_gateway.discovery.operations.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = response.parse() + assert_matches_type(SyncSinglePage[DiscoveryOperation], operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.discovery.operations.with_raw_response.list( + zone_id="", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + operation = client.api_gateway.discovery.operations.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(OperationEditResponse, operation, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + operation = client.api_gateway.discovery.operations.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + state="review", + ) + assert_matches_type(OperationEditResponse, operation, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.api_gateway.discovery.operations.with_raw_response.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = response.parse() + assert_matches_type(OperationEditResponse, operation, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.api_gateway.discovery.operations.with_streaming_response.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = response.parse() + assert_matches_type(OperationEditResponse, operation, 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 `zone_id` but received ''"): + client.api_gateway.discovery.operations.with_raw_response.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + client.api_gateway.discovery.operations.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncOperations: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.discovery.operations.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[DiscoveryOperation], operation, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.discovery.operations.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + diff=True, + direction="desc", + endpoint="/api/v1", + host=["api.cloudflare.com"], + method=["GET"], + order="method", + origin="ML", + page={}, + per_page={}, + state="review", + ) + assert_matches_type(AsyncSinglePage[DiscoveryOperation], operation, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.discovery.operations.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = await response.parse() + assert_matches_type(AsyncSinglePage[DiscoveryOperation], operation, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.discovery.operations.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = await response.parse() + assert_matches_type(AsyncSinglePage[DiscoveryOperation], operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.discovery.operations.with_raw_response.list( + zone_id="", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.discovery.operations.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(OperationEditResponse, operation, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.discovery.operations.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + state="review", + ) + assert_matches_type(OperationEditResponse, operation, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.discovery.operations.with_raw_response.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = await response.parse() + assert_matches_type(OperationEditResponse, operation, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.discovery.operations.with_streaming_response.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = await response.parse() + assert_matches_type(OperationEditResponse, operation, 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 `zone_id` but received ''"): + await async_client.api_gateway.discovery.operations.with_raw_response.edit( + "0d9bf70c-92e1-4bb3-9411-34a3bcc59003", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + await async_client.api_gateway.discovery.operations.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/api_gateway/operations/__init__.py b/tests/api_resources/api_gateway/operations/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/api_gateway/operations/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/api_gateway/operations/test_schema_validation.py b/tests/api_resources/api_gateway/operations/test_schema_validation.py new file mode 100644 index 00000000000..c821655f2da --- /dev/null +++ b/tests/api_resources/api_gateway/operations/test_schema_validation.py @@ -0,0 +1,344 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.api_gateway.operations import ( + SettingsMultipleRequest, + SchemaValidationGetResponse, + SchemaValidationUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSchemaValidation: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.operations.schema_validation.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SchemaValidationUpdateResponse, schema_validation, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.operations.schema_validation.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + mitigation_action="block", + ) + assert_matches_type(SchemaValidationUpdateResponse, schema_validation, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.api_gateway.operations.schema_validation.with_raw_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = response.parse() + assert_matches_type(SchemaValidationUpdateResponse, schema_validation, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.api_gateway.operations.schema_validation.with_streaming_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = response.parse() + assert_matches_type(SchemaValidationUpdateResponse, schema_validation, 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 `zone_id` but received ''"): + client.api_gateway.operations.schema_validation.with_raw_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + client.api_gateway.operations.schema_validation.with_raw_response.update( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.operations.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + settings_multiple_request={ + "3818d821-5901-4147-a474-f5f5aec1d54e": {}, + "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": {}, + }, + ) + assert_matches_type(SettingsMultipleRequest, schema_validation, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.api_gateway.operations.schema_validation.with_raw_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + settings_multiple_request={ + "3818d821-5901-4147-a474-f5f5aec1d54e": {}, + "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": {}, + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = response.parse() + assert_matches_type(SettingsMultipleRequest, schema_validation, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.api_gateway.operations.schema_validation.with_streaming_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + settings_multiple_request={ + "3818d821-5901-4147-a474-f5f5aec1d54e": {}, + "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": {}, + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = response.parse() + assert_matches_type(SettingsMultipleRequest, schema_validation, 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 `zone_id` but received ''"): + client.api_gateway.operations.schema_validation.with_raw_response.edit( + zone_id="", + settings_multiple_request={ + "3818d821-5901-4147-a474-f5f5aec1d54e": {}, + "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": {}, + }, + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.operations.schema_validation.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SchemaValidationGetResponse, schema_validation, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.api_gateway.operations.schema_validation.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = response.parse() + assert_matches_type(SchemaValidationGetResponse, schema_validation, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.api_gateway.operations.schema_validation.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = response.parse() + assert_matches_type(SchemaValidationGetResponse, schema_validation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.operations.schema_validation.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + client.api_gateway.operations.schema_validation.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncSchemaValidation: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.operations.schema_validation.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SchemaValidationUpdateResponse, schema_validation, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.operations.schema_validation.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + mitigation_action="block", + ) + assert_matches_type(SchemaValidationUpdateResponse, schema_validation, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.operations.schema_validation.with_raw_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = await response.parse() + assert_matches_type(SchemaValidationUpdateResponse, schema_validation, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.operations.schema_validation.with_streaming_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = await response.parse() + assert_matches_type(SchemaValidationUpdateResponse, schema_validation, 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 `zone_id` but received ''"): + await async_client.api_gateway.operations.schema_validation.with_raw_response.update( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + await async_client.api_gateway.operations.schema_validation.with_raw_response.update( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.operations.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + settings_multiple_request={ + "3818d821-5901-4147-a474-f5f5aec1d54e": {}, + "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": {}, + }, + ) + assert_matches_type(SettingsMultipleRequest, schema_validation, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.operations.schema_validation.with_raw_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + settings_multiple_request={ + "3818d821-5901-4147-a474-f5f5aec1d54e": {}, + "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": {}, + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = await response.parse() + assert_matches_type(SettingsMultipleRequest, schema_validation, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.operations.schema_validation.with_streaming_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + settings_multiple_request={ + "3818d821-5901-4147-a474-f5f5aec1d54e": {}, + "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": {}, + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = await response.parse() + assert_matches_type(SettingsMultipleRequest, schema_validation, 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 `zone_id` but received ''"): + await async_client.api_gateway.operations.schema_validation.with_raw_response.edit( + zone_id="", + settings_multiple_request={ + "3818d821-5901-4147-a474-f5f5aec1d54e": {}, + "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": {}, + }, + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.operations.schema_validation.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SchemaValidationGetResponse, schema_validation, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.operations.schema_validation.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = await response.parse() + assert_matches_type(SchemaValidationGetResponse, schema_validation, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.operations.schema_validation.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = await response.parse() + assert_matches_type(SchemaValidationGetResponse, schema_validation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.operations.schema_validation.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + await async_client.api_gateway.operations.schema_validation.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/api_gateway/settings/__init__.py b/tests/api_resources/api_gateway/settings/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/api_gateway/settings/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/api_gateway/settings/test_schema_validation.py b/tests/api_resources/api_gateway/settings/test_schema_validation.py new file mode 100644 index 00000000000..f0d5bb47925 --- /dev/null +++ b/tests/api_resources/api_gateway/settings/test_schema_validation.py @@ -0,0 +1,200 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.api_gateway.settings import Settings + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSchemaValidation: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.settings.schema_validation.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.settings.schema_validation.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + validation_override_mitigation_action="none", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.api_gateway.settings.schema_validation.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.api_gateway.settings.schema_validation.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = response.parse() + assert_matches_type(Settings, schema_validation, 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 `zone_id` but received ''"): + client.api_gateway.settings.schema_validation.with_raw_response.update( + zone_id="", + validation_default_mitigation_action="block", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.settings.schema_validation.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.api_gateway.settings.schema_validation.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.api_gateway.settings.schema_validation.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.settings.schema_validation.with_raw_response.get( + zone_id="", + ) + + +class TestAsyncSchemaValidation: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.settings.schema_validation.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.settings.schema_validation.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + validation_override_mitigation_action="none", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.settings.schema_validation.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = await response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.settings.schema_validation.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = await response.parse() + assert_matches_type(Settings, schema_validation, 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 `zone_id` but received ''"): + await async_client.api_gateway.settings.schema_validation.with_raw_response.update( + zone_id="", + validation_default_mitigation_action="block", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.settings.schema_validation.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.settings.schema_validation.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = await response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.settings.schema_validation.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = await response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.settings.schema_validation.with_raw_response.get( + zone_id="", + ) diff --git a/tests/api_resources/api_gateway/test_configurations.py b/tests/api_resources/api_gateway/test_configurations.py new file mode 100644 index 00000000000..675123bd057 --- /dev/null +++ b/tests/api_resources/api_gateway/test_configurations.py @@ -0,0 +1,219 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.api_gateway import ( + Configuration, + ConfigurationUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestConfigurations: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + configuration = client.api_gateway.configurations.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ConfigurationUpdateResponse, configuration, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + configuration = client.api_gateway.configurations.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + auth_id_characteristics=[ + { + "name": "authorization", + "type": "header", + } + ], + ) + assert_matches_type(ConfigurationUpdateResponse, configuration, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.api_gateway.configurations.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + configuration = response.parse() + assert_matches_type(ConfigurationUpdateResponse, configuration, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.api_gateway.configurations.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + configuration = response.parse() + assert_matches_type(ConfigurationUpdateResponse, configuration, 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 `zone_id` but received ''"): + client.api_gateway.configurations.with_raw_response.update( + zone_id="", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + configuration = client.api_gateway.configurations.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Configuration, configuration, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + configuration = client.api_gateway.configurations.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + properties=["auth_id_characteristics"], + ) + assert_matches_type(Configuration, configuration, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.api_gateway.configurations.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + configuration = response.parse() + assert_matches_type(Configuration, configuration, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.api_gateway.configurations.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + configuration = response.parse() + assert_matches_type(Configuration, configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.configurations.with_raw_response.get( + zone_id="", + ) + + +class TestAsyncConfigurations: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + configuration = await async_client.api_gateway.configurations.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(ConfigurationUpdateResponse, configuration, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + configuration = await async_client.api_gateway.configurations.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + auth_id_characteristics=[ + { + "name": "authorization", + "type": "header", + } + ], + ) + assert_matches_type(ConfigurationUpdateResponse, configuration, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.configurations.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + configuration = await response.parse() + assert_matches_type(ConfigurationUpdateResponse, configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.configurations.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + configuration = await response.parse() + assert_matches_type(ConfigurationUpdateResponse, configuration, 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 `zone_id` but received ''"): + await async_client.api_gateway.configurations.with_raw_response.update( + zone_id="", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + configuration = await async_client.api_gateway.configurations.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Configuration, configuration, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + configuration = await async_client.api_gateway.configurations.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + properties=["auth_id_characteristics"], + ) + assert_matches_type(Configuration, configuration, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.configurations.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + configuration = await response.parse() + assert_matches_type(Configuration, configuration, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.configurations.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + configuration = await response.parse() + assert_matches_type(Configuration, configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.configurations.with_raw_response.get( + zone_id="", + ) diff --git a/tests/api_resources/api_gateway/test_discovery.py b/tests/api_resources/api_gateway/test_discovery.py new file mode 100644 index 00000000000..f41ab529266 --- /dev/null +++ b/tests/api_resources/api_gateway/test_discovery.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.api_gateway import DiscoveryGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestDiscovery: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + discovery = client.api_gateway.discovery.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DiscoveryGetResponse, discovery, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.api_gateway.discovery.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + discovery = response.parse() + assert_matches_type(DiscoveryGetResponse, discovery, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.api_gateway.discovery.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + discovery = response.parse() + assert_matches_type(DiscoveryGetResponse, discovery, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.discovery.with_raw_response.get( + zone_id="", + ) + + +class TestAsyncDiscovery: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + discovery = await async_client.api_gateway.discovery.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(DiscoveryGetResponse, discovery, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.discovery.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + discovery = await response.parse() + assert_matches_type(DiscoveryGetResponse, discovery, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.discovery.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + discovery = await response.parse() + assert_matches_type(DiscoveryGetResponse, discovery, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.discovery.with_raw_response.get( + zone_id="", + ) diff --git a/tests/api_resources/api_gateway/test_operations.py b/tests/api_resources/api_gateway/test_operations.py new file mode 100644 index 00000000000..6c0d2194715 --- /dev/null +++ b/tests/api_resources/api_gateway/test_operations.py @@ -0,0 +1,555 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.api_gateway import ( + APIShield, + OperationCreateResponse, + OperationDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestOperations: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + operation = client.api_gateway.operations.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + ], + ) + assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.api_gateway.operations.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = response.parse() + assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.api_gateway.operations.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = response.parse() + assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.operations.with_raw_response.create( + zone_id="", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + ], + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + operation = client.api_gateway.operations.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[APIShield], operation, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + operation = client.api_gateway.operations.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + endpoint="/api/v1", + feature=["thresholds"], + host=["api.cloudflare.com"], + method=["GET"], + order="method", + page={}, + per_page=5, + ) + assert_matches_type(SyncSinglePage[APIShield], operation, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.api_gateway.operations.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = response.parse() + assert_matches_type(SyncSinglePage[APIShield], operation, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.api_gateway.operations.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = response.parse() + assert_matches_type(SyncSinglePage[APIShield], operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.operations.with_raw_response.list( + zone_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + operation = client.api_gateway.operations.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(OperationDeleteResponse, operation, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.api_gateway.operations.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = response.parse() + assert_matches_type(OperationDeleteResponse, operation, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.api_gateway.operations.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = response.parse() + assert_matches_type(OperationDeleteResponse, operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.operations.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + client.api_gateway.operations.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + operation = client.api_gateway.operations.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(APIShield, operation, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + operation = client.api_gateway.operations.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + feature=["thresholds"], + ) + assert_matches_type(APIShield, operation, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.api_gateway.operations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = response.parse() + assert_matches_type(APIShield, operation, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.api_gateway.operations.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = response.parse() + assert_matches_type(APIShield, operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.operations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + client.api_gateway.operations.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncOperations: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.operations.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + ], + ) + assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.operations.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = await response.parse() + assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.operations.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = await response.parse() + assert_matches_type(Optional[OperationCreateResponse], operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.operations.with_raw_response.create( + zone_id="", + body=[ + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + { + "endpoint": "/api/v1/users/{var1}", + "host": "www.example.com", + "method": "GET", + }, + ], + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.operations.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[APIShield], operation, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.operations.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + endpoint="/api/v1", + feature=["thresholds"], + host=["api.cloudflare.com"], + method=["GET"], + order="method", + page={}, + per_page=5, + ) + assert_matches_type(AsyncSinglePage[APIShield], operation, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.operations.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = await response.parse() + assert_matches_type(AsyncSinglePage[APIShield], operation, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.operations.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = await response.parse() + assert_matches_type(AsyncSinglePage[APIShield], operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.operations.with_raw_response.list( + zone_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.operations.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(OperationDeleteResponse, operation, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.operations.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = await response.parse() + assert_matches_type(OperationDeleteResponse, operation, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.operations.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = await response.parse() + assert_matches_type(OperationDeleteResponse, operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.operations.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + await async_client.api_gateway.operations.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.operations.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(APIShield, operation, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.operations.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + feature=["thresholds"], + ) + assert_matches_type(APIShield, operation, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.operations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = await response.parse() + assert_matches_type(APIShield, operation, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.operations.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = await response.parse() + assert_matches_type(APIShield, operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.operations.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `operation_id` but received ''"): + await async_client.api_gateway.operations.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/api_gateway/test_schema_validation.py b/tests/api_resources/api_gateway/test_schema_validation.py new file mode 100644 index 00000000000..dbe446a6c02 --- /dev/null +++ b/tests/api_resources/api_gateway/test_schema_validation.py @@ -0,0 +1,116 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.api_gateway.settings import Settings + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSchemaValidation: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + validation_override_mitigation_action="none", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.api_gateway.schema_validation.with_raw_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.api_gateway.schema_validation.with_streaming_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = response.parse() + assert_matches_type(Settings, schema_validation, 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 `zone_id` but received ''"): + client.api_gateway.schema_validation.with_raw_response.edit( + zone_id="", + ) + + +class TestAsyncSchemaValidation: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + validation_override_mitigation_action="none", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.schema_validation.with_raw_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = await response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.schema_validation.with_streaming_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = await response.parse() + assert_matches_type(Settings, schema_validation, 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 `zone_id` but received ''"): + await async_client.api_gateway.schema_validation.with_raw_response.edit( + zone_id="", + ) diff --git a/tests/api_resources/api_gateway/test_schemas.py b/tests/api_resources/api_gateway/test_schemas.py new file mode 100644 index 00000000000..5c2542b4cb5 --- /dev/null +++ b/tests/api_resources/api_gateway/test_schemas.py @@ -0,0 +1,116 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.api_gateway import SchemaListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSchemas: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + schema = client.api_gateway.schemas.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SchemaListResponse, schema, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + schema = client.api_gateway.schemas.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + feature=["thresholds"], + host=["www.example.com"], + ) + assert_matches_type(SchemaListResponse, schema, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.api_gateway.schemas.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema = response.parse() + assert_matches_type(SchemaListResponse, schema, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.api_gateway.schemas.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema = response.parse() + assert_matches_type(SchemaListResponse, schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.schemas.with_raw_response.list( + zone_id="", + ) + + +class TestAsyncSchemas: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + schema = await async_client.api_gateway.schemas.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SchemaListResponse, schema, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + schema = await async_client.api_gateway.schemas.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + feature=["thresholds"], + host=["www.example.com"], + ) + assert_matches_type(SchemaListResponse, schema, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.schemas.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema = await response.parse() + assert_matches_type(SchemaListResponse, schema, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.schemas.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema = await response.parse() + assert_matches_type(SchemaListResponse, schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.schemas.with_raw_response.list( + zone_id="", + ) diff --git a/tests/api_resources/api_gateway/test_user_schemas.py b/tests/api_resources/api_gateway/test_user_schemas.py new file mode 100644 index 00000000000..dddeafd45e8 --- /dev/null +++ b/tests/api_resources/api_gateway/test_user_schemas.py @@ -0,0 +1,563 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.api_gateway import ( + PublicSchema, + SchemaUpload, + UserSchemaDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestUserSchemas: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + file=b"raw file contents", + kind="openapi_v3", + ) + assert_matches_type(SchemaUpload, user_schema, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + file=b"raw file contents", + kind="openapi_v3", + name="petstore schema", + validation_enabled="true", + ) + assert_matches_type(SchemaUpload, user_schema, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.api_gateway.user_schemas.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + file=b"raw file contents", + kind="openapi_v3", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = response.parse() + assert_matches_type(SchemaUpload, user_schema, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.api_gateway.user_schemas.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + file=b"raw file contents", + kind="openapi_v3", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = response.parse() + assert_matches_type(SchemaUpload, user_schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.user_schemas.with_raw_response.create( + zone_id="", + file=b"raw file contents", + kind="openapi_v3", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[PublicSchema], user_schema, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + omit_source=True, + page={}, + per_page={}, + validation_enabled=True, + ) + assert_matches_type(SyncSinglePage[PublicSchema], user_schema, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.api_gateway.user_schemas.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = response.parse() + assert_matches_type(SyncSinglePage[PublicSchema], user_schema, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.api_gateway.user_schemas.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = response.parse() + assert_matches_type(SyncSinglePage[PublicSchema], user_schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.user_schemas.with_raw_response.list( + zone_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.api_gateway.user_schemas.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = response.parse() + assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.api_gateway.user_schemas.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = response.parse() + assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.user_schemas.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `schema_id` but received ''"): + client.api_gateway.user_schemas.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_enabled=True, + ) + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.api_gateway.user_schemas.with_raw_response.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = response.parse() + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.api_gateway.user_schemas.with_streaming_response.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = response.parse() + assert_matches_type(PublicSchema, user_schema, 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 `zone_id` but received ''"): + client.api_gateway.user_schemas.with_raw_response.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `schema_id` but received ''"): + client.api_gateway.user_schemas.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + user_schema = client.api_gateway.user_schemas.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + omit_source=True, + ) + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.api_gateway.user_schemas.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = response.parse() + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.api_gateway.user_schemas.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = response.parse() + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.user_schemas.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `schema_id` but received ''"): + client.api_gateway.user_schemas.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncUserSchemas: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + file=b"raw file contents", + kind="openapi_v3", + ) + assert_matches_type(SchemaUpload, user_schema, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + file=b"raw file contents", + kind="openapi_v3", + name="petstore schema", + validation_enabled="true", + ) + assert_matches_type(SchemaUpload, user_schema, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.user_schemas.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + file=b"raw file contents", + kind="openapi_v3", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = await response.parse() + assert_matches_type(SchemaUpload, user_schema, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.user_schemas.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + file=b"raw file contents", + kind="openapi_v3", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = await response.parse() + assert_matches_type(SchemaUpload, user_schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.user_schemas.with_raw_response.create( + zone_id="", + file=b"raw file contents", + kind="openapi_v3", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[PublicSchema], user_schema, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + omit_source=True, + page={}, + per_page={}, + validation_enabled=True, + ) + assert_matches_type(AsyncSinglePage[PublicSchema], user_schema, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.user_schemas.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = await response.parse() + assert_matches_type(AsyncSinglePage[PublicSchema], user_schema, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.user_schemas.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = await response.parse() + assert_matches_type(AsyncSinglePage[PublicSchema], user_schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.user_schemas.with_raw_response.list( + zone_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.user_schemas.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = await response.parse() + assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.user_schemas.with_streaming_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = await response.parse() + assert_matches_type(UserSchemaDeleteResponse, user_schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.user_schemas.with_raw_response.delete( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `schema_id` but received ''"): + await async_client.api_gateway.user_schemas.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_enabled=True, + ) + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.user_schemas.with_raw_response.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = await response.parse() + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.user_schemas.with_streaming_response.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = await response.parse() + assert_matches_type(PublicSchema, user_schema, 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 `zone_id` but received ''"): + await async_client.api_gateway.user_schemas.with_raw_response.edit( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `schema_id` but received ''"): + await async_client.api_gateway.user_schemas.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + user_schema = await async_client.api_gateway.user_schemas.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + omit_source=True, + ) + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.user_schemas.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user_schema = await response.parse() + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.user_schemas.with_streaming_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user_schema = await response.parse() + assert_matches_type(PublicSchema, user_schema, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.user_schemas.with_raw_response.get( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `schema_id` but received ''"): + await async_client.api_gateway.user_schemas.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/api_gateway/user_schemas/__init__.py b/tests/api_resources/api_gateway/user_schemas/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/api_gateway/user_schemas/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/api_gateway/user_schemas/test_operations.py b/tests/api_resources/api_gateway/user_schemas/test_operations.py new file mode 100644 index 00000000000..ff5257f64c9 --- /dev/null +++ b/tests/api_resources/api_gateway/user_schemas/test_operations.py @@ -0,0 +1,149 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.api_gateway.user_schemas import OperationListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestOperations: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + operation = client.api_gateway.user_schemas.operations.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[OperationListResponse], operation, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + operation = client.api_gateway.user_schemas.operations.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + endpoint="/api/v1", + feature=["thresholds"], + host=["api.cloudflare.com"], + method=["GET"], + operation_status="new", + page={}, + per_page={}, + ) + assert_matches_type(SyncSinglePage[OperationListResponse], operation, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.api_gateway.user_schemas.operations.with_raw_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = response.parse() + assert_matches_type(SyncSinglePage[OperationListResponse], operation, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.api_gateway.user_schemas.operations.with_streaming_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = response.parse() + assert_matches_type(SyncSinglePage[OperationListResponse], operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.user_schemas.operations.with_raw_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `schema_id` but received ''"): + client.api_gateway.user_schemas.operations.with_raw_response.list( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncOperations: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.user_schemas.operations.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[OperationListResponse], operation, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + operation = await async_client.api_gateway.user_schemas.operations.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + endpoint="/api/v1", + feature=["thresholds"], + host=["api.cloudflare.com"], + method=["GET"], + operation_status="new", + page={}, + per_page={}, + ) + assert_matches_type(AsyncSinglePage[OperationListResponse], operation, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.user_schemas.operations.with_raw_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + operation = await response.parse() + assert_matches_type(AsyncSinglePage[OperationListResponse], operation, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.user_schemas.operations.with_streaming_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + operation = await response.parse() + assert_matches_type(AsyncSinglePage[OperationListResponse], operation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.user_schemas.operations.with_raw_response.list( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `schema_id` but received ''"): + await async_client.api_gateway.user_schemas.operations.with_raw_response.list( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) From 588716667b2060ec18202056fdaf8d4c2c6a24df Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 09:50:29 +0000 Subject: [PATCH 179/532] feat(api): OpenAPI spec update via Stainless API (#660) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index aaef851a064..d2b2938b7b3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5cc7607a4825bf9606463ee28fc976b8498b237c981bcb896211b60b6fe5c146.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaf3cf93b4b0566484405b918a65aeca6e5ad4cc194989298a633601684fa0c1.yml From 2cebcc3e5a2a0004f3e9ac3f56be2a9816dbdc78 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 09:52:37 +0000 Subject: [PATCH 180/532] feat(api): OpenAPI spec update via Stainless API (#661) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d2b2938b7b3..aaef851a064 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-eaf3cf93b4b0566484405b918a65aeca6e5ad4cc194989298a633601684fa0c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5cc7607a4825bf9606463ee28fc976b8498b237c981bcb896211b60b6fe5c146.yml From 6bbe0d88f07043c71cc160a114ef8d35fccd56f3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 09:59:29 +0000 Subject: [PATCH 181/532] feat(api): OpenAPI spec update via Stainless API (#662) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index aaef851a064..1d93ad978cc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5cc7607a4825bf9606463ee28fc976b8498b237c981bcb896211b60b6fe5c146.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d798919f06fdb766d1e047f3a387fa78bdee979130963b425176a00429b842b9.yml diff --git a/api.md b/api.md index f96a63ddc67..93866067807 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7634,14 +7634,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7657,10 +7657,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7677,11 +7677,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From bcc840d5bcf838d86f1982814ea7816baacf6de1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 10:29:44 +0000 Subject: [PATCH 182/532] feat(api): OpenAPI spec update via Stainless API (#663) --- .stats.yml | 4 +- api.md | 8 +- src/cloudflare/resources/radar/bgp/routes.py | 190 +----------------- src/cloudflare/types/radar/bgp/__init__.py | 2 - .../radar/bgp/route_timeseries_params.py | 56 ------ .../radar/bgp/route_timeseries_response.py | 42 ---- tests/api_resources/radar/bgp/test_routes.py | 78 ------- 7 files changed, 5 insertions(+), 375 deletions(-) delete mode 100644 src/cloudflare/types/radar/bgp/route_timeseries_params.py delete mode 100644 src/cloudflare/types/radar/bgp/route_timeseries_response.py diff --git a/.stats.yml b/.stats.yml index 1d93ad978cc..819c2de2b35 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d798919f06fdb766d1e047f3a387fa78bdee979130963b425176a00429b842b9.yml +configured_endpoints: 1318 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c9580652e64cbc56358ed166b67257a24a6079e70e390bab214e45920bba7039.yml diff --git a/api.md b/api.md index 93866067807..04a95f58489 100644 --- a/api.md +++ b/api.md @@ -6416,12 +6416,7 @@ Methods: Types: ```python -from cloudflare.types.radar.bgp import ( - RouteMoasResponse, - RoutePfx2asResponse, - RouteStatsResponse, - RouteTimeseriesResponse, -) +from cloudflare.types.radar.bgp import RouteMoasResponse, RoutePfx2asResponse, RouteStatsResponse ``` Methods: @@ -6429,7 +6424,6 @@ Methods: - client.radar.bgp.routes.moas(\*\*params) -> RouteMoasResponse - client.radar.bgp.routes.pfx2as(\*\*params) -> RoutePfx2asResponse - client.radar.bgp.routes.stats(\*\*params) -> RouteStatsResponse -- client.radar.bgp.routes.timeseries(\*\*params) -> RouteTimeseriesResponse ## Datasets diff --git a/src/cloudflare/resources/radar/bgp/routes.py b/src/cloudflare/resources/radar/bgp/routes.py index e1fcef5229a..4f993e592f5 100644 --- a/src/cloudflare/resources/radar/bgp/routes.py +++ b/src/cloudflare/resources/radar/bgp/routes.py @@ -2,8 +2,7 @@ from __future__ import annotations -from typing import Type, Union, cast -from datetime import datetime +from typing import Type, cast from typing_extensions import Literal import httpx @@ -25,11 +24,10 @@ from ...._base_client import ( make_request_options, ) -from ....types.radar.bgp import route_moas_params, route_stats_params, route_pfx2as_params, route_timeseries_params +from ....types.radar.bgp import route_moas_params, route_stats_params, route_pfx2as_params from ....types.radar.bgp.route_moas_response import RouteMoasResponse from ....types.radar.bgp.route_stats_response import RouteStatsResponse from ....types.radar.bgp.route_pfx2as_response import RoutePfx2asResponse -from ....types.radar.bgp.route_timeseries_response import RouteTimeseriesResponse __all__ = ["RoutesResource", "AsyncRoutesResource"] @@ -209,92 +207,6 @@ def stats( cast_to=cast(Type[RouteStatsResponse], ResultWrapper[RouteStatsResponse]), ) - def timeseries( - self, - *, - asn: int | NotGiven = NOT_GIVEN, - date_end: Union[str, datetime] | NotGiven = NOT_GIVEN, - date_range: Literal[ - "1d", - "2d", - "7d", - "14d", - "28d", - "12w", - "24w", - "52w", - "1dControl", - "2dControl", - "7dControl", - "14dControl", - "28dControl", - "12wControl", - "24wControl", - ] - | NotGiven = NOT_GIVEN, - date_start: Union[str, datetime] | NotGiven = NOT_GIVEN, - format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, - include_delay: bool | NotGiven = NOT_GIVEN, - location: 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, - ) -> RouteTimeseriesResponse: - """ - Gets time-series data for the announced IP space count, represented as the - number of IPv4 /24s and IPv6 /48s, for a given ASN. - - Args: - asn: Single ASN as integer. - - date_end: End of the date range (inclusive). - - date_range: Shorthand date ranges for the last X days - use when you don't need specific - start and end dates. - - date_start: Start of the date range (inclusive). - - format: Format results are returned in. - - include_delay: Include data delay meta information - - location: Location Alpha2 code. - - 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 - """ - return self._get( - "/radar/bgp/routes/timeseries", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "asn": asn, - "date_end": date_end, - "date_range": date_range, - "date_start": date_start, - "format": format, - "include_delay": include_delay, - "location": location, - }, - route_timeseries_params.RouteTimeseriesParams, - ), - post_parser=ResultWrapper[RouteTimeseriesResponse]._unwrapper, - ), - cast_to=cast(Type[RouteTimeseriesResponse], ResultWrapper[RouteTimeseriesResponse]), - ) - class AsyncRoutesResource(AsyncAPIResource): @cached_property @@ -471,92 +383,6 @@ async def stats( cast_to=cast(Type[RouteStatsResponse], ResultWrapper[RouteStatsResponse]), ) - async def timeseries( - self, - *, - asn: int | NotGiven = NOT_GIVEN, - date_end: Union[str, datetime] | NotGiven = NOT_GIVEN, - date_range: Literal[ - "1d", - "2d", - "7d", - "14d", - "28d", - "12w", - "24w", - "52w", - "1dControl", - "2dControl", - "7dControl", - "14dControl", - "28dControl", - "12wControl", - "24wControl", - ] - | NotGiven = NOT_GIVEN, - date_start: Union[str, datetime] | NotGiven = NOT_GIVEN, - format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, - include_delay: bool | NotGiven = NOT_GIVEN, - location: 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, - ) -> RouteTimeseriesResponse: - """ - Gets time-series data for the announced IP space count, represented as the - number of IPv4 /24s and IPv6 /48s, for a given ASN. - - Args: - asn: Single ASN as integer. - - date_end: End of the date range (inclusive). - - date_range: Shorthand date ranges for the last X days - use when you don't need specific - start and end dates. - - date_start: Start of the date range (inclusive). - - format: Format results are returned in. - - include_delay: Include data delay meta information - - location: Location Alpha2 code. - - 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 - """ - return await self._get( - "/radar/bgp/routes/timeseries", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "asn": asn, - "date_end": date_end, - "date_range": date_range, - "date_start": date_start, - "format": format, - "include_delay": include_delay, - "location": location, - }, - route_timeseries_params.RouteTimeseriesParams, - ), - post_parser=ResultWrapper[RouteTimeseriesResponse]._unwrapper, - ), - cast_to=cast(Type[RouteTimeseriesResponse], ResultWrapper[RouteTimeseriesResponse]), - ) - class RoutesResourceWithRawResponse: def __init__(self, routes: RoutesResource) -> None: @@ -571,9 +397,6 @@ def __init__(self, routes: RoutesResource) -> None: self.stats = to_raw_response_wrapper( routes.stats, ) - self.timeseries = to_raw_response_wrapper( - routes.timeseries, - ) class AsyncRoutesResourceWithRawResponse: @@ -589,9 +412,6 @@ def __init__(self, routes: AsyncRoutesResource) -> None: self.stats = async_to_raw_response_wrapper( routes.stats, ) - self.timeseries = async_to_raw_response_wrapper( - routes.timeseries, - ) class RoutesResourceWithStreamingResponse: @@ -607,9 +427,6 @@ def __init__(self, routes: RoutesResource) -> None: self.stats = to_streamed_response_wrapper( routes.stats, ) - self.timeseries = to_streamed_response_wrapper( - routes.timeseries, - ) class AsyncRoutesResourceWithStreamingResponse: @@ -625,6 +442,3 @@ def __init__(self, routes: AsyncRoutesResource) -> None: self.stats = async_to_streamed_response_wrapper( routes.stats, ) - self.timeseries = async_to_streamed_response_wrapper( - routes.timeseries, - ) diff --git a/src/cloudflare/types/radar/bgp/__init__.py b/src/cloudflare/types/radar/bgp/__init__.py index d1bc53367b3..bc82551b34d 100644 --- a/src/cloudflare/types/radar/bgp/__init__.py +++ b/src/cloudflare/types/radar/bgp/__init__.py @@ -10,5 +10,3 @@ from .route_stats_response import RouteStatsResponse as RouteStatsResponse from .route_pfx2as_response import RoutePfx2asResponse as RoutePfx2asResponse from .top_prefixes_response import TopPrefixesResponse as TopPrefixesResponse -from .route_timeseries_params import RouteTimeseriesParams as RouteTimeseriesParams -from .route_timeseries_response import RouteTimeseriesResponse as RouteTimeseriesResponse diff --git a/src/cloudflare/types/radar/bgp/route_timeseries_params.py b/src/cloudflare/types/radar/bgp/route_timeseries_params.py deleted file mode 100644 index 55d51e97031..00000000000 --- a/src/cloudflare/types/radar/bgp/route_timeseries_params.py +++ /dev/null @@ -1,56 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from datetime import datetime -from typing_extensions import Literal, Annotated, TypedDict - -from ...._utils import PropertyInfo - -__all__ = ["RouteTimeseriesParams"] - - -class RouteTimeseriesParams(TypedDict, total=False): - asn: int - """Single ASN as integer.""" - - date_end: Annotated[Union[str, datetime], PropertyInfo(alias="dateEnd", format="iso8601")] - """End of the date range (inclusive).""" - - date_range: Annotated[ - Literal[ - "1d", - "2d", - "7d", - "14d", - "28d", - "12w", - "24w", - "52w", - "1dControl", - "2dControl", - "7dControl", - "14dControl", - "28dControl", - "12wControl", - "24wControl", - ], - PropertyInfo(alias="dateRange"), - ] - """ - Shorthand date ranges for the last X days - use when you don't need specific - start and end dates. - """ - - date_start: Annotated[Union[str, datetime], PropertyInfo(alias="dateStart", format="iso8601")] - """Start of the date range (inclusive).""" - - format: Literal["JSON", "CSV"] - """Format results are returned in.""" - - include_delay: Annotated[bool, PropertyInfo(alias="includeDelay")] - """Include data delay meta information""" - - location: str - """Location Alpha2 code.""" diff --git a/src/cloudflare/types/radar/bgp/route_timeseries_response.py b/src/cloudflare/types/radar/bgp/route_timeseries_response.py deleted file mode 100644 index fa7506de2c5..00000000000 --- a/src/cloudflare/types/radar/bgp/route_timeseries_response.py +++ /dev/null @@ -1,42 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List -from datetime import datetime - -from pydantic import Field as FieldInfo - -from ...._models import BaseModel - -__all__ = ["RouteTimeseriesResponse", "Meta", "MetaDateRange", "SerieIPV4_24s", "SerieIPV6_48s"] - - -class MetaDateRange(BaseModel): - end_time: datetime = FieldInfo(alias="endTime") - """Adjusted end of date range.""" - - start_time: datetime = FieldInfo(alias="startTime") - """Adjusted start of date range.""" - - -class Meta(BaseModel): - date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") - - -class SerieIPV4_24s(BaseModel): - timestamps: List[datetime] - - values: List[int] - - -class SerieIPV6_48s(BaseModel): - timestamps: List[datetime] - - values: List[int] - - -class RouteTimeseriesResponse(BaseModel): - meta: Meta - - serie_ipv4_24s: SerieIPV4_24s - - serie_ipv6_48s: SerieIPV6_48s diff --git a/tests/api_resources/radar/bgp/test_routes.py b/tests/api_resources/radar/bgp/test_routes.py index aeec1f26421..fc506877a1b 100644 --- a/tests/api_resources/radar/bgp/test_routes.py +++ b/tests/api_resources/radar/bgp/test_routes.py @@ -9,12 +9,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare._utils import parse_datetime from cloudflare.types.radar.bgp import ( RouteMoasResponse, RouteStatsResponse, RoutePfx2asResponse, - RouteTimeseriesResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -128,44 +126,6 @@ def test_streaming_response_stats(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True - @parametrize - def test_method_timeseries(self, client: Cloudflare) -> None: - route = client.radar.bgp.routes.timeseries() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - def test_method_timeseries_with_all_params(self, client: Cloudflare) -> None: - route = client.radar.bgp.routes.timeseries( - asn=174, - date_end=parse_datetime("2023-09-01T11:41:33.782Z"), - date_range="7d", - date_start=parse_datetime("2023-09-01T11:41:33.782Z"), - format="JSON", - include_delay=True, - location="US", - ) - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - def test_raw_response_timeseries(self, client: Cloudflare) -> None: - response = client.radar.bgp.routes.with_raw_response.timeseries() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - route = response.parse() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - def test_streaming_response_timeseries(self, client: Cloudflare) -> None: - with client.radar.bgp.routes.with_streaming_response.timeseries() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - route = response.parse() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - assert cast(Any, response.is_closed) is True - class TestAsyncRoutes: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -274,41 +234,3 @@ async def test_streaming_response_stats(self, async_client: AsyncCloudflare) -> assert_matches_type(RouteStatsResponse, route, path=["response"]) assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_timeseries(self, async_client: AsyncCloudflare) -> None: - route = await async_client.radar.bgp.routes.timeseries() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - async def test_method_timeseries_with_all_params(self, async_client: AsyncCloudflare) -> None: - route = await async_client.radar.bgp.routes.timeseries( - asn=174, - date_end=parse_datetime("2023-09-01T11:41:33.782Z"), - date_range="7d", - date_start=parse_datetime("2023-09-01T11:41:33.782Z"), - format="JSON", - include_delay=True, - location="US", - ) - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - async def test_raw_response_timeseries(self, async_client: AsyncCloudflare) -> None: - response = await async_client.radar.bgp.routes.with_raw_response.timeseries() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - route = await response.parse() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - async def test_streaming_response_timeseries(self, async_client: AsyncCloudflare) -> None: - async with async_client.radar.bgp.routes.with_streaming_response.timeseries() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - route = await response.parse() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - assert cast(Any, response.is_closed) is True From 00f31f92c4c4a269656cc148992d5c106f4e6b72 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 10:31:49 +0000 Subject: [PATCH 183/532] feat(api): OpenAPI spec update via Stainless API (#664) --- .stats.yml | 4 +- api.md | 8 +- src/cloudflare/resources/radar/bgp/routes.py | 190 +++++++++++++++++- src/cloudflare/types/radar/bgp/__init__.py | 2 + .../radar/bgp/route_timeseries_params.py | 56 ++++++ .../radar/bgp/route_timeseries_response.py | 42 ++++ tests/api_resources/radar/bgp/test_routes.py | 78 +++++++ 7 files changed, 375 insertions(+), 5 deletions(-) create mode 100644 src/cloudflare/types/radar/bgp/route_timeseries_params.py create mode 100644 src/cloudflare/types/radar/bgp/route_timeseries_response.py diff --git a/.stats.yml b/.stats.yml index 819c2de2b35..1d93ad978cc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1318 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c9580652e64cbc56358ed166b67257a24a6079e70e390bab214e45920bba7039.yml +configured_endpoints: 1319 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d798919f06fdb766d1e047f3a387fa78bdee979130963b425176a00429b842b9.yml diff --git a/api.md b/api.md index 04a95f58489..93866067807 100644 --- a/api.md +++ b/api.md @@ -6416,7 +6416,12 @@ Methods: Types: ```python -from cloudflare.types.radar.bgp import RouteMoasResponse, RoutePfx2asResponse, RouteStatsResponse +from cloudflare.types.radar.bgp import ( + RouteMoasResponse, + RoutePfx2asResponse, + RouteStatsResponse, + RouteTimeseriesResponse, +) ``` Methods: @@ -6424,6 +6429,7 @@ Methods: - client.radar.bgp.routes.moas(\*\*params) -> RouteMoasResponse - client.radar.bgp.routes.pfx2as(\*\*params) -> RoutePfx2asResponse - client.radar.bgp.routes.stats(\*\*params) -> RouteStatsResponse +- client.radar.bgp.routes.timeseries(\*\*params) -> RouteTimeseriesResponse ## Datasets diff --git a/src/cloudflare/resources/radar/bgp/routes.py b/src/cloudflare/resources/radar/bgp/routes.py index 4f993e592f5..e1fcef5229a 100644 --- a/src/cloudflare/resources/radar/bgp/routes.py +++ b/src/cloudflare/resources/radar/bgp/routes.py @@ -2,7 +2,8 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Union, cast +from datetime import datetime from typing_extensions import Literal import httpx @@ -24,10 +25,11 @@ from ...._base_client import ( make_request_options, ) -from ....types.radar.bgp import route_moas_params, route_stats_params, route_pfx2as_params +from ....types.radar.bgp import route_moas_params, route_stats_params, route_pfx2as_params, route_timeseries_params from ....types.radar.bgp.route_moas_response import RouteMoasResponse from ....types.radar.bgp.route_stats_response import RouteStatsResponse from ....types.radar.bgp.route_pfx2as_response import RoutePfx2asResponse +from ....types.radar.bgp.route_timeseries_response import RouteTimeseriesResponse __all__ = ["RoutesResource", "AsyncRoutesResource"] @@ -207,6 +209,92 @@ def stats( cast_to=cast(Type[RouteStatsResponse], ResultWrapper[RouteStatsResponse]), ) + def timeseries( + self, + *, + asn: int | NotGiven = NOT_GIVEN, + date_end: Union[str, datetime] | NotGiven = NOT_GIVEN, + date_range: Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + | NotGiven = NOT_GIVEN, + date_start: Union[str, datetime] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + include_delay: bool | NotGiven = NOT_GIVEN, + location: 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, + ) -> RouteTimeseriesResponse: + """ + Gets time-series data for the announced IP space count, represented as the + number of IPv4 /24s and IPv6 /48s, for a given ASN. + + Args: + asn: Single ASN as integer. + + date_end: End of the date range (inclusive). + + date_range: Shorthand date ranges for the last X days - use when you don't need specific + start and end dates. + + date_start: Start of the date range (inclusive). + + format: Format results are returned in. + + include_delay: Include data delay meta information + + location: Location Alpha2 code. + + 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 + """ + return self._get( + "/radar/bgp/routes/timeseries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "asn": asn, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "include_delay": include_delay, + "location": location, + }, + route_timeseries_params.RouteTimeseriesParams, + ), + post_parser=ResultWrapper[RouteTimeseriesResponse]._unwrapper, + ), + cast_to=cast(Type[RouteTimeseriesResponse], ResultWrapper[RouteTimeseriesResponse]), + ) + class AsyncRoutesResource(AsyncAPIResource): @cached_property @@ -383,6 +471,92 @@ async def stats( cast_to=cast(Type[RouteStatsResponse], ResultWrapper[RouteStatsResponse]), ) + async def timeseries( + self, + *, + asn: int | NotGiven = NOT_GIVEN, + date_end: Union[str, datetime] | NotGiven = NOT_GIVEN, + date_range: Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + | NotGiven = NOT_GIVEN, + date_start: Union[str, datetime] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + include_delay: bool | NotGiven = NOT_GIVEN, + location: 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, + ) -> RouteTimeseriesResponse: + """ + Gets time-series data for the announced IP space count, represented as the + number of IPv4 /24s and IPv6 /48s, for a given ASN. + + Args: + asn: Single ASN as integer. + + date_end: End of the date range (inclusive). + + date_range: Shorthand date ranges for the last X days - use when you don't need specific + start and end dates. + + date_start: Start of the date range (inclusive). + + format: Format results are returned in. + + include_delay: Include data delay meta information + + location: Location Alpha2 code. + + 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 + """ + return await self._get( + "/radar/bgp/routes/timeseries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "asn": asn, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "include_delay": include_delay, + "location": location, + }, + route_timeseries_params.RouteTimeseriesParams, + ), + post_parser=ResultWrapper[RouteTimeseriesResponse]._unwrapper, + ), + cast_to=cast(Type[RouteTimeseriesResponse], ResultWrapper[RouteTimeseriesResponse]), + ) + class RoutesResourceWithRawResponse: def __init__(self, routes: RoutesResource) -> None: @@ -397,6 +571,9 @@ def __init__(self, routes: RoutesResource) -> None: self.stats = to_raw_response_wrapper( routes.stats, ) + self.timeseries = to_raw_response_wrapper( + routes.timeseries, + ) class AsyncRoutesResourceWithRawResponse: @@ -412,6 +589,9 @@ def __init__(self, routes: AsyncRoutesResource) -> None: self.stats = async_to_raw_response_wrapper( routes.stats, ) + self.timeseries = async_to_raw_response_wrapper( + routes.timeseries, + ) class RoutesResourceWithStreamingResponse: @@ -427,6 +607,9 @@ def __init__(self, routes: RoutesResource) -> None: self.stats = to_streamed_response_wrapper( routes.stats, ) + self.timeseries = to_streamed_response_wrapper( + routes.timeseries, + ) class AsyncRoutesResourceWithStreamingResponse: @@ -442,3 +625,6 @@ def __init__(self, routes: AsyncRoutesResource) -> None: self.stats = async_to_streamed_response_wrapper( routes.stats, ) + self.timeseries = async_to_streamed_response_wrapper( + routes.timeseries, + ) diff --git a/src/cloudflare/types/radar/bgp/__init__.py b/src/cloudflare/types/radar/bgp/__init__.py index bc82551b34d..d1bc53367b3 100644 --- a/src/cloudflare/types/radar/bgp/__init__.py +++ b/src/cloudflare/types/radar/bgp/__init__.py @@ -10,3 +10,5 @@ from .route_stats_response import RouteStatsResponse as RouteStatsResponse from .route_pfx2as_response import RoutePfx2asResponse as RoutePfx2asResponse from .top_prefixes_response import TopPrefixesResponse as TopPrefixesResponse +from .route_timeseries_params import RouteTimeseriesParams as RouteTimeseriesParams +from .route_timeseries_response import RouteTimeseriesResponse as RouteTimeseriesResponse diff --git a/src/cloudflare/types/radar/bgp/route_timeseries_params.py b/src/cloudflare/types/radar/bgp/route_timeseries_params.py new file mode 100644 index 00000000000..55d51e97031 --- /dev/null +++ b/src/cloudflare/types/radar/bgp/route_timeseries_params.py @@ -0,0 +1,56 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["RouteTimeseriesParams"] + + +class RouteTimeseriesParams(TypedDict, total=False): + asn: int + """Single ASN as integer.""" + + date_end: Annotated[Union[str, datetime], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ], + PropertyInfo(alias="dateRange"), + ] + """ + Shorthand date ranges for the last X days - use when you don't need specific + start and end dates. + """ + + date_start: Annotated[Union[str, datetime], PropertyInfo(alias="dateStart", format="iso8601")] + """Start of the date range (inclusive).""" + + format: Literal["JSON", "CSV"] + """Format results are returned in.""" + + include_delay: Annotated[bool, PropertyInfo(alias="includeDelay")] + """Include data delay meta information""" + + location: str + """Location Alpha2 code.""" diff --git a/src/cloudflare/types/radar/bgp/route_timeseries_response.py b/src/cloudflare/types/radar/bgp/route_timeseries_response.py new file mode 100644 index 00000000000..fa7506de2c5 --- /dev/null +++ b/src/cloudflare/types/radar/bgp/route_timeseries_response.py @@ -0,0 +1,42 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from datetime import datetime + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["RouteTimeseriesResponse", "Meta", "MetaDateRange", "SerieIPV4_24s", "SerieIPV6_48s"] + + +class MetaDateRange(BaseModel): + end_time: datetime = FieldInfo(alias="endTime") + """Adjusted end of date range.""" + + start_time: datetime = FieldInfo(alias="startTime") + """Adjusted start of date range.""" + + +class Meta(BaseModel): + date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") + + +class SerieIPV4_24s(BaseModel): + timestamps: List[datetime] + + values: List[int] + + +class SerieIPV6_48s(BaseModel): + timestamps: List[datetime] + + values: List[int] + + +class RouteTimeseriesResponse(BaseModel): + meta: Meta + + serie_ipv4_24s: SerieIPV4_24s + + serie_ipv6_48s: SerieIPV6_48s diff --git a/tests/api_resources/radar/bgp/test_routes.py b/tests/api_resources/radar/bgp/test_routes.py index fc506877a1b..aeec1f26421 100644 --- a/tests/api_resources/radar/bgp/test_routes.py +++ b/tests/api_resources/radar/bgp/test_routes.py @@ -9,10 +9,12 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime from cloudflare.types.radar.bgp import ( RouteMoasResponse, RouteStatsResponse, RoutePfx2asResponse, + RouteTimeseriesResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -126,6 +128,44 @@ def test_streaming_response_stats(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_method_timeseries(self, client: Cloudflare) -> None: + route = client.radar.bgp.routes.timeseries() + assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) + + @parametrize + def test_method_timeseries_with_all_params(self, client: Cloudflare) -> None: + route = client.radar.bgp.routes.timeseries( + asn=174, + date_end=parse_datetime("2023-09-01T11:41:33.782Z"), + date_range="7d", + date_start=parse_datetime("2023-09-01T11:41:33.782Z"), + format="JSON", + include_delay=True, + location="US", + ) + assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) + + @parametrize + def test_raw_response_timeseries(self, client: Cloudflare) -> None: + response = client.radar.bgp.routes.with_raw_response.timeseries() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) + + @parametrize + def test_streaming_response_timeseries(self, client: Cloudflare) -> None: + with client.radar.bgp.routes.with_streaming_response.timeseries() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + class TestAsyncRoutes: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -234,3 +274,41 @@ async def test_streaming_response_stats(self, async_client: AsyncCloudflare) -> assert_matches_type(RouteStatsResponse, route, path=["response"]) assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_timeseries(self, async_client: AsyncCloudflare) -> None: + route = await async_client.radar.bgp.routes.timeseries() + assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) + + @parametrize + async def test_method_timeseries_with_all_params(self, async_client: AsyncCloudflare) -> None: + route = await async_client.radar.bgp.routes.timeseries( + asn=174, + date_end=parse_datetime("2023-09-01T11:41:33.782Z"), + date_range="7d", + date_start=parse_datetime("2023-09-01T11:41:33.782Z"), + format="JSON", + include_delay=True, + location="US", + ) + assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) + + @parametrize + async def test_raw_response_timeseries(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.bgp.routes.with_raw_response.timeseries() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) + + @parametrize + async def test_streaming_response_timeseries(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.bgp.routes.with_streaming_response.timeseries() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True From ae81ac0f252834158310a28a57d2e4680e0822a2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 11:06:35 +0000 Subject: [PATCH 184/532] feat(api): OpenAPI spec update via Stainless API (#665) --- .stats.yml | 4 +- api.md | 36 ++-- .../cloudforce_one/requests/message.py | 76 +++---- .../cloudforce_one/requests/priority.py | 88 ++++---- .../cloudforce_one/requests/requests.py | 112 +++++------ src/cloudflare/resources/intel/whois.py | 14 +- src/cloudflare/resources/radar/bgp/routes.py | 190 +----------------- .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- src/cloudflare/types/radar/bgp/__init__.py | 2 - .../radar/bgp/route_timeseries_params.py | 56 ------ .../radar/bgp/route_timeseries_response.py | 42 ---- .../cloudforce_one/requests/test_message.py | 50 ++--- .../cloudforce_one/requests/test_priority.py | 50 ++--- .../cloudforce_one/test_requests.py | 82 ++++---- tests/api_resources/intel/test_whois.py | 18 +- tests/api_resources/radar/bgp/test_routes.py | 78 ------- 18 files changed, 276 insertions(+), 667 deletions(-) delete mode 100644 src/cloudflare/types/radar/bgp/route_timeseries_params.py delete mode 100644 src/cloudflare/types/radar/bgp/route_timeseries_response.py diff --git a/.stats.yml b/.stats.yml index 1d93ad978cc..d18836c9721 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d798919f06fdb766d1e047f3a387fa78bdee979130963b425176a00429b842b9.yml +configured_endpoints: 1318 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-023c801c42e5f9d2443005ad5eb1282684d36ea405dabaa5942edcf1f3e2b29f.yml diff --git a/api.md b/api.md index 93866067807..ea3404faaa0 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -6416,12 +6416,7 @@ Methods: Types: ```python -from cloudflare.types.radar.bgp import ( - RouteMoasResponse, - RoutePfx2asResponse, - RouteStatsResponse, - RouteTimeseriesResponse, -) +from cloudflare.types.radar.bgp import RouteMoasResponse, RoutePfx2asResponse, RouteStatsResponse ``` Methods: @@ -6429,7 +6424,6 @@ Methods: - client.radar.bgp.routes.moas(\*\*params) -> RouteMoasResponse - client.radar.bgp.routes.pfx2as(\*\*params) -> RoutePfx2asResponse - client.radar.bgp.routes.stats(\*\*params) -> RouteStatsResponse -- client.radar.bgp.routes.timeseries(\*\*params) -> RouteTimeseriesResponse ## Datasets @@ -7634,14 +7628,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7657,10 +7651,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7677,11 +7671,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/radar/bgp/routes.py b/src/cloudflare/resources/radar/bgp/routes.py index e1fcef5229a..4f993e592f5 100644 --- a/src/cloudflare/resources/radar/bgp/routes.py +++ b/src/cloudflare/resources/radar/bgp/routes.py @@ -2,8 +2,7 @@ from __future__ import annotations -from typing import Type, Union, cast -from datetime import datetime +from typing import Type, cast from typing_extensions import Literal import httpx @@ -25,11 +24,10 @@ from ...._base_client import ( make_request_options, ) -from ....types.radar.bgp import route_moas_params, route_stats_params, route_pfx2as_params, route_timeseries_params +from ....types.radar.bgp import route_moas_params, route_stats_params, route_pfx2as_params from ....types.radar.bgp.route_moas_response import RouteMoasResponse from ....types.radar.bgp.route_stats_response import RouteStatsResponse from ....types.radar.bgp.route_pfx2as_response import RoutePfx2asResponse -from ....types.radar.bgp.route_timeseries_response import RouteTimeseriesResponse __all__ = ["RoutesResource", "AsyncRoutesResource"] @@ -209,92 +207,6 @@ def stats( cast_to=cast(Type[RouteStatsResponse], ResultWrapper[RouteStatsResponse]), ) - def timeseries( - self, - *, - asn: int | NotGiven = NOT_GIVEN, - date_end: Union[str, datetime] | NotGiven = NOT_GIVEN, - date_range: Literal[ - "1d", - "2d", - "7d", - "14d", - "28d", - "12w", - "24w", - "52w", - "1dControl", - "2dControl", - "7dControl", - "14dControl", - "28dControl", - "12wControl", - "24wControl", - ] - | NotGiven = NOT_GIVEN, - date_start: Union[str, datetime] | NotGiven = NOT_GIVEN, - format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, - include_delay: bool | NotGiven = NOT_GIVEN, - location: 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, - ) -> RouteTimeseriesResponse: - """ - Gets time-series data for the announced IP space count, represented as the - number of IPv4 /24s and IPv6 /48s, for a given ASN. - - Args: - asn: Single ASN as integer. - - date_end: End of the date range (inclusive). - - date_range: Shorthand date ranges for the last X days - use when you don't need specific - start and end dates. - - date_start: Start of the date range (inclusive). - - format: Format results are returned in. - - include_delay: Include data delay meta information - - location: Location Alpha2 code. - - 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 - """ - return self._get( - "/radar/bgp/routes/timeseries", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "asn": asn, - "date_end": date_end, - "date_range": date_range, - "date_start": date_start, - "format": format, - "include_delay": include_delay, - "location": location, - }, - route_timeseries_params.RouteTimeseriesParams, - ), - post_parser=ResultWrapper[RouteTimeseriesResponse]._unwrapper, - ), - cast_to=cast(Type[RouteTimeseriesResponse], ResultWrapper[RouteTimeseriesResponse]), - ) - class AsyncRoutesResource(AsyncAPIResource): @cached_property @@ -471,92 +383,6 @@ async def stats( cast_to=cast(Type[RouteStatsResponse], ResultWrapper[RouteStatsResponse]), ) - async def timeseries( - self, - *, - asn: int | NotGiven = NOT_GIVEN, - date_end: Union[str, datetime] | NotGiven = NOT_GIVEN, - date_range: Literal[ - "1d", - "2d", - "7d", - "14d", - "28d", - "12w", - "24w", - "52w", - "1dControl", - "2dControl", - "7dControl", - "14dControl", - "28dControl", - "12wControl", - "24wControl", - ] - | NotGiven = NOT_GIVEN, - date_start: Union[str, datetime] | NotGiven = NOT_GIVEN, - format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, - include_delay: bool | NotGiven = NOT_GIVEN, - location: 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, - ) -> RouteTimeseriesResponse: - """ - Gets time-series data for the announced IP space count, represented as the - number of IPv4 /24s and IPv6 /48s, for a given ASN. - - Args: - asn: Single ASN as integer. - - date_end: End of the date range (inclusive). - - date_range: Shorthand date ranges for the last X days - use when you don't need specific - start and end dates. - - date_start: Start of the date range (inclusive). - - format: Format results are returned in. - - include_delay: Include data delay meta information - - location: Location Alpha2 code. - - 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 - """ - return await self._get( - "/radar/bgp/routes/timeseries", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - { - "asn": asn, - "date_end": date_end, - "date_range": date_range, - "date_start": date_start, - "format": format, - "include_delay": include_delay, - "location": location, - }, - route_timeseries_params.RouteTimeseriesParams, - ), - post_parser=ResultWrapper[RouteTimeseriesResponse]._unwrapper, - ), - cast_to=cast(Type[RouteTimeseriesResponse], ResultWrapper[RouteTimeseriesResponse]), - ) - class RoutesResourceWithRawResponse: def __init__(self, routes: RoutesResource) -> None: @@ -571,9 +397,6 @@ def __init__(self, routes: RoutesResource) -> None: self.stats = to_raw_response_wrapper( routes.stats, ) - self.timeseries = to_raw_response_wrapper( - routes.timeseries, - ) class AsyncRoutesResourceWithRawResponse: @@ -589,9 +412,6 @@ def __init__(self, routes: AsyncRoutesResource) -> None: self.stats = async_to_raw_response_wrapper( routes.stats, ) - self.timeseries = async_to_raw_response_wrapper( - routes.timeseries, - ) class RoutesResourceWithStreamingResponse: @@ -607,9 +427,6 @@ def __init__(self, routes: RoutesResource) -> None: self.stats = to_streamed_response_wrapper( routes.stats, ) - self.timeseries = to_streamed_response_wrapper( - routes.timeseries, - ) class AsyncRoutesResourceWithStreamingResponse: @@ -625,6 +442,3 @@ def __init__(self, routes: AsyncRoutesResource) -> None: self.stats = async_to_streamed_response_wrapper( routes.stats, ) - self.timeseries = async_to_streamed_response_wrapper( - routes.timeseries, - ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/radar/bgp/__init__.py b/src/cloudflare/types/radar/bgp/__init__.py index d1bc53367b3..bc82551b34d 100644 --- a/src/cloudflare/types/radar/bgp/__init__.py +++ b/src/cloudflare/types/radar/bgp/__init__.py @@ -10,5 +10,3 @@ from .route_stats_response import RouteStatsResponse as RouteStatsResponse from .route_pfx2as_response import RoutePfx2asResponse as RoutePfx2asResponse from .top_prefixes_response import TopPrefixesResponse as TopPrefixesResponse -from .route_timeseries_params import RouteTimeseriesParams as RouteTimeseriesParams -from .route_timeseries_response import RouteTimeseriesResponse as RouteTimeseriesResponse diff --git a/src/cloudflare/types/radar/bgp/route_timeseries_params.py b/src/cloudflare/types/radar/bgp/route_timeseries_params.py deleted file mode 100644 index 55d51e97031..00000000000 --- a/src/cloudflare/types/radar/bgp/route_timeseries_params.py +++ /dev/null @@ -1,56 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from datetime import datetime -from typing_extensions import Literal, Annotated, TypedDict - -from ...._utils import PropertyInfo - -__all__ = ["RouteTimeseriesParams"] - - -class RouteTimeseriesParams(TypedDict, total=False): - asn: int - """Single ASN as integer.""" - - date_end: Annotated[Union[str, datetime], PropertyInfo(alias="dateEnd", format="iso8601")] - """End of the date range (inclusive).""" - - date_range: Annotated[ - Literal[ - "1d", - "2d", - "7d", - "14d", - "28d", - "12w", - "24w", - "52w", - "1dControl", - "2dControl", - "7dControl", - "14dControl", - "28dControl", - "12wControl", - "24wControl", - ], - PropertyInfo(alias="dateRange"), - ] - """ - Shorthand date ranges for the last X days - use when you don't need specific - start and end dates. - """ - - date_start: Annotated[Union[str, datetime], PropertyInfo(alias="dateStart", format="iso8601")] - """Start of the date range (inclusive).""" - - format: Literal["JSON", "CSV"] - """Format results are returned in.""" - - include_delay: Annotated[bool, PropertyInfo(alias="includeDelay")] - """Include data delay meta information""" - - location: str - """Location Alpha2 code.""" diff --git a/src/cloudflare/types/radar/bgp/route_timeseries_response.py b/src/cloudflare/types/radar/bgp/route_timeseries_response.py deleted file mode 100644 index fa7506de2c5..00000000000 --- a/src/cloudflare/types/radar/bgp/route_timeseries_response.py +++ /dev/null @@ -1,42 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List -from datetime import datetime - -from pydantic import Field as FieldInfo - -from ...._models import BaseModel - -__all__ = ["RouteTimeseriesResponse", "Meta", "MetaDateRange", "SerieIPV4_24s", "SerieIPV6_48s"] - - -class MetaDateRange(BaseModel): - end_time: datetime = FieldInfo(alias="endTime") - """Adjusted end of date range.""" - - start_time: datetime = FieldInfo(alias="startTime") - """Adjusted start of date range.""" - - -class Meta(BaseModel): - date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") - - -class SerieIPV4_24s(BaseModel): - timestamps: List[datetime] - - values: List[int] - - -class SerieIPV6_48s(BaseModel): - timestamps: List[datetime] - - values: List[int] - - -class RouteTimeseriesResponse(BaseModel): - meta: Meta - - serie_ipv4_24s: SerieIPV4_24s - - serie_ipv6_48s: SerieIPV6_48s diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/radar/bgp/test_routes.py b/tests/api_resources/radar/bgp/test_routes.py index aeec1f26421..fc506877a1b 100644 --- a/tests/api_resources/radar/bgp/test_routes.py +++ b/tests/api_resources/radar/bgp/test_routes.py @@ -9,12 +9,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare._utils import parse_datetime from cloudflare.types.radar.bgp import ( RouteMoasResponse, RouteStatsResponse, RoutePfx2asResponse, - RouteTimeseriesResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -128,44 +126,6 @@ def test_streaming_response_stats(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True - @parametrize - def test_method_timeseries(self, client: Cloudflare) -> None: - route = client.radar.bgp.routes.timeseries() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - def test_method_timeseries_with_all_params(self, client: Cloudflare) -> None: - route = client.radar.bgp.routes.timeseries( - asn=174, - date_end=parse_datetime("2023-09-01T11:41:33.782Z"), - date_range="7d", - date_start=parse_datetime("2023-09-01T11:41:33.782Z"), - format="JSON", - include_delay=True, - location="US", - ) - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - def test_raw_response_timeseries(self, client: Cloudflare) -> None: - response = client.radar.bgp.routes.with_raw_response.timeseries() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - route = response.parse() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - def test_streaming_response_timeseries(self, client: Cloudflare) -> None: - with client.radar.bgp.routes.with_streaming_response.timeseries() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - route = response.parse() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - assert cast(Any, response.is_closed) is True - class TestAsyncRoutes: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -274,41 +234,3 @@ async def test_streaming_response_stats(self, async_client: AsyncCloudflare) -> assert_matches_type(RouteStatsResponse, route, path=["response"]) assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_timeseries(self, async_client: AsyncCloudflare) -> None: - route = await async_client.radar.bgp.routes.timeseries() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - async def test_method_timeseries_with_all_params(self, async_client: AsyncCloudflare) -> None: - route = await async_client.radar.bgp.routes.timeseries( - asn=174, - date_end=parse_datetime("2023-09-01T11:41:33.782Z"), - date_range="7d", - date_start=parse_datetime("2023-09-01T11:41:33.782Z"), - format="JSON", - include_delay=True, - location="US", - ) - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - async def test_raw_response_timeseries(self, async_client: AsyncCloudflare) -> None: - response = await async_client.radar.bgp.routes.with_raw_response.timeseries() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - route = await response.parse() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - @parametrize - async def test_streaming_response_timeseries(self, async_client: AsyncCloudflare) -> None: - async with async_client.radar.bgp.routes.with_streaming_response.timeseries() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - route = await response.parse() - assert_matches_type(RouteTimeseriesResponse, route, path=["response"]) - - assert cast(Any, response.is_closed) is True From 8ba10d9100d34c99f75dc2d1c5b3f8e3390d4004 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 13:44:47 +0000 Subject: [PATCH 185/532] feat(api): OpenAPI spec update via Stainless API (#666) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index d18836c9721..b6fc8e2ddb8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1318 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-023c801c42e5f9d2443005ad5eb1282684d36ea405dabaa5942edcf1f3e2b29f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ad688c70f1586b01810d8388213f79137ea8d7158d069b883fa4a9fefee01a2a.yml diff --git a/api.md b/api.md index ea3404faaa0..04a95f58489 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7628,14 +7628,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7651,10 +7651,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7671,11 +7671,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 4cf63cd98e74081529126eef88c5aa7af7b49c29 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 03:02:55 +0000 Subject: [PATCH 186/532] feat(api): update via SDK Studio (#667) --- .stats.yml | 4 +- api.md | 40 ++- scripts/bootstrap | 2 +- .../cloudforce_one/requests/message.py | 76 ++--- .../cloudforce_one/requests/priority.py | 88 +++--- .../cloudforce_one/requests/requests.py | 112 +++----- src/cloudflare/resources/intel/whois.py | 14 +- .../resources/radar/bgp/__init__.py | 14 + src/cloudflare/resources/radar/bgp/bgp.py | 32 +++ src/cloudflare/resources/radar/bgp/ips.py | 267 ++++++++++++++++++ .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- src/cloudflare/types/radar/bgp/__init__.py | 2 + .../types/radar/bgp/ip_timeseries_params.py | 59 ++++ .../types/radar/bgp/ip_timeseries_response.py | 46 +++ .../cloudforce_one/requests/test_message.py | 50 ++-- .../cloudforce_one/requests/test_priority.py | 50 ++-- .../cloudforce_one/test_requests.py | 82 +++--- tests/api_resources/intel/test_whois.py | 18 +- tests/api_resources/radar/bgp/test_ips.py | 101 +++++++ 21 files changed, 807 insertions(+), 295 deletions(-) create mode 100644 src/cloudflare/resources/radar/bgp/ips.py create mode 100644 src/cloudflare/types/radar/bgp/ip_timeseries_params.py create mode 100644 src/cloudflare/types/radar/bgp/ip_timeseries_response.py create mode 100644 tests/api_resources/radar/bgp/test_ips.py diff --git a/.stats.yml b/.stats.yml index b6fc8e2ddb8..0efb49b675a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1318 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ad688c70f1586b01810d8388213f79137ea8d7158d069b883fa4a9fefee01a2a.yml +configured_endpoints: 1319 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-79996c6f0ba6a97a922883584d2308844300e95b758ed40ac16fb6db09b3c5fa.yml diff --git a/api.md b/api.md index 04a95f58489..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -6425,6 +6425,18 @@ Methods: - client.radar.bgp.routes.pfx2as(\*\*params) -> RoutePfx2asResponse - client.radar.bgp.routes.stats(\*\*params) -> RouteStatsResponse +### IPs + +Types: + +```python +from cloudflare.types.radar.bgp import IPTimeseriesResponse +``` + +Methods: + +- client.radar.bgp.ips.timeseries(\*\*params) -> IPTimeseriesResponse + ## Datasets Types: @@ -7628,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7651,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7671,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/scripts/bootstrap b/scripts/bootstrap index 29df07e77be..8c5c60eba34 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -16,4 +16,4 @@ echo "==> Installing Python dependencies…" # experimental uv support makes installations significantly faster rye config --set-bool behavior.use-uv=true -rye sync +rye sync --all-features diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/radar/bgp/__init__.py b/src/cloudflare/resources/radar/bgp/__init__.py index b143abf6005..1e54970bfb0 100644 --- a/src/cloudflare/resources/radar/bgp/__init__.py +++ b/src/cloudflare/resources/radar/bgp/__init__.py @@ -8,6 +8,14 @@ BGPResourceWithStreamingResponse, AsyncBGPResourceWithStreamingResponse, ) +from .ips import ( + IPsResource, + AsyncIPsResource, + IPsResourceWithRawResponse, + AsyncIPsResourceWithRawResponse, + IPsResourceWithStreamingResponse, + AsyncIPsResourceWithStreamingResponse, +) from .top import ( TopResource, AsyncTopResource, @@ -66,6 +74,12 @@ "AsyncRoutesResourceWithRawResponse", "RoutesResourceWithStreamingResponse", "AsyncRoutesResourceWithStreamingResponse", + "IPsResource", + "AsyncIPsResource", + "IPsResourceWithRawResponse", + "AsyncIPsResourceWithRawResponse", + "IPsResourceWithStreamingResponse", + "AsyncIPsResourceWithStreamingResponse", "BGPResource", "AsyncBGPResource", "BGPResourceWithRawResponse", diff --git a/src/cloudflare/resources/radar/bgp/bgp.py b/src/cloudflare/resources/radar/bgp/bgp.py index 1db4a996c30..0b0c2aa8a06 100644 --- a/src/cloudflare/resources/radar/bgp/bgp.py +++ b/src/cloudflare/resources/radar/bgp/bgp.py @@ -8,6 +8,14 @@ import httpx +from .ips import ( + IPsResource, + AsyncIPsResource, + IPsResourceWithRawResponse, + AsyncIPsResourceWithRawResponse, + IPsResourceWithStreamingResponse, + AsyncIPsResourceWithStreamingResponse, +) from .top import ( TopResource, AsyncTopResource, @@ -83,6 +91,10 @@ def hijacks(self) -> HijacksResource: def routes(self) -> RoutesResource: return RoutesResource(self._client) + @cached_property + def ips(self) -> IPsResource: + return IPsResource(self._client) + @cached_property def with_raw_response(self) -> BGPResourceWithRawResponse: return BGPResourceWithRawResponse(self) @@ -212,6 +224,10 @@ def hijacks(self) -> AsyncHijacksResource: def routes(self) -> AsyncRoutesResource: return AsyncRoutesResource(self._client) + @cached_property + def ips(self) -> AsyncIPsResource: + return AsyncIPsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncBGPResourceWithRawResponse: return AsyncBGPResourceWithRawResponse(self) @@ -348,6 +364,10 @@ def hijacks(self) -> HijacksResourceWithRawResponse: def routes(self) -> RoutesResourceWithRawResponse: return RoutesResourceWithRawResponse(self._bgp.routes) + @cached_property + def ips(self) -> IPsResourceWithRawResponse: + return IPsResourceWithRawResponse(self._bgp.ips) + class AsyncBGPResourceWithRawResponse: def __init__(self, bgp: AsyncBGPResource) -> None: @@ -373,6 +393,10 @@ def hijacks(self) -> AsyncHijacksResourceWithRawResponse: def routes(self) -> AsyncRoutesResourceWithRawResponse: return AsyncRoutesResourceWithRawResponse(self._bgp.routes) + @cached_property + def ips(self) -> AsyncIPsResourceWithRawResponse: + return AsyncIPsResourceWithRawResponse(self._bgp.ips) + class BGPResourceWithStreamingResponse: def __init__(self, bgp: BGPResource) -> None: @@ -398,6 +422,10 @@ def hijacks(self) -> HijacksResourceWithStreamingResponse: def routes(self) -> RoutesResourceWithStreamingResponse: return RoutesResourceWithStreamingResponse(self._bgp.routes) + @cached_property + def ips(self) -> IPsResourceWithStreamingResponse: + return IPsResourceWithStreamingResponse(self._bgp.ips) + class AsyncBGPResourceWithStreamingResponse: def __init__(self, bgp: AsyncBGPResource) -> None: @@ -422,3 +450,7 @@ def hijacks(self) -> AsyncHijacksResourceWithStreamingResponse: @cached_property def routes(self) -> AsyncRoutesResourceWithStreamingResponse: return AsyncRoutesResourceWithStreamingResponse(self._bgp.routes) + + @cached_property + def ips(self) -> AsyncIPsResourceWithStreamingResponse: + return AsyncIPsResourceWithStreamingResponse(self._bgp.ips) diff --git a/src/cloudflare/resources/radar/bgp/ips.py b/src/cloudflare/resources/radar/bgp/ips.py new file mode 100644 index 00000000000..62cfdacf32a --- /dev/null +++ b/src/cloudflare/resources/radar/bgp/ips.py @@ -0,0 +1,267 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Union, cast +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ...._base_client import ( + make_request_options, +) +from ....types.radar.bgp import ip_timeseries_params +from ....types.radar.bgp.ip_timeseries_response import IPTimeseriesResponse + +__all__ = ["IPsResource", "AsyncIPsResource"] + + +class IPsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> IPsResourceWithRawResponse: + return IPsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IPsResourceWithStreamingResponse: + return IPsResourceWithStreamingResponse(self) + + def timeseries( + self, + *, + asn: str | NotGiven = NOT_GIVEN, + date_end: Union[str, datetime] | NotGiven = NOT_GIVEN, + date_range: Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + | NotGiven = NOT_GIVEN, + date_start: Union[str, datetime] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + include_delay: bool | NotGiven = NOT_GIVEN, + location: str | NotGiven = NOT_GIVEN, + name: List[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, + ) -> IPTimeseriesResponse: + """ + Gets time-series data for the announced IP space count, represented as the + number of IPv4 /24s and IPv6 /48s, for a given ASN. + + Args: + asn: Comma separated list of ASNs. + + date_end: End of the date range (inclusive). + + date_range: Shorthand date ranges for the last X days - use when you don't need specific + start and end dates. + + date_start: Start of the date range (inclusive). + + format: Format results are returned in. + + include_delay: Include data delay meta information + + location: Comma separated list of locations. + + name: Array of names that will be used to name the series in responses. + + 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 + """ + return self._get( + "/radar/bgp/ips/timeseries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "asn": asn, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "include_delay": include_delay, + "location": location, + "name": name, + }, + ip_timeseries_params.IPTimeseriesParams, + ), + post_parser=ResultWrapper[IPTimeseriesResponse]._unwrapper, + ), + cast_to=cast(Type[IPTimeseriesResponse], ResultWrapper[IPTimeseriesResponse]), + ) + + +class AsyncIPsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIPsResourceWithRawResponse: + return AsyncIPsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIPsResourceWithStreamingResponse: + return AsyncIPsResourceWithStreamingResponse(self) + + async def timeseries( + self, + *, + asn: str | NotGiven = NOT_GIVEN, + date_end: Union[str, datetime] | NotGiven = NOT_GIVEN, + date_range: Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + | NotGiven = NOT_GIVEN, + date_start: Union[str, datetime] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + include_delay: bool | NotGiven = NOT_GIVEN, + location: str | NotGiven = NOT_GIVEN, + name: List[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, + ) -> IPTimeseriesResponse: + """ + Gets time-series data for the announced IP space count, represented as the + number of IPv4 /24s and IPv6 /48s, for a given ASN. + + Args: + asn: Comma separated list of ASNs. + + date_end: End of the date range (inclusive). + + date_range: Shorthand date ranges for the last X days - use when you don't need specific + start and end dates. + + date_start: Start of the date range (inclusive). + + format: Format results are returned in. + + include_delay: Include data delay meta information + + location: Comma separated list of locations. + + name: Array of names that will be used to name the series in responses. + + 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 + """ + return await self._get( + "/radar/bgp/ips/timeseries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "asn": asn, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "include_delay": include_delay, + "location": location, + "name": name, + }, + ip_timeseries_params.IPTimeseriesParams, + ), + post_parser=ResultWrapper[IPTimeseriesResponse]._unwrapper, + ), + cast_to=cast(Type[IPTimeseriesResponse], ResultWrapper[IPTimeseriesResponse]), + ) + + +class IPsResourceWithRawResponse: + def __init__(self, ips: IPsResource) -> None: + self._ips = ips + + self.timeseries = to_raw_response_wrapper( + ips.timeseries, + ) + + +class AsyncIPsResourceWithRawResponse: + def __init__(self, ips: AsyncIPsResource) -> None: + self._ips = ips + + self.timeseries = async_to_raw_response_wrapper( + ips.timeseries, + ) + + +class IPsResourceWithStreamingResponse: + def __init__(self, ips: IPsResource) -> None: + self._ips = ips + + self.timeseries = to_streamed_response_wrapper( + ips.timeseries, + ) + + +class AsyncIPsResourceWithStreamingResponse: + def __init__(self, ips: AsyncIPsResource) -> None: + self._ips = ips + + self.timeseries = async_to_streamed_response_wrapper( + ips.timeseries, + ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/radar/bgp/__init__.py b/src/cloudflare/types/radar/bgp/__init__.py index bc82551b34d..abf4e584e4d 100644 --- a/src/cloudflare/types/radar/bgp/__init__.py +++ b/src/cloudflare/types/radar/bgp/__init__.py @@ -7,6 +7,8 @@ from .route_moas_response import RouteMoasResponse as RouteMoasResponse from .route_pfx2as_params import RoutePfx2asParams as RoutePfx2asParams from .top_prefixes_params import TopPrefixesParams as TopPrefixesParams +from .ip_timeseries_params import IPTimeseriesParams as IPTimeseriesParams from .route_stats_response import RouteStatsResponse as RouteStatsResponse from .route_pfx2as_response import RoutePfx2asResponse as RoutePfx2asResponse from .top_prefixes_response import TopPrefixesResponse as TopPrefixesResponse +from .ip_timeseries_response import IPTimeseriesResponse as IPTimeseriesResponse diff --git a/src/cloudflare/types/radar/bgp/ip_timeseries_params.py b/src/cloudflare/types/radar/bgp/ip_timeseries_params.py new file mode 100644 index 00000000000..64d069dcb49 --- /dev/null +++ b/src/cloudflare/types/radar/bgp/ip_timeseries_params.py @@ -0,0 +1,59 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["IPTimeseriesParams"] + + +class IPTimeseriesParams(TypedDict, total=False): + asn: str + """Comma separated list of ASNs.""" + + date_end: Annotated[Union[str, datetime], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ], + PropertyInfo(alias="dateRange"), + ] + """ + Shorthand date ranges for the last X days - use when you don't need specific + start and end dates. + """ + + date_start: Annotated[Union[str, datetime], PropertyInfo(alias="dateStart", format="iso8601")] + """Start of the date range (inclusive).""" + + format: Literal["JSON", "CSV"] + """Format results are returned in.""" + + include_delay: Annotated[bool, PropertyInfo(alias="includeDelay")] + """Include data delay meta information""" + + location: str + """Comma separated list of locations.""" + + name: List[str] + """Array of names that will be used to name the series in responses.""" diff --git a/src/cloudflare/types/radar/bgp/ip_timeseries_response.py b/src/cloudflare/types/radar/bgp/ip_timeseries_response.py new file mode 100644 index 00000000000..aeff238cfe0 --- /dev/null +++ b/src/cloudflare/types/radar/bgp/ip_timeseries_response.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from datetime import datetime + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["IPTimeseriesResponse", "Meta", "MetaDateRange", "Serie174", "SerieCn"] + + +class MetaDateRange(BaseModel): + end_time: datetime = FieldInfo(alias="endTime") + """Adjusted end of date range.""" + + start_time: datetime = FieldInfo(alias="startTime") + """Adjusted start of date range.""" + + +class Meta(BaseModel): + date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") + + +class Serie174(BaseModel): + ipv4: List[str] + + ipv6: List[str] + + timestamps: List[datetime] + + +class SerieCn(BaseModel): + ipv4: List[str] + + ipv6: List[str] + + timestamps: List[datetime] + + +class IPTimeseriesResponse(BaseModel): + meta: Meta + + serie_174: Serie174 + + serie_cn: SerieCn diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/radar/bgp/test_ips.py b/tests/api_resources/radar/bgp/test_ips.py new file mode 100644 index 00000000000..d8438d9d709 --- /dev/null +++ b/tests/api_resources/radar/bgp/test_ips.py @@ -0,0 +1,101 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.radar.bgp import IPTimeseriesResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestIPs: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_timeseries(self, client: Cloudflare) -> None: + ip = client.radar.bgp.ips.timeseries() + assert_matches_type(IPTimeseriesResponse, ip, path=["response"]) + + @parametrize + def test_method_timeseries_with_all_params(self, client: Cloudflare) -> None: + ip = client.radar.bgp.ips.timeseries( + asn="174,7922", + date_end=parse_datetime("2023-09-01T11:41:33.782Z"), + date_range="7d", + date_start=parse_datetime("2023-09-01T11:41:33.782Z"), + format="JSON", + include_delay=True, + location="US,CA", + name=["string", "string", "string"], + ) + assert_matches_type(IPTimeseriesResponse, ip, path=["response"]) + + @parametrize + def test_raw_response_timeseries(self, client: Cloudflare) -> None: + response = client.radar.bgp.ips.with_raw_response.timeseries() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip = response.parse() + assert_matches_type(IPTimeseriesResponse, ip, path=["response"]) + + @parametrize + def test_streaming_response_timeseries(self, client: Cloudflare) -> None: + with client.radar.bgp.ips.with_streaming_response.timeseries() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip = response.parse() + assert_matches_type(IPTimeseriesResponse, ip, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncIPs: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_timeseries(self, async_client: AsyncCloudflare) -> None: + ip = await async_client.radar.bgp.ips.timeseries() + assert_matches_type(IPTimeseriesResponse, ip, path=["response"]) + + @parametrize + async def test_method_timeseries_with_all_params(self, async_client: AsyncCloudflare) -> None: + ip = await async_client.radar.bgp.ips.timeseries( + asn="174,7922", + date_end=parse_datetime("2023-09-01T11:41:33.782Z"), + date_range="7d", + date_start=parse_datetime("2023-09-01T11:41:33.782Z"), + format="JSON", + include_delay=True, + location="US,CA", + name=["string", "string", "string"], + ) + assert_matches_type(IPTimeseriesResponse, ip, path=["response"]) + + @parametrize + async def test_raw_response_timeseries(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.bgp.ips.with_raw_response.timeseries() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip = await response.parse() + assert_matches_type(IPTimeseriesResponse, ip, path=["response"]) + + @parametrize + async def test_streaming_response_timeseries(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.bgp.ips.with_streaming_response.timeseries() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip = await response.parse() + assert_matches_type(IPTimeseriesResponse, ip, path=["response"]) + + assert cast(Any, response.is_closed) is True From 1f99285ac46577c1ce237ebf7012db62fba790bd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 07:34:02 +0000 Subject: [PATCH 187/532] feat(api): OpenAPI spec update via Stainless API (#668) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0efb49b675a..0f994354e8c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-79996c6f0ba6a97a922883584d2308844300e95b758ed40ac16fb6db09b3c5fa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7bbd1bdf3676605206d203a379ec552e90d33f796103fce96e4498944556d9b7.yml From 767d93704e86123243d6375bac5db4b2d797592b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 08:37:23 +0000 Subject: [PATCH 188/532] feat(api): OpenAPI spec update via Stainless API (#669) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0f994354e8c..a3bf03281f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7bbd1bdf3676605206d203a379ec552e90d33f796103fce96e4498944556d9b7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2f8f209261c514d276f522d14e6fdd1221bfe1f3fee621ea3244ba5fecc255c9.yml diff --git a/api.md b/api.md index 03a403900af..cb3fbfd2000 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 12a22339c62535c815cdf5e41246562bcdbffd10 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 08:43:51 +0000 Subject: [PATCH 189/532] feat(api): OpenAPI spec update via Stainless API (#670) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a3bf03281f7..f3885076e20 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2f8f209261c514d276f522d14e6fdd1221bfe1f3fee621ea3244ba5fecc255c9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fedb743a7cc56087e6e614208f7ab09e4f1ca78e1b95eb987f6e006741d9802a.yml From 1285395535ee2da6cb6aca92ae52fe2aa66f33ce Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 09:06:52 +0000 Subject: [PATCH 190/532] feat(api): OpenAPI spec update via Stainless API (#671) --- .stats.yml | 2 +- .../resources/ai_gateway/ai_gateway.py | 39 +++---- .../ai_gateway/ai_gateway_create_params.py | 11 +- .../ai_gateway/ai_gateway_create_response.py | 5 +- .../ai_gateway/ai_gateway_delete_response.py | 5 +- .../ai_gateway/ai_gateway_get_response.py | 5 +- .../ai_gateway/ai_gateway_list_response.py | 5 +- .../ai_gateway/ai_gateway_update_params.py | 11 +- .../ai_gateway/ai_gateway_update_response.py | 5 +- tests/api_resources/test_ai_gateway.py | 110 +++++++++--------- 10 files changed, 100 insertions(+), 98 deletions(-) diff --git a/.stats.yml b/.stats.yml index f3885076e20..8832edc35e8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fedb743a7cc56087e6e614208f7ab09e4f1ca78e1b95eb987f6e006741d9802a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96d7933e4fccd37e679b7a53a68227f3e414a66a1806491333f23b50d9ed2421.yml diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 76774aed510..2fc5cfcef74 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -2,7 +2,8 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast +from typing_extensions import Literal import httpx @@ -62,11 +63,11 @@ def create( account_id: str, id: str, cache_invalidate_on_update: bool, - cache_ttl: int, + cache_ttl: Optional[int], collect_logs: bool, - rate_limiting_interval: int | NotGiven = NOT_GIVEN, - rate_limiting_limit: int | NotGiven = NOT_GIVEN, - rate_limiting_technique: str | NotGiven = NOT_GIVEN, + rate_limiting_interval: Optional[int], + rate_limiting_limit: Optional[int], + rate_limiting_technique: Literal["fixed", "sliding"], # 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, @@ -120,11 +121,11 @@ def update( *, account_id: str, cache_invalidate_on_update: bool, - cache_ttl: int, + cache_ttl: Optional[int], collect_logs: bool, - rate_limiting_interval: int | NotGiven = NOT_GIVEN, - rate_limiting_limit: int | NotGiven = NOT_GIVEN, - rate_limiting_technique: str | NotGiven = NOT_GIVEN, + rate_limiting_interval: Optional[int], + rate_limiting_limit: Optional[int], + rate_limiting_technique: Literal["fixed", "sliding"], # 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, @@ -243,8 +244,6 @@ def delete( Delete a Gateway Args: - id: gateway id - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -331,11 +330,11 @@ async def create( account_id: str, id: str, cache_invalidate_on_update: bool, - cache_ttl: int, + cache_ttl: Optional[int], collect_logs: bool, - rate_limiting_interval: int | NotGiven = NOT_GIVEN, - rate_limiting_limit: int | NotGiven = NOT_GIVEN, - rate_limiting_technique: str | NotGiven = NOT_GIVEN, + rate_limiting_interval: Optional[int], + rate_limiting_limit: Optional[int], + rate_limiting_technique: Literal["fixed", "sliding"], # 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, @@ -389,11 +388,11 @@ async def update( *, account_id: str, cache_invalidate_on_update: bool, - cache_ttl: int, + cache_ttl: Optional[int], collect_logs: bool, - rate_limiting_interval: int | NotGiven = NOT_GIVEN, - rate_limiting_limit: int | NotGiven = NOT_GIVEN, - rate_limiting_technique: str | NotGiven = NOT_GIVEN, + rate_limiting_interval: Optional[int], + rate_limiting_limit: Optional[int], + rate_limiting_technique: Literal["fixed", "sliding"], # 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, @@ -512,8 +511,6 @@ async def delete( Delete a Gateway Args: - id: gateway id - extra_headers: Send extra headers extra_query: Add additional query parameters to the request diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py index 876aa2295cc..666a25e174e 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py @@ -2,7 +2,8 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing import Optional +from typing_extensions import Literal, Required, TypedDict __all__ = ["AIGatewayCreateParams"] @@ -15,12 +16,12 @@ class AIGatewayCreateParams(TypedDict, total=False): cache_invalidate_on_update: Required[bool] - cache_ttl: Required[int] + cache_ttl: Required[Optional[int]] collect_logs: Required[bool] - rate_limiting_interval: int + rate_limiting_interval: Required[Optional[int]] - rate_limiting_limit: int + rate_limiting_limit: Required[Optional[int]] - rate_limiting_technique: str + rate_limiting_technique: Required[Literal["fixed", "sliding"]] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py index 79833ca2751..0b9b7af0175 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py @@ -2,6 +2,7 @@ from typing import Optional from datetime import datetime +from typing_extensions import Literal from ..._models import BaseModel @@ -14,7 +15,7 @@ class Task(BaseModel): cache_invalidate_on_update: bool - cache_ttl: int + cache_ttl: Optional[int] = None collect_logs: bool @@ -26,7 +27,7 @@ class Task(BaseModel): rate_limiting_limit: Optional[int] = None - rate_limiting_technique: Optional[str] = None + rate_limiting_technique: Literal["fixed", "sliding"] class AIGatewayCreateResponse(BaseModel): diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py index a4968de542a..e66ae46e886 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py @@ -2,6 +2,7 @@ from typing import Optional from datetime import datetime +from typing_extensions import Literal from ..._models import BaseModel @@ -14,7 +15,7 @@ class AIGatewayDeleteResponse(BaseModel): cache_invalidate_on_update: bool - cache_ttl: int + cache_ttl: Optional[int] = None collect_logs: bool @@ -26,4 +27,4 @@ class AIGatewayDeleteResponse(BaseModel): rate_limiting_limit: Optional[int] = None - rate_limiting_technique: Optional[str] = None + rate_limiting_technique: Literal["fixed", "sliding"] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py index 7718bd50b46..d62e61d19b2 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py @@ -2,6 +2,7 @@ from typing import Optional from datetime import datetime +from typing_extensions import Literal from ..._models import BaseModel @@ -14,7 +15,7 @@ class AIGatewayGetResponse(BaseModel): cache_invalidate_on_update: bool - cache_ttl: int + cache_ttl: Optional[int] = None collect_logs: bool @@ -26,4 +27,4 @@ class AIGatewayGetResponse(BaseModel): rate_limiting_limit: Optional[int] = None - rate_limiting_technique: Optional[str] = None + rate_limiting_technique: Literal["fixed", "sliding"] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py index eab99a61793..bd4a36e0bfb 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py @@ -2,6 +2,7 @@ from typing import Optional from datetime import datetime +from typing_extensions import Literal from ..._models import BaseModel @@ -14,7 +15,7 @@ class AIGatewayListResponse(BaseModel): cache_invalidate_on_update: bool - cache_ttl: int + cache_ttl: Optional[int] = None collect_logs: bool @@ -26,4 +27,4 @@ class AIGatewayListResponse(BaseModel): rate_limiting_limit: Optional[int] = None - rate_limiting_technique: Optional[str] = None + rate_limiting_technique: Literal["fixed", "sliding"] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py index df3676b3b77..05588bd7cf3 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py @@ -2,7 +2,8 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing import Optional +from typing_extensions import Literal, Required, TypedDict __all__ = ["AIGatewayUpdateParams"] @@ -12,12 +13,12 @@ class AIGatewayUpdateParams(TypedDict, total=False): cache_invalidate_on_update: Required[bool] - cache_ttl: Required[int] + cache_ttl: Required[Optional[int]] collect_logs: Required[bool] - rate_limiting_interval: int + rate_limiting_interval: Required[Optional[int]] - rate_limiting_limit: int + rate_limiting_limit: Required[Optional[int]] - rate_limiting_technique: str + rate_limiting_technique: Required[Literal["fixed", "sliding"]] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py index d0741678568..f07218099b5 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py @@ -2,6 +2,7 @@ from typing import Optional from datetime import datetime +from typing_extensions import Literal from ..._models import BaseModel @@ -14,7 +15,7 @@ class AIGatewayUpdateResponse(BaseModel): cache_invalidate_on_update: bool - cache_ttl: int + cache_ttl: Optional[int] = None collect_logs: bool @@ -26,4 +27,4 @@ class AIGatewayUpdateResponse(BaseModel): rate_limiting_limit: Optional[int] = None - rate_limiting_technique: Optional[str] = None + rate_limiting_technique: Literal["fixed", "sliding"] diff --git a/tests/api_resources/test_ai_gateway.py b/tests/api_resources/test_ai_gateway.py index 53a7a8ddee2..836bd4a6bbb 100644 --- a/tests/api_resources/test_ai_gateway.py +++ b/tests/api_resources/test_ai_gateway.py @@ -26,17 +26,6 @@ class TestAIGateway: @parametrize def test_method_create(self, client: Cloudflare) -> None: - ai_gateway = client.ai_gateway.create( - account_id="0d37909e38d3e99c29fa2cd343ac421a", - id="my-gateway", - cache_invalidate_on_update=True, - cache_ttl=0, - collect_logs=True, - ) - assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", id="my-gateway", @@ -45,7 +34,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: collect_logs=True, rate_limiting_interval=0, rate_limiting_limit=0, - rate_limiting_technique="string", + rate_limiting_technique="fixed", ) assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"]) @@ -57,6 +46,9 @@ def test_raw_response_create(self, client: Cloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) assert response.is_closed is True @@ -72,6 +64,9 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -90,21 +85,13 @@ def test_path_params_create(self, client: Cloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) @parametrize def test_method_update(self, client: Cloudflare) -> None: - ai_gateway = client.ai_gateway.update( - "my-gateway", - account_id="0d37909e38d3e99c29fa2cd343ac421a", - cache_invalidate_on_update=True, - cache_ttl=0, - collect_logs=True, - ) - assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"]) - - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.update( "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", @@ -113,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: collect_logs=True, rate_limiting_interval=0, rate_limiting_limit=0, - rate_limiting_technique="string", + rate_limiting_technique="fixed", ) assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"]) @@ -125,6 +112,9 @@ def test_raw_response_update(self, client: Cloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) assert response.is_closed is True @@ -140,6 +130,9 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -158,6 +151,9 @@ def test_path_params_update(self, client: Cloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -167,6 +163,9 @@ def test_path_params_update(self, client: Cloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) @parametrize @@ -221,7 +220,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: @parametrize def test_method_delete(self, client: Cloudflare) -> None: ai_gateway = client.ai_gateway.delete( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"]) @@ -229,7 +228,7 @@ def test_method_delete(self, client: Cloudflare) -> None: @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.ai_gateway.with_raw_response.delete( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) @@ -241,7 +240,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.ai_gateway.with_streaming_response.delete( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) as response: assert not response.is_closed @@ -256,7 +255,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: 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.ai_gateway.with_raw_response.delete( - "my-gateway", + "string", account_id="", ) @@ -320,17 +319,6 @@ class TestAsyncAIGateway: @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: - ai_gateway = await async_client.ai_gateway.create( - account_id="0d37909e38d3e99c29fa2cd343ac421a", - id="my-gateway", - cache_invalidate_on_update=True, - cache_ttl=0, - collect_logs=True, - ) - assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.create( account_id="0d37909e38d3e99c29fa2cd343ac421a", id="my-gateway", @@ -339,7 +327,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare collect_logs=True, rate_limiting_interval=0, rate_limiting_limit=0, - rate_limiting_technique="string", + rate_limiting_technique="fixed", ) assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"]) @@ -351,6 +339,9 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) assert response.is_closed is True @@ -366,6 +357,9 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -384,21 +378,13 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: - ai_gateway = await async_client.ai_gateway.update( - "my-gateway", - account_id="0d37909e38d3e99c29fa2cd343ac421a", - cache_invalidate_on_update=True, - cache_ttl=0, - collect_logs=True, - ) - assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"]) - - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.update( "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", @@ -407,7 +393,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare collect_logs=True, rate_limiting_interval=0, rate_limiting_limit=0, - rate_limiting_technique="string", + rate_limiting_technique="fixed", ) assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"]) @@ -419,6 +405,9 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) assert response.is_closed is True @@ -434,6 +423,9 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -452,6 +444,9 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -461,6 +456,9 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, + rate_limiting_interval=0, + rate_limiting_limit=0, + rate_limiting_technique="fixed", ) @parametrize @@ -515,7 +513,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ai_gateway = await async_client.ai_gateway.delete( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"]) @@ -523,7 +521,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.ai_gateway.with_raw_response.delete( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) @@ -535,7 +533,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.ai_gateway.with_streaming_response.delete( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) as response: assert not response.is_closed @@ -550,7 +548,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> 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.ai_gateway.with_raw_response.delete( - "my-gateway", + "string", account_id="", ) From fa43c7259c174836048f4e5e51699625e7dcc56a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 09:46:11 +0000 Subject: [PATCH 191/532] feat(api): OpenAPI spec update via Stainless API (#672) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8832edc35e8..c33ca4fc747 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96d7933e4fccd37e679b7a53a68227f3e414a66a1806491333f23b50d9ed2421.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a244984f23f13d49cb7b1708aab93ea08c58a27ab0c0720e6539755b38098d23.yml diff --git a/api.md b/api.md index cb3fbfd2000..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 98cb7ced1377a7d2641fc4248e30edf8938d0904 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 10:55:11 +0000 Subject: [PATCH 192/532] feat(api): OpenAPI spec update via Stainless API (#673) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index c33ca4fc747..8832edc35e8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a244984f23f13d49cb7b1708aab93ea08c58a27ab0c0720e6539755b38098d23.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96d7933e4fccd37e679b7a53a68227f3e414a66a1806491333f23b50d9ed2421.yml diff --git a/api.md b/api.md index 03a403900af..cb3fbfd2000 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From fd4bc93325b741aee85a8a03cdfc2b15c16cb75c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 15:15:01 +0000 Subject: [PATCH 193/532] feat(api): OpenAPI spec update via Stainless API (#674) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8832edc35e8..5338d8426c8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96d7933e4fccd37e679b7a53a68227f3e414a66a1806491333f23b50d9ed2421.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-689c74936058de426265b871e29486b744602698fbb217f25b46e95c199e5422.yml diff --git a/api.md b/api.md index cb3fbfd2000..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From bd9001e189405c6c38c05dfb8f91bdad2b9d9060 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 15:49:27 +0000 Subject: [PATCH 194/532] feat(api): OpenAPI spec update via Stainless API (#675) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5338d8426c8..4f5132c5dcd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-689c74936058de426265b871e29486b744602698fbb217f25b46e95c199e5422.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4262d92f50cf46b515411bfbb417984acc537be48fffdf36387bddcf2e222db1.yml diff --git a/api.md b/api.md index 03a403900af..cb3fbfd2000 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From d1480d9ebbc999b96ec1410c9bc3ebce81f62e3d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 15:51:36 +0000 Subject: [PATCH 195/532] feat(api): OpenAPI spec update via Stainless API (#676) --- .stats.yml | 2 +- src/cloudflare/resources/r2/buckets.py | 8 ++++++++ src/cloudflare/types/r2/bucket.py | 3 +++ src/cloudflare/types/r2/bucket_create_params.py | 3 +++ tests/api_resources/r2/test_buckets.py | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4f5132c5dcd..040c6773f41 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4262d92f50cf46b515411bfbb417984acc537be48fffdf36387bddcf2e222db1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a6c025333f43194a102e23621d34e1f5d1521ff54e377bde51480c7f7c33b886.yml diff --git a/src/cloudflare/resources/r2/buckets.py b/src/cloudflare/resources/r2/buckets.py index c7c04313e66..2b322b7a24c 100644 --- a/src/cloudflare/resources/r2/buckets.py +++ b/src/cloudflare/resources/r2/buckets.py @@ -47,6 +47,7 @@ def create( account_id: str, name: str, location_hint: Literal["apac", "eeur", "enam", "weur", "wnam"] | NotGiven = NOT_GIVEN, + storage_class: Literal["Standard", "InfrequentAccess"] | 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, @@ -64,6 +65,8 @@ def create( location_hint: Location of the bucket + storage_class: Storage class for newly uploaded objects, unless specified otherwise. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -80,6 +83,7 @@ def create( { "name": name, "location_hint": location_hint, + "storage_class": storage_class, }, bucket_create_params.BucketCreateParams, ), @@ -267,6 +271,7 @@ async def create( account_id: str, name: str, location_hint: Literal["apac", "eeur", "enam", "weur", "wnam"] | NotGiven = NOT_GIVEN, + storage_class: Literal["Standard", "InfrequentAccess"] | 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, @@ -284,6 +289,8 @@ async def create( location_hint: Location of the bucket + storage_class: Storage class for newly uploaded objects, unless specified otherwise. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -300,6 +307,7 @@ async def create( { "name": name, "location_hint": location_hint, + "storage_class": storage_class, }, bucket_create_params.BucketCreateParams, ), diff --git a/src/cloudflare/types/r2/bucket.py b/src/cloudflare/types/r2/bucket.py index d473140b23d..aa601305f38 100644 --- a/src/cloudflare/types/r2/bucket.py +++ b/src/cloudflare/types/r2/bucket.py @@ -17,3 +17,6 @@ class Bucket(BaseModel): name: Optional[str] = None """Name of the bucket""" + + storage_class: Optional[Literal["Standard", "InfrequentAccess"]] = None + """Storage class for newly uploaded objects, unless specified otherwise.""" diff --git a/src/cloudflare/types/r2/bucket_create_params.py b/src/cloudflare/types/r2/bucket_create_params.py index 9809fb9a07d..ad5ad8a75b3 100644 --- a/src/cloudflare/types/r2/bucket_create_params.py +++ b/src/cloudflare/types/r2/bucket_create_params.py @@ -18,3 +18,6 @@ class BucketCreateParams(TypedDict, total=False): location_hint: Annotated[Literal["apac", "eeur", "enam", "weur", "wnam"], PropertyInfo(alias="locationHint")] """Location of the bucket""" + + storage_class: Annotated[Literal["Standard", "InfrequentAccess"], PropertyInfo(alias="storageClass")] + """Storage class for newly uploaded objects, unless specified otherwise.""" diff --git a/tests/api_resources/r2/test_buckets.py b/tests/api_resources/r2/test_buckets.py index 956a75d7441..0b1049530c9 100644 --- a/tests/api_resources/r2/test_buckets.py +++ b/tests/api_resources/r2/test_buckets.py @@ -32,6 +32,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", name="example-bucket", location_hint="apac", + storage_class="Standard", ) assert_matches_type(Bucket, bucket, path=["response"]) @@ -234,6 +235,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_id="023e105f4ecef8ad9ca31a8372d0c353", name="example-bucket", location_hint="apac", + storage_class="Standard", ) assert_matches_type(Bucket, bucket, path=["response"]) From 43dea694c154b011ad1a4416410a28ff7be89eb0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 15:55:42 +0000 Subject: [PATCH 196/532] feat(api): OpenAPI spec update via Stainless API (#677) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 040c6773f41..f3009ad4d95 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a6c025333f43194a102e23621d34e1f5d1521ff54e377bde51480c7f7c33b886.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e803674fed18c8a55aacf23405aa472437f7ab3502189ed42033505d4c213747.yml From 0e05c40ca0fd70f0ca6560573d1b3bdffa869290 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 16:10:04 +0000 Subject: [PATCH 197/532] feat(api): OpenAPI spec update via Stainless API (#678) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index f3009ad4d95..13730db7cbb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e803674fed18c8a55aacf23405aa472437f7ab3502189ed42033505d4c213747.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f89052e535a63430662bc2a46ef81b816db1c35df7dc58f1392e9628d677f82.yml diff --git a/api.md b/api.md index cb3fbfd2000..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From db7c75640e02996f7dfa3d904ecd0542878f9789 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 16:12:50 +0000 Subject: [PATCH 198/532] feat(api): OpenAPI spec update via Stainless API (#679) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 13730db7cbb..16aad5d0302 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f89052e535a63430662bc2a46ef81b816db1c35df7dc58f1392e9628d677f82.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4ee01d34625694110df88e13482b808db6fb87dcee6d1856c1f40362bd8342c3.yml From 624f4e0789837d202c2847e7359e6ff41ace688c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 16:29:27 +0000 Subject: [PATCH 199/532] feat(api): OpenAPI spec update via Stainless API (#680) --- .stats.yml | 2 +- src/cloudflare/resources/d1/database.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 16aad5d0302..85857b4c2dd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4ee01d34625694110df88e13482b808db6fb87dcee6d1856c1f40362bd8342c3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2fd5e83a588bb4f43068c2d2000ef14aa74bf0e0707f3ad161a46f61ca75cfec.yml diff --git a/src/cloudflare/resources/d1/database.py b/src/cloudflare/resources/d1/database.py index 1c557c2e71e..0d056e79996 100644 --- a/src/cloudflare/resources/d1/database.py +++ b/src/cloudflare/resources/d1/database.py @@ -245,7 +245,7 @@ def query( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> DatabaseQueryResponse: """ - Returns the query result. + Returns the query result as an object. Args: account_id: Account identifier tag. @@ -492,7 +492,7 @@ async def query( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> DatabaseQueryResponse: """ - Returns the query result. + Returns the query result as an object. Args: account_id: Account identifier tag. From 80ef42896bdeef8cac357a85fb5404adca150cfa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 16:41:24 +0000 Subject: [PATCH 200/532] feat(api): OpenAPI spec update via Stainless API (#681) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 85857b4c2dd..6aa55bcf129 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2fd5e83a588bb4f43068c2d2000ef14aa74bf0e0707f3ad161a46f61ca75cfec.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a07d07890afccbbf5fa8020a460e879d2d26ccc7786666ed060d08089bf7b9f.yml From 913362958e489e9253e6955dac2644df1979f1a1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 16:53:47 +0000 Subject: [PATCH 201/532] feat(api): OpenAPI spec update via Stainless API (#682) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6aa55bcf129..9deeb86d36c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a07d07890afccbbf5fa8020a460e879d2d26ccc7786666ed060d08089bf7b9f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8449e4537cf545b9b1c153a80f6b671f59ab4265d3e20c8b7677a48d23f0e672.yml diff --git a/api.md b/api.md index 03a403900af..cb3fbfd2000 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 9c53092e24bffcc07c31beca4c215d61cb354995 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 17:36:27 +0000 Subject: [PATCH 202/532] feat(api): OpenAPI spec update via Stainless API (#683) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9deeb86d36c..c3c4792c2a5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8449e4537cf545b9b1c153a80f6b671f59ab4265d3e20c8b7677a48d23f0e672.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-adc599dd24afc5c97da89237fd8dc6a95358563481533a0d2a3b32799e25bab8.yml From aa1289f7e30c2f688796384d5d4e51b78bed19d6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 17:38:37 +0000 Subject: [PATCH 203/532] feat(api): OpenAPI spec update via Stainless API (#684) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c3c4792c2a5..9deeb86d36c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-adc599dd24afc5c97da89237fd8dc6a95358563481533a0d2a3b32799e25bab8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8449e4537cf545b9b1c153a80f6b671f59ab4265d3e20c8b7677a48d23f0e672.yml From 005e4059327a3cad6fe285b9b6836899962aa5b8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 17:45:59 +0000 Subject: [PATCH 204/532] feat(api): OpenAPI spec update via Stainless API (#685) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9deeb86d36c..6aa55bcf129 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8449e4537cf545b9b1c153a80f6b671f59ab4265d3e20c8b7677a48d23f0e672.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a07d07890afccbbf5fa8020a460e879d2d26ccc7786666ed060d08089bf7b9f.yml diff --git a/api.md b/api.md index cb3fbfd2000..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From d4bf34682336562d4ee18e95b3cdb7d9ee6ad984 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 17:58:53 +0000 Subject: [PATCH 205/532] feat(api): OpenAPI spec update via Stainless API (#686) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6aa55bcf129..85857b4c2dd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a07d07890afccbbf5fa8020a460e879d2d26ccc7786666ed060d08089bf7b9f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2fd5e83a588bb4f43068c2d2000ef14aa74bf0e0707f3ad161a46f61ca75cfec.yml From 14ee6c99e23c0e63be0abb872c4456301967938b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 18:17:09 +0000 Subject: [PATCH 206/532] feat(api): OpenAPI spec update via Stainless API (#687) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 85857b4c2dd..9deeb86d36c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2fd5e83a588bb4f43068c2d2000ef14aa74bf0e0707f3ad161a46f61ca75cfec.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8449e4537cf545b9b1c153a80f6b671f59ab4265d3e20c8b7677a48d23f0e672.yml diff --git a/api.md b/api.md index 03a403900af..cb3fbfd2000 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 7121c4385b6f4d38ac5cfc515025ed1c1dcf155e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 18:22:43 +0000 Subject: [PATCH 207/532] feat(api): OpenAPI spec update via Stainless API (#688) --- .stats.yml | 2 +- src/cloudflare/resources/cache/cache.py | 788 +++++++++++++++++- .../types/cache/cache_purge_params.py | 67 +- tests/api_resources/test_cache.py | 142 +++- 4 files changed, 935 insertions(+), 64 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9deeb86d36c..071f3a1b1b1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8449e4537cf545b9b1c153a80f6b671f59ab4265d3e20c8b7677a48d23f0e672.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fd92259169e1a2cc929fca63cb0b69d5e9c5410458facd77da999b9f61a78efb.yml diff --git a/src/cloudflare/resources/cache/cache.py b/src/cloudflare/resources/cache/cache.py index 29104a62b96..0b6fc0dd540 100644 --- a/src/cloudflare/resources/cache/cache.py +++ b/src/cloudflare/resources/cache/cache.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast, overload +from typing import List, Type, Iterable, Optional, cast, overload import httpx @@ -106,6 +106,10 @@ def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -118,9 +122,34 @@ def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -133,7 +162,28 @@ def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + tags: For more information on cache tags and purging by tags, please refer to + [purge by cache-tags documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/#purge-cache-by-cache-tags-enterprise-only). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -163,6 +213,10 @@ def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -175,9 +229,34 @@ def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -190,7 +269,28 @@ def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + hosts: For more information purging by hostnames, please refer to + [purge by hostname documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-hostname/). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -220,6 +320,10 @@ def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -232,9 +336,34 @@ def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -247,7 +376,28 @@ def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + prefixes: For more information on purging by prefixes, please refer to + [purge by prefix documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge_by_prefix/). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -277,6 +427,10 @@ def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -289,9 +443,34 @@ def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -304,7 +483,28 @@ def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + purge_everything: For more information, please refer to + [purge everything documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-everything/). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -320,7 +520,7 @@ def purge( self, *, zone_id: str, - files: List[cache_purge_params.CachePurgeFilesFile] | NotGiven = NOT_GIVEN, + files: List[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, @@ -334,6 +534,10 @@ def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -346,9 +550,34 @@ def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -361,7 +590,135 @@ def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + files: For more information on purging files, please refer to + [purge by single-file documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-single-file/). + + 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 + """ + ... + + @overload + def purge( + self, + *, + zone_id: str, + files: Iterable[cache_purge_params.CachePurgeSingleFileWithURLAndHeadersFile] | 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[CachePurgeResponse]: + """### Purge All Cached Content + + Removes ALL files from Cloudflare's cache. + + All tiers can purge everything. + + ``` + {"purge_everything": true} + ``` + + ### Purge Cached Content by URL + + Granularly removes one or more files from Cloudflare's cache by specifying URLs. + All tiers can purge by URL. + + To purge files with custom cache keys, include the headers used to compute the + cache key as in the example. If you have a device type or geo in your cache key, + you will need to include the CF-Device-Type or CF-IPCountry headers. If you have + lang in your cache key, you will need to include the Accept-Language header. + + **NB:** When including the Origin header, be sure to include the **scheme** and + **hostname**. The port number can be omitted if it is the default port (80 for + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` + + ### Purge Cached Content by Tag, Host or Prefix + + Granularly removes one or more files from Cloudflare's cache either by + specifying the host, the associated Cache-Tag, or a Prefix. Only Enterprise + customers are permitted to purge by Tag, Host or Prefix. + + **NB:** Cache-Tag, host, and prefix purging each have a rate limit of 30,000 + purge API calls in every 24 hour period. You may purge up to 30 tags, hosts, or + prefixes in one API call. This rate limit can be raised for customers who need + to purge at higher volume. + + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + + Args: + files: For more information on purging files with URL and headers, please refer to + [purge by single-file documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-single-file/). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -381,7 +738,9 @@ def purge( hosts: List[str] | NotGiven = NOT_GIVEN, prefixes: List[str] | NotGiven = NOT_GIVEN, purge_everything: bool | NotGiven = NOT_GIVEN, - files: List[cache_purge_params.CachePurgeFilesFile] | NotGiven = NOT_GIVEN, + files: List[str] + | Iterable[cache_purge_params.CachePurgeSingleFileWithURLAndHeadersFile] + | 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, @@ -458,6 +817,10 @@ async def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -470,9 +833,34 @@ async def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -485,7 +873,28 @@ async def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + tags: For more information on cache tags and purging by tags, please refer to + [purge by cache-tags documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/#purge-cache-by-cache-tags-enterprise-only). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -515,6 +924,10 @@ async def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -527,9 +940,34 @@ async def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -542,7 +980,28 @@ async def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + hosts: For more information purging by hostnames, please refer to + [purge by hostname documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-hostname/). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -572,6 +1031,10 @@ async def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -584,9 +1047,34 @@ async def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -599,7 +1087,28 @@ async def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + prefixes: For more information on purging by prefixes, please refer to + [purge by prefix documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge_by_prefix/). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -629,6 +1138,10 @@ async def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -641,9 +1154,34 @@ async def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -656,7 +1194,28 @@ async def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + purge_everything: For more information, please refer to + [purge everything documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-everything/). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -672,7 +1231,7 @@ async def purge( self, *, zone_id: str, - files: List[cache_purge_params.CachePurgeFilesFile] | NotGiven = NOT_GIVEN, + files: List[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, @@ -686,6 +1245,10 @@ async def purge( All tiers can purge everything. + ``` + {"purge_everything": true} + ``` + ### Purge Cached Content by URL Granularly removes one or more files from Cloudflare's cache by specifying URLs. @@ -698,9 +1261,34 @@ async def purge( **NB:** When including the Origin header, be sure to include the **scheme** and **hostname**. The port number can be omitted if it is the default port (80 for - http, 443 for https), but must be included otherwise. **NB:** For Zones on - Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones - on Enterprise plan, you may purge up to 500 URLs in one API call. + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` ### Purge Cached Content by Tag, Host or Prefix @@ -713,7 +1301,135 @@ async def purge( prefixes in one API call. This rate limit can be raised for customers who need to purge at higher volume. + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + Args: + files: For more information on purging files, please refer to + [purge by single-file documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-single-file/). + + 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 + """ + ... + + @overload + async def purge( + self, + *, + zone_id: str, + files: Iterable[cache_purge_params.CachePurgeSingleFileWithURLAndHeadersFile] | 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[CachePurgeResponse]: + """### Purge All Cached Content + + Removes ALL files from Cloudflare's cache. + + All tiers can purge everything. + + ``` + {"purge_everything": true} + ``` + + ### Purge Cached Content by URL + + Granularly removes one or more files from Cloudflare's cache by specifying URLs. + All tiers can purge by URL. + + To purge files with custom cache keys, include the headers used to compute the + cache key as in the example. If you have a device type or geo in your cache key, + you will need to include the CF-Device-Type or CF-IPCountry headers. If you have + lang in your cache key, you will need to include the Accept-Language header. + + **NB:** When including the Origin header, be sure to include the **scheme** and + **hostname**. The port number can be omitted if it is the default port (80 for + http, 443 for https), but must be included otherwise. + + **NB:** For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one + API call. For Zones on Enterprise plan, you may purge up to 500 URLs in one API + call. + + Single file purge example with files: + + ``` + {"files": ["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"]} + ``` + + Single file purge example with url and header pairs: + + ``` + { + "files": [ + { + url: "http://www.example.com/cat_picture.jpg", + headers: {"CF-IPCountry": "US", "CF-Device-Type": "desktop", "Accept-Language": "zh-CN"}, + }, + { + url: "http://www.example.com/dog_picture.jpg", + headers: {"CF-IPCountry": "EU", "CF-Device-Type": "mobile", "Accept-Language": "en-US"}, + }, + ] + } + ``` + + ### Purge Cached Content by Tag, Host or Prefix + + Granularly removes one or more files from Cloudflare's cache either by + specifying the host, the associated Cache-Tag, or a Prefix. Only Enterprise + customers are permitted to purge by Tag, Host or Prefix. + + **NB:** Cache-Tag, host, and prefix purging each have a rate limit of 30,000 + purge API calls in every 24 hour period. You may purge up to 30 tags, hosts, or + prefixes in one API call. This rate limit can be raised for customers who need + to purge at higher volume. + + Flex purge with tags: + + ``` + {"tags": ["a-cache-tag", "another-cache-tag"]} + ``` + + Flex purge with hosts: + + ``` + {"hosts": ["www.example.com", "images.example.com"]} + ``` + + Flex purge with prefixes: + + ``` + {"prefixes": ["www.example.com/foo", "images.example.com/bar/baz"]} + ``` + + Args: + files: For more information on purging files with URL and headers, please refer to + [purge by single-file documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-single-file/). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -733,7 +1449,9 @@ async def purge( hosts: List[str] | NotGiven = NOT_GIVEN, prefixes: List[str] | NotGiven = NOT_GIVEN, purge_everything: bool | NotGiven = NOT_GIVEN, - files: List[cache_purge_params.CachePurgeFilesFile] | NotGiven = NOT_GIVEN, + files: List[str] + | Iterable[cache_purge_params.CachePurgeSingleFileWithURLAndHeadersFile] + | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/cloudflare/types/cache/cache_purge_params.py b/src/cloudflare/types/cache/cache_purge_params.py index 5eb2fbb56c7..53155b6f63a 100644 --- a/src/cloudflare/types/cache/cache_purge_params.py +++ b/src/cloudflare/types/cache/cache_purge_params.py @@ -2,57 +2,92 @@ from __future__ import annotations -from typing import List, Union +from typing import List, Union, Iterable from typing_extensions import Required, TypedDict __all__ = [ "CachePurgeParams", - "CachePurgeTags", - "CachePurgeHosts", - "CachePurgePrefixes", + "CachePurgeFlexPurgeByTags", + "CachePurgeFlexPurgeByHostnames", + "CachePurgeFlexPurgeByPrefixes", "CachePurgeEverything", - "CachePurgeFiles", - "CachePurgeFilesFile", - "CachePurgeFilesFileCachePurgeURLAndHeaders", + "CachePurgeSingleFile", + "CachePurgeSingleFileWithURLAndHeaders", + "CachePurgeSingleFileWithURLAndHeadersFile", ] -class CachePurgeTags(TypedDict, total=False): +class CachePurgeFlexPurgeByTags(TypedDict, total=False): zone_id: Required[str] tags: List[str] + """ + For more information on cache tags and purging by tags, please refer to + [purge by cache-tags documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/#purge-cache-by-cache-tags-enterprise-only). + """ -class CachePurgeHosts(TypedDict, total=False): +class CachePurgeFlexPurgeByHostnames(TypedDict, total=False): zone_id: Required[str] hosts: List[str] + """ + For more information purging by hostnames, please refer to + [purge by hostname documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-hostname/). + """ -class CachePurgePrefixes(TypedDict, total=False): +class CachePurgeFlexPurgeByPrefixes(TypedDict, total=False): zone_id: Required[str] prefixes: List[str] + """ + For more information on purging by prefixes, please refer to + [purge by prefix documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge_by_prefix/). + """ class CachePurgeEverything(TypedDict, total=False): zone_id: Required[str] purge_everything: bool + """ + For more information, please refer to + [purge everything documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-everything/). + """ -class CachePurgeFiles(TypedDict, total=False): +class CachePurgeSingleFile(TypedDict, total=False): zone_id: Required[str] - files: List[CachePurgeFilesFile] + files: List[str] + """ + For more information on purging files, please refer to + [purge by single-file documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-single-file/). + """ -class CachePurgeFilesFileCachePurgeURLAndHeaders(TypedDict, total=False): +class CachePurgeSingleFileWithURLAndHeaders(TypedDict, total=False): + zone_id: Required[str] + + files: Iterable[CachePurgeSingleFileWithURLAndHeadersFile] + """ + For more information on purging files with URL and headers, please refer to + [purge by single-file documentation page](https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-single-file/). + """ + + +class CachePurgeSingleFileWithURLAndHeadersFile(TypedDict, total=False): headers: object url: str -CachePurgeFilesFile = Union[str, CachePurgeFilesFileCachePurgeURLAndHeaders] - -CachePurgeParams = Union[CachePurgeTags, CachePurgeHosts, CachePurgePrefixes, CachePurgeEverything, CachePurgeFiles] +CachePurgeParams = Union[ + CachePurgeFlexPurgeByTags, + CachePurgeFlexPurgeByHostnames, + CachePurgeFlexPurgeByPrefixes, + CachePurgeEverything, + CachePurgeSingleFile, + CachePurgeSingleFileWithURLAndHeaders, +] diff --git a/tests/api_resources/test_cache.py b/tests/api_resources/test_cache.py index 2c5dd92732e..d23c8672439 100644 --- a/tests/api_resources/test_cache.py +++ b/tests/api_resources/test_cache.py @@ -28,7 +28,7 @@ def test_method_purge_overload_1(self, client: Cloudflare) -> None: def test_method_purge_with_all_params_overload_1(self, client: Cloudflare) -> None: cache = client.cache.purge( zone_id="string", - tags=["some-tag", "another-tag"], + tags=["a-cache-tag", "another-cache-tag"], ) assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) @@ -212,11 +212,7 @@ def test_method_purge_overload_5(self, client: Cloudflare) -> None: def test_method_purge_with_all_params_overload_5(self, client: Cloudflare) -> None: cache = client.cache.purge( zone_id="string", - files=[ - "http://www.example.com/css/styles.css", - "http://www.example.com/css/styles.css", - "http://www.example.com/css/styles.css", - ], + files=["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"], ) assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) @@ -251,6 +247,69 @@ def test_path_params_purge_overload_5(self, client: Cloudflare) -> None: zone_id="", ) + @parametrize + def test_method_purge_overload_6(self, client: Cloudflare) -> None: + cache = client.cache.purge( + zone_id="string", + ) + assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) + + @parametrize + def test_method_purge_with_all_params_overload_6(self, client: Cloudflare) -> None: + cache = client.cache.purge( + zone_id="string", + files=[ + { + "headers": { + "Accept-Language": "zh-CN", + "CF-Device-Type": "desktop", + "CF-IPCountry": "US", + }, + "url": "http://www.example.com/cat_picture.jpg", + }, + { + "headers": { + "Accept-Language": "en-US", + "CF-Device-Type": "mobile", + "CF-IPCountry": "EU", + }, + "url": "http://www.example.com/dog_picture.jpg", + }, + ], + ) + assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) + + @parametrize + def test_raw_response_purge_overload_6(self, client: Cloudflare) -> None: + response = client.cache.with_raw_response.purge( + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cache = response.parse() + assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) + + @parametrize + def test_streaming_response_purge_overload_6(self, client: Cloudflare) -> None: + with client.cache.with_streaming_response.purge( + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cache = response.parse() + assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_purge_overload_6(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.cache.with_raw_response.purge( + zone_id="", + ) + class TestAsyncCache: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -266,7 +325,7 @@ async def test_method_purge_overload_1(self, async_client: AsyncCloudflare) -> N async def test_method_purge_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: cache = await async_client.cache.purge( zone_id="string", - tags=["some-tag", "another-tag"], + tags=["a-cache-tag", "another-cache-tag"], ) assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) @@ -450,11 +509,7 @@ async def test_method_purge_overload_5(self, async_client: AsyncCloudflare) -> N async def test_method_purge_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: cache = await async_client.cache.purge( zone_id="string", - files=[ - "http://www.example.com/css/styles.css", - "http://www.example.com/css/styles.css", - "http://www.example.com/css/styles.css", - ], + files=["http://www.example.com/css/styles.css", "http://www.example.com/js/index.js"], ) assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) @@ -488,3 +543,66 @@ async def test_path_params_purge_overload_5(self, async_client: AsyncCloudflare) await async_client.cache.with_raw_response.purge( zone_id="", ) + + @parametrize + async def test_method_purge_overload_6(self, async_client: AsyncCloudflare) -> None: + cache = await async_client.cache.purge( + zone_id="string", + ) + assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) + + @parametrize + async def test_method_purge_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: + cache = await async_client.cache.purge( + zone_id="string", + files=[ + { + "headers": { + "Accept-Language": "zh-CN", + "CF-Device-Type": "desktop", + "CF-IPCountry": "US", + }, + "url": "http://www.example.com/cat_picture.jpg", + }, + { + "headers": { + "Accept-Language": "en-US", + "CF-Device-Type": "mobile", + "CF-IPCountry": "EU", + }, + "url": "http://www.example.com/dog_picture.jpg", + }, + ], + ) + assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) + + @parametrize + async def test_raw_response_purge_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.cache.with_raw_response.purge( + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cache = await response.parse() + assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) + + @parametrize + async def test_streaming_response_purge_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.cache.with_streaming_response.purge( + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cache = await response.parse() + assert_matches_type(Optional[CachePurgeResponse], cache, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_purge_overload_6(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.cache.with_raw_response.purge( + zone_id="", + ) From 6ac0d9d9b431af16956b9064d660f74e4d287caf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 18:27:40 +0000 Subject: [PATCH 208/532] feat(api): OpenAPI spec update via Stainless API (#689) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 071f3a1b1b1..eebbf24275c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fd92259169e1a2cc929fca63cb0b69d5e9c5410458facd77da999b9f61a78efb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5cf86316bb729c1c2d89688af761f31810f696145425cc03d0447e7fa0b136c6.yml diff --git a/api.md b/api.md index cb3fbfd2000..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From e08ff5c57b6a00f57a89fe1d045f776ef0f669fb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 18:34:15 +0000 Subject: [PATCH 209/532] feat(api): OpenAPI spec update via Stainless API (#690) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index eebbf24275c..435870631ee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5cf86316bb729c1c2d89688af761f31810f696145425cc03d0447e7fa0b136c6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml From 08203fb73210cc67fd9a34d2253e70887d9825d0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 20:16:44 +0000 Subject: [PATCH 210/532] feat(api): OpenAPI spec update via Stainless API (#691) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 435870631ee..70fe273f6ae 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml diff --git a/api.md b/api.md index 03a403900af..cb3fbfd2000 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From c95540bece01993960a69cb1483de916d785d06f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 20:28:51 +0000 Subject: [PATCH 211/532] feat(api): OpenAPI spec update via Stainless API (#692) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 70fe273f6ae..a91991678eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml diff --git a/api.md b/api.md index cb3fbfd2000..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 2ebd19b7924eb91c37deb9fe03010c0993c4562a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 21:30:32 +0000 Subject: [PATCH 212/532] feat(api): OpenAPI spec update via Stainless API (#693) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a91991678eb..8b763334f41 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a8f464c87b8d42715e4641e9e49808524a96024fbd7df0eca209410719279ad6.yml diff --git a/api.md b/api.md index 03a403900af..cb3fbfd2000 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From cb7edcdc5d6128771d9031e28348323a426b078c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 21:54:11 +0000 Subject: [PATCH 213/532] feat(api): OpenAPI spec update via Stainless API (#694) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8b763334f41..435870631ee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a8f464c87b8d42715e4641e9e49808524a96024fbd7df0eca209410719279ad6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml diff --git a/api.md b/api.md index cb3fbfd2000..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 6d39d7bd16a7c80e19cc90cd36a5436c567fd569 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 23:40:03 +0000 Subject: [PATCH 214/532] feat(api): OpenAPI spec update via Stainless API (#695) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 435870631ee..70fe273f6ae 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml diff --git a/api.md b/api.md index 03a403900af..cb3fbfd2000 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From bef7fd3b4e021c56abfdac1b0d74abc2e1e0c276 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 23:47:53 +0000 Subject: [PATCH 215/532] feat(api): OpenAPI spec update via Stainless API (#696) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 70fe273f6ae..a91991678eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1319 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml diff --git a/api.md b/api.md index cb3fbfd2000..03a403900af 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7640,14 +7640,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7663,10 +7663,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7683,11 +7683,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 149d9ee9b066975fe792e5799717df5405f2a6a2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 01:06:07 +0000 Subject: [PATCH 216/532] feat(api): update via SDK Studio (#697) --- .stats.yml | 2 +- api.md | 3 + src/cloudflare/resources/d1/database.py | 121 ++++++++++++++++- .../resources/kv/namespaces/namespaces.py | 100 ++++++++++++++ src/cloudflare/types/d1/__init__.py | 2 + .../types/d1/database_raw_params.py | 17 +++ .../types/d1/database_raw_response.py | 45 +++++++ tests/api_resources/d1/test_database.py | 127 ++++++++++++++++++ tests/api_resources/kv/test_namespaces.py | 96 +++++++++++++ 9 files changed, 511 insertions(+), 2 deletions(-) create mode 100644 src/cloudflare/types/d1/database_raw_params.py create mode 100644 src/cloudflare/types/d1/database_raw_response.py diff --git a/.stats.yml b/.stats.yml index a91991678eb..79bbbc19c23 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1319 +configured_endpoints: 1321 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml diff --git a/api.md b/api.md index 03a403900af..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -2810,6 +2810,7 @@ Methods: - client.kv.namespaces.update(namespace_id, \*, account_id, \*\*params) -> NamespaceUpdateResponse - client.kv.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] - client.kv.namespaces.delete(namespace_id, \*, account_id) -> NamespaceDeleteResponse +- client.kv.namespaces.get(namespace_id, \*, account_id) -> Namespace ### Bulk @@ -4743,6 +4744,7 @@ from cloudflare.types.d1 import ( DatabaseListResponse, DatabaseDeleteResponse, DatabaseQueryResponse, + DatabaseRawResponse, ) ``` @@ -4753,6 +4755,7 @@ Methods: - client.d1.database.delete(database_id, \*, account_id) -> DatabaseDeleteResponse - client.d1.database.get(database_id, \*, account_id) -> D1 - client.d1.database.query(database_id, \*, account_id, \*\*params) -> DatabaseQueryResponse +- client.d1.database.raw(database_id, \*, account_id, \*\*params) -> DatabaseRawResponse # R2 diff --git a/src/cloudflare/resources/d1/database.py b/src/cloudflare/resources/d1/database.py index 0d056e79996..d4b4ca58763 100644 --- a/src/cloudflare/resources/d1/database.py +++ b/src/cloudflare/resources/d1/database.py @@ -12,7 +12,7 @@ async_maybe_transform, ) from ..._compat import cached_property -from ...types.d1 import database_list_params, database_query_params, database_create_params +from ...types.d1 import database_raw_params, database_list_params, database_query_params, database_create_params from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, @@ -27,6 +27,7 @@ AsyncPaginator, make_request_options, ) +from ...types.d1.database_raw_response import DatabaseRawResponse from ...types.d1.database_list_response import DatabaseListResponse from ...types.d1.database_query_response import DatabaseQueryResponse from ...types.d1.database_create_response import DatabaseCreateResponse @@ -281,6 +282,59 @@ def query( cast_to=cast(Type[DatabaseQueryResponse], ResultWrapper[DatabaseQueryResponse]), ) + def raw( + self, + database_id: str, + *, + account_id: str, + sql: str, + params: List[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, + ) -> DatabaseRawResponse: + """Returns the query result rows as arrays rather than objects. + + This is a + performance-optimized version of the /query endpoint. + + Args: + account_id: Account identifier tag. + + 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 database_id: + raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") + return self._post( + f"/accounts/{account_id}/d1/database/{database_id}/raw", + body=maybe_transform( + { + "sql": sql, + "params": params, + }, + database_raw_params.DatabaseRawParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatabaseRawResponse]._unwrapper, + ), + cast_to=cast(Type[DatabaseRawResponse], ResultWrapper[DatabaseRawResponse]), + ) + class AsyncDatabaseResource(AsyncAPIResource): @cached_property @@ -528,6 +582,59 @@ async def query( cast_to=cast(Type[DatabaseQueryResponse], ResultWrapper[DatabaseQueryResponse]), ) + async def raw( + self, + database_id: str, + *, + account_id: str, + sql: str, + params: List[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, + ) -> DatabaseRawResponse: + """Returns the query result rows as arrays rather than objects. + + This is a + performance-optimized version of the /query endpoint. + + Args: + account_id: Account identifier tag. + + 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 database_id: + raise ValueError(f"Expected a non-empty value for `database_id` but received {database_id!r}") + return await self._post( + f"/accounts/{account_id}/d1/database/{database_id}/raw", + body=await async_maybe_transform( + { + "sql": sql, + "params": params, + }, + database_raw_params.DatabaseRawParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DatabaseRawResponse]._unwrapper, + ), + cast_to=cast(Type[DatabaseRawResponse], ResultWrapper[DatabaseRawResponse]), + ) + class DatabaseResourceWithRawResponse: def __init__(self, database: DatabaseResource) -> None: @@ -548,6 +655,9 @@ def __init__(self, database: DatabaseResource) -> None: self.query = to_raw_response_wrapper( database.query, ) + self.raw = to_raw_response_wrapper( + database.raw, + ) class AsyncDatabaseResourceWithRawResponse: @@ -569,6 +679,9 @@ def __init__(self, database: AsyncDatabaseResource) -> None: self.query = async_to_raw_response_wrapper( database.query, ) + self.raw = async_to_raw_response_wrapper( + database.raw, + ) class DatabaseResourceWithStreamingResponse: @@ -590,6 +703,9 @@ def __init__(self, database: DatabaseResource) -> None: self.query = to_streamed_response_wrapper( database.query, ) + self.raw = to_streamed_response_wrapper( + database.raw, + ) class AsyncDatabaseResourceWithStreamingResponse: @@ -611,3 +727,6 @@ def __init__(self, database: AsyncDatabaseResource) -> None: self.query = async_to_streamed_response_wrapper( database.query, ) + self.raw = async_to_streamed_response_wrapper( + database.raw, + ) diff --git a/src/cloudflare/resources/kv/namespaces/namespaces.py b/src/cloudflare/resources/kv/namespaces/namespaces.py index ae2f40cc23f..5f25f6cfbf3 100644 --- a/src/cloudflare/resources/kv/namespaces/namespaces.py +++ b/src/cloudflare/resources/kv/namespaces/namespaces.py @@ -299,6 +299,50 @@ def delete( ), ) + def get( + self, + namespace_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, + ) -> Namespace: + """ + Get the namespace corresponding to the given ID. + + Args: + account_id: Identifier + + namespace_id: Namespace identifier tag. + + 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 namespace_id: + raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") + return self._get( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Namespace]._unwrapper, + ), + cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + ) + class AsyncNamespacesResource(AsyncAPIResource): @cached_property @@ -533,6 +577,50 @@ async def delete( ), ) + async def get( + self, + namespace_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, + ) -> Namespace: + """ + Get the namespace corresponding to the given ID. + + Args: + account_id: Identifier + + namespace_id: Namespace identifier tag. + + 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 namespace_id: + raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") + return await self._get( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Namespace]._unwrapper, + ), + cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + ) + class NamespacesResourceWithRawResponse: def __init__(self, namespaces: NamespacesResource) -> None: @@ -550,6 +638,9 @@ def __init__(self, namespaces: NamespacesResource) -> None: self.delete = to_raw_response_wrapper( namespaces.delete, ) + self.get = to_raw_response_wrapper( + namespaces.get, + ) @cached_property def bulk(self) -> BulkResourceWithRawResponse: @@ -584,6 +675,9 @@ def __init__(self, namespaces: AsyncNamespacesResource) -> None: self.delete = async_to_raw_response_wrapper( namespaces.delete, ) + self.get = async_to_raw_response_wrapper( + namespaces.get, + ) @cached_property def bulk(self) -> AsyncBulkResourceWithRawResponse: @@ -618,6 +712,9 @@ def __init__(self, namespaces: NamespacesResource) -> None: self.delete = to_streamed_response_wrapper( namespaces.delete, ) + self.get = to_streamed_response_wrapper( + namespaces.get, + ) @cached_property def bulk(self) -> BulkResourceWithStreamingResponse: @@ -652,6 +749,9 @@ def __init__(self, namespaces: AsyncNamespacesResource) -> None: self.delete = async_to_streamed_response_wrapper( namespaces.delete, ) + self.get = async_to_streamed_response_wrapper( + namespaces.get, + ) @cached_property def bulk(self) -> AsyncBulkResourceWithStreamingResponse: diff --git a/src/cloudflare/types/d1/__init__.py b/src/cloudflare/types/d1/__init__.py index 2c77c7a96e5..fe272f9209e 100644 --- a/src/cloudflare/types/d1/__init__.py +++ b/src/cloudflare/types/d1/__init__.py @@ -4,8 +4,10 @@ from .d1 import D1 as D1 from .query_result import QueryResult as QueryResult +from .database_raw_params import DatabaseRawParams as DatabaseRawParams from .database_list_params import DatabaseListParams as DatabaseListParams from .database_query_params import DatabaseQueryParams as DatabaseQueryParams +from .database_raw_response import DatabaseRawResponse as DatabaseRawResponse from .database_create_params import DatabaseCreateParams as DatabaseCreateParams from .database_list_response import DatabaseListResponse as DatabaseListResponse from .database_query_response import DatabaseQueryResponse as DatabaseQueryResponse diff --git a/src/cloudflare/types/d1/database_raw_params.py b/src/cloudflare/types/d1/database_raw_params.py new file mode 100644 index 00000000000..9c056647b21 --- /dev/null +++ b/src/cloudflare/types/d1/database_raw_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, TypedDict + +__all__ = ["DatabaseRawParams"] + + +class DatabaseRawParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + sql: Required[str] + + params: List[str] diff --git a/src/cloudflare/types/d1/database_raw_response.py b/src/cloudflare/types/d1/database_raw_response.py new file mode 100644 index 00000000000..f59973dba74 --- /dev/null +++ b/src/cloudflare/types/d1/database_raw_response.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional + +from ..._models import BaseModel + +__all__ = [ + "DatabaseRawResponse", + "DatabaseRawResponseItem", + "DatabaseRawResponseItemMeta", + "DatabaseRawResponseItemResults", +] + + +class DatabaseRawResponseItemMeta(BaseModel): + changed_db: Optional[bool] = None + + changes: Optional[float] = None + + duration: Optional[float] = None + + last_row_id: Optional[float] = None + + rows_read: Optional[float] = None + + rows_written: Optional[float] = None + + size_after: Optional[float] = None + + +class DatabaseRawResponseItemResults(BaseModel): + columns: Optional[List[str]] = None + + rows: Optional[List[List[Union[float, str, object]]]] = None + + +class DatabaseRawResponseItem(BaseModel): + meta: Optional[DatabaseRawResponseItemMeta] = None + + results: Optional[DatabaseRawResponseItemResults] = None + + success: Optional[bool] = None + + +DatabaseRawResponse = List[DatabaseRawResponseItem] diff --git a/tests/api_resources/d1/test_database.py b/tests/api_resources/d1/test_database.py index 15d0c3e2765..68fd53cc39b 100644 --- a/tests/api_resources/d1/test_database.py +++ b/tests/api_resources/d1/test_database.py @@ -11,6 +11,7 @@ from tests.utils import assert_matches_type from cloudflare.types.d1 import ( D1, + DatabaseRawResponse, DatabaseListResponse, DatabaseQueryResponse, DatabaseCreateResponse, @@ -273,6 +274,69 @@ def test_path_params_query(self, client: Cloudflare) -> None: sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", ) + @parametrize + def test_method_raw(self, client: Cloudflare) -> None: + database = client.d1.database.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + assert_matches_type(DatabaseRawResponse, database, path=["response"]) + + @parametrize + def test_method_raw_with_all_params(self, client: Cloudflare) -> None: + database = client.d1.database.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + params=["firstParam", "secondParam"], + ) + assert_matches_type(DatabaseRawResponse, database, path=["response"]) + + @parametrize + def test_raw_response_raw(self, client: Cloudflare) -> None: + response = client.d1.database.with_raw_response.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + database = response.parse() + assert_matches_type(DatabaseRawResponse, database, path=["response"]) + + @parametrize + def test_streaming_response_raw(self, client: Cloudflare) -> None: + with client.d1.database.with_streaming_response.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + database = response.parse() + assert_matches_type(DatabaseRawResponse, database, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_raw(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.d1.database.with_raw_response.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_id` but received ''"): + client.d1.database.with_raw_response.raw( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + class TestAsyncDatabase: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -525,3 +589,66 @@ async def test_path_params_query(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", ) + + @parametrize + async def test_method_raw(self, async_client: AsyncCloudflare) -> None: + database = await async_client.d1.database.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + assert_matches_type(DatabaseRawResponse, database, path=["response"]) + + @parametrize + async def test_method_raw_with_all_params(self, async_client: AsyncCloudflare) -> None: + database = await async_client.d1.database.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + params=["firstParam", "secondParam"], + ) + assert_matches_type(DatabaseRawResponse, database, path=["response"]) + + @parametrize + async def test_raw_response_raw(self, async_client: AsyncCloudflare) -> None: + response = await async_client.d1.database.with_raw_response.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + database = await response.parse() + assert_matches_type(DatabaseRawResponse, database, path=["response"]) + + @parametrize + async def test_streaming_response_raw(self, async_client: AsyncCloudflare) -> None: + async with async_client.d1.database.with_streaming_response.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + database = await response.parse() + assert_matches_type(DatabaseRawResponse, database, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_raw(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.d1.database.with_raw_response.raw( + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + account_id="", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `database_id` but received ''"): + await async_client.d1.database.with_raw_response.raw( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + sql="SELECT * FROM myTable WHERE field = ? OR field = ?;", + ) diff --git a/tests/api_resources/kv/test_namespaces.py b/tests/api_resources/kv/test_namespaces.py index aca5a2593f2..d263f63eae8 100644 --- a/tests/api_resources/kv/test_namespaces.py +++ b/tests/api_resources/kv/test_namespaces.py @@ -214,6 +214,54 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + namespace = client.kv.namespaces.get( + "0f2ac74b498b48028cb68387c421e279", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Namespace, namespace, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.kv.namespaces.with_raw_response.get( + "0f2ac74b498b48028cb68387c421e279", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = response.parse() + assert_matches_type(Namespace, namespace, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.kv.namespaces.with_streaming_response.get( + "0f2ac74b498b48028cb68387c421e279", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = response.parse() + assert_matches_type(Namespace, namespace, 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.kv.namespaces.with_raw_response.get( + "0f2ac74b498b48028cb68387c421e279", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `namespace_id` but received ''"): + client.kv.namespaces.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + class TestAsyncNamespaces: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -409,3 +457,51 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: "", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + namespace = await async_client.kv.namespaces.get( + "0f2ac74b498b48028cb68387c421e279", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Namespace, namespace, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.kv.namespaces.with_raw_response.get( + "0f2ac74b498b48028cb68387c421e279", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + namespace = await response.parse() + assert_matches_type(Namespace, namespace, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.kv.namespaces.with_streaming_response.get( + "0f2ac74b498b48028cb68387c421e279", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + namespace = await response.parse() + assert_matches_type(Namespace, namespace, 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.kv.namespaces.with_raw_response.get( + "0f2ac74b498b48028cb68387c421e279", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `namespace_id` but received ''"): + await async_client.kv.namespaces.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) From ba4897066d3975853a9f983b46982e722f193d1c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 05:27:59 +0000 Subject: [PATCH 217/532] feat(api): OpenAPI spec update via Stainless API (#698) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 79bbbc19c23..185b070c886 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml From 2c1659242f6e93c17dcfd595b32c245128e80545 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 05:30:07 +0000 Subject: [PATCH 218/532] feat(api): OpenAPI spec update via Stainless API (#699) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 185b070c886..79bbbc19c23 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml From 39fddb627d5d8c5eff1902adf5687ab7bb456aac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 05:48:00 +0000 Subject: [PATCH 219/532] feat(api): OpenAPI spec update via Stainless API (#700) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 79bbbc19c23..185b070c886 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml From b037aab980d6435cc9f373ea948a5ce0f6930633 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 05:50:20 +0000 Subject: [PATCH 220/532] feat(api): OpenAPI spec update via Stainless API (#701) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 185b070c886..d5e383244aa 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 771a3e2454f849206d6ddd7f459be31af8a97654 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 06:08:46 +0000 Subject: [PATCH 221/532] feat(api): OpenAPI spec update via Stainless API (#702) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index d5e383244aa..185b070c886 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml diff --git a/api.md b/api.md index 7a0d3b24707..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 9c613081fe69f1d17bbe16dfe9459349442739db Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 07:09:05 +0000 Subject: [PATCH 222/532] feat(api): OpenAPI spec update via Stainless API (#703) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 185b070c886..d5e383244aa 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From cd623336783d3670276c2d10ce59eb253ce8fbd2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 07:18:45 +0000 Subject: [PATCH 223/532] feat(api): OpenAPI spec update via Stainless API (#704) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d5e383244aa..cc5c71135eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a8f464c87b8d42715e4641e9e49808524a96024fbd7df0eca209410719279ad6.yml From 80bbbeaca6f6253367bfd594d57894105c861434 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 08:04:10 +0000 Subject: [PATCH 224/532] feat(api): OpenAPI spec update via Stainless API (#705) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index cc5c71135eb..185b070c886 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a8f464c87b8d42715e4641e9e49808524a96024fbd7df0eca209410719279ad6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml diff --git a/api.md b/api.md index 7a0d3b24707..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 9f700331567b43a910c69aa49e422941dd2a2a9c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 08:11:29 +0000 Subject: [PATCH 225/532] feat(api): OpenAPI spec update via Stainless API (#706) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 185b070c886..79bbbc19c23 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f9e20f897ad801cef48bf4dac5bb5ca6f25bdeb103c1d5bd20592e7485ba37a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml From 24a88ed36be905fb1302f710f15f3851749f2968 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 08:16:49 +0000 Subject: [PATCH 226/532] feat(api): OpenAPI spec update via Stainless API (#707) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 79bbbc19c23..cc5c71135eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a8f464c87b8d42715e4641e9e49808524a96024fbd7df0eca209410719279ad6.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 23f52bb47d6515f33b19030b019ede5e353d65e4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 08:24:25 +0000 Subject: [PATCH 227/532] feat(api): OpenAPI spec update via Stainless API (#708) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index cc5c71135eb..79bbbc19c23 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a8f464c87b8d42715e4641e9e49808524a96024fbd7df0eca209410719279ad6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml diff --git a/api.md b/api.md index 7a0d3b24707..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From f2e1ad06f689678fe07133ac2ce57af1798478a6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 08:31:28 +0000 Subject: [PATCH 228/532] feat(api): OpenAPI spec update via Stainless API (#709) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 79bbbc19c23..cc5c71135eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a8f464c87b8d42715e4641e9e49808524a96024fbd7df0eca209410719279ad6.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From c06792a10716bc3205bae774757b1709f9098cbc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 08:33:32 +0000 Subject: [PATCH 229/532] feat(api): OpenAPI spec update via Stainless API (#710) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index cc5c71135eb..d5e383244aa 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a8f464c87b8d42715e4641e9e49808524a96024fbd7df0eca209410719279ad6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml From dab20ed880f3096a336d30e3edfd904a0f5958df Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 08:39:36 +0000 Subject: [PATCH 230/532] feat(api): OpenAPI spec update via Stainless API (#711) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index d5e383244aa..79bbbc19c23 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-112dc9daeb885813896cca43eabb89b1a43f50616490db5e370a505b87516337.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml diff --git a/api.md b/api.md index 7a0d3b24707..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From b511135f1adcc1a3d0f5f111c0f54a8e758dc3c6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 10:01:51 +0000 Subject: [PATCH 231/532] feat(api): OpenAPI spec update via Stainless API (#712) --- .stats.yml | 2 +- api.md | 28 +- .../cloudforce_one/requests/message.py | 76 +- .../cloudforce_one/requests/priority.py | 88 ++- .../cloudforce_one/requests/requests.py | 112 +-- src/cloudflare/resources/intel/whois.py | 14 +- src/cloudflare/resources/rulesets/rules.py | 492 +++++++++++++ .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- .../types/rulesets/phase_get_response.py | 74 ++ .../types/rulesets/phase_update_params.py | 56 ++ .../types/rulesets/phase_update_response.py | 74 ++ .../rulesets/phases/version_get_response.py | 74 ++ .../types/rulesets/rule_create_params.py | 68 ++ .../types/rulesets/rule_create_response.py | 74 ++ .../types/rulesets/rule_delete_response.py | 74 ++ .../types/rulesets/rule_edit_params.py | 74 ++ .../types/rulesets/rule_edit_response.py | 74 ++ .../types/rulesets/ruleset_create_params.py | 56 ++ .../types/rulesets/ruleset_create_response.py | 74 ++ .../types/rulesets/ruleset_get_response.py | 74 ++ .../types/rulesets/ruleset_update_params.py | 56 ++ .../types/rulesets/ruleset_update_response.py | 74 ++ .../types/rulesets/version_get_response.py | 74 ++ .../rulesets/versions/by_tag_get_response.py | 74 ++ .../cloudforce_one/requests/test_message.py | 50 +- .../cloudforce_one/requests/test_priority.py | 50 +- .../cloudforce_one/test_requests.py | 82 +-- tests/api_resources/intel/test_whois.py | 18 +- tests/api_resources/rulesets/test_rules.py | 688 +++++++++++++++++- 31 files changed, 2581 insertions(+), 288 deletions(-) diff --git a/.stats.yml b/.stats.yml index 79bbbc19c23..9ad762c7dd4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index bd7c415a47b..ecf569b9efa 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -1003,6 +1003,126 @@ def create( """ ... + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + def create( self, ruleset_id: str, @@ -1026,6 +1146,8 @@ def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -2130,6 +2252,128 @@ def edit( """ ... + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + @required_args(["ruleset_id"]) def edit( self, @@ -2155,6 +2399,8 @@ def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object @@ -3193,6 +3439,126 @@ async def create( """ ... + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + async def create( self, ruleset_id: str, @@ -3216,6 +3582,8 @@ async def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -4320,6 +4688,128 @@ async def edit( """ ... + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + @required_args(["ruleset_id"]) async def edit( self, @@ -4345,6 +4835,8 @@ async def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index 476a9254497..d88c9679596 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index d1e457901af..27f4398d8c9 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index a92b28cb216..3e00524ec11 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index bf04a129360..3c7d7b05653 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index e08bad9f0e5..f027d1e1dc5 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -76,6 +76,8 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", + "RulesetsDDoSDynamicRule", + "RulesetsForceConnectionCloseRule", ] @@ -1205,6 +1207,70 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" +class RulesetsDDoSDynamicRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsForceConnectionCloseRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + RuleCreateParams = Union[ BlockRule, ChallengeRule, @@ -1222,4 +1288,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, + RulesetsDDoSDynamicRule, + RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 9a729d3fbe1..04e3457f902 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 1b6810d585e..25d801cd5aa 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index 86c8418e7c8..8382c7d8687 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -76,6 +76,8 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", + "RulesetsDDoSDynamicRule", + "RulesetsForceConnectionCloseRule", ] @@ -1253,6 +1255,76 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" +class RulesetsDDoSDynamicRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsForceConnectionCloseRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + RuleEditParams = Union[ BlockRule, ChallengeRule, @@ -1270,4 +1342,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, + RulesetsDDoSDynamicRule, + RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 3bf0100ef6f..47dd4534324 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py index 6d34a46fac5..4e372271bef 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_params.py +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index f87b58ceec8..bfeacd5afd4 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index d5864df9b91..328ba42b25a 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py index ce723859ed9..e2ff9a9fcb8 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_params.py +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index d2aaaa91d6f..9fb84d0d26a 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index 4d61f17e3ec..abb1cfae6c7 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index 62def70b1fd..058c549bc29 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py index 1496d433303..b457e152f24 100644 --- a/tests/api_resources/rulesets/test_rules.py +++ b/tests/api_resources/rulesets/test_rules.py @@ -1394,6 +1394,156 @@ def test_path_params_create_overload_16(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_17(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_delete(self, client: Cloudflare) -> None: @@ -3072,6 +3222,184 @@ def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + class TestAsyncRules: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -4313,7 +4641,86 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy "respect_strong_etags": True, "serve_stale": {"disable_stale_while_updating": True}, }, - description="Set cache settings when the hostname address is not example.com", + description="Set cache settings when the hostname address is not example.com", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4323,7 +4730,7 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4336,7 +4743,7 @@ async def test_raw_response_create_overload_15(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4351,7 +4758,7 @@ async def test_streaming_response_create_overload_15(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -4372,7 +4779,7 @@ async def test_path_params_create_overload_15(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4381,18 +4788,14 @@ async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="log_custom_field", - action_parameters={ - "cookie_fields": [{"name": "cookie_name_1"}], - "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], - "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], - }, - description="Log custom field when the IP address is not 1.1.1.1", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4402,7 +4805,7 @@ async def test_method_create_with_all_params_overload_16(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4415,7 +4818,7 @@ async def test_raw_response_create_overload_16(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4430,7 +4833,82 @@ async def test_streaming_response_create_overload_16(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_18(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -6126,3 +6604,181 @@ async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) From a0eeb874726c9d5178b97635ce2d4ee206d76b5d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 10:03:53 +0000 Subject: [PATCH 232/532] feat(api): OpenAPI spec update via Stainless API (#713) --- .stats.yml | 2 +- api.md | 28 +- .../cloudforce_one/requests/message.py | 76 +- .../cloudforce_one/requests/priority.py | 88 +-- .../cloudforce_one/requests/requests.py | 112 ++- src/cloudflare/resources/intel/whois.py | 14 +- src/cloudflare/resources/rulesets/rules.py | 492 ------------- .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- .../types/rulesets/phase_get_response.py | 74 -- .../types/rulesets/phase_update_params.py | 56 -- .../types/rulesets/phase_update_response.py | 74 -- .../rulesets/phases/version_get_response.py | 74 -- .../types/rulesets/rule_create_params.py | 68 -- .../types/rulesets/rule_create_response.py | 74 -- .../types/rulesets/rule_delete_response.py | 74 -- .../types/rulesets/rule_edit_params.py | 74 -- .../types/rulesets/rule_edit_response.py | 74 -- .../types/rulesets/ruleset_create_params.py | 56 -- .../types/rulesets/ruleset_create_response.py | 74 -- .../types/rulesets/ruleset_get_response.py | 74 -- .../types/rulesets/ruleset_update_params.py | 56 -- .../types/rulesets/ruleset_update_response.py | 74 -- .../types/rulesets/version_get_response.py | 74 -- .../rulesets/versions/by_tag_get_response.py | 74 -- .../cloudforce_one/requests/test_message.py | 50 +- .../cloudforce_one/requests/test_priority.py | 50 +- .../cloudforce_one/test_requests.py | 82 +-- tests/api_resources/intel/test_whois.py | 18 +- tests/api_resources/rulesets/test_rules.py | 694 +----------------- 31 files changed, 291 insertions(+), 2584 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9ad762c7dd4..79bbbc19c23 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml diff --git a/api.md b/api.md index 7a0d3b24707..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index ecf569b9efa..bd7c415a47b 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -1003,126 +1003,6 @@ def create( """ ... - @overload - def create( - self, - ruleset_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. - - Args: - ruleset_id: The unique ID of the ruleset. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - - @overload - def create( - self, - ruleset_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. - - Args: - ruleset_id: The unique ID of the ruleset. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - def create( self, ruleset_id: str, @@ -1146,8 +1026,6 @@ def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] - | Literal["ddos_dynamic"] - | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -2252,128 +2130,6 @@ def edit( """ ... - @overload - def edit( - self, - rule_id: str, - *, - ruleset_id: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleEditResponse: - """ - Updates an existing rule in an account or zone ruleset. - - Args: - ruleset_id: The unique ID of the ruleset. - - rule_id: The unique ID of the rule. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - - @overload - def edit( - self, - rule_id: str, - *, - ruleset_id: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleEditResponse: - """ - Updates an existing rule in an account or zone ruleset. - - Args: - ruleset_id: The unique ID of the ruleset. - - rule_id: The unique ID of the rule. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - @required_args(["ruleset_id"]) def edit( self, @@ -2399,8 +2155,6 @@ def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] - | Literal["ddos_dynamic"] - | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object @@ -3439,126 +3193,6 @@ async def create( """ ... - @overload - async def create( - self, - ruleset_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. - - Args: - ruleset_id: The unique ID of the ruleset. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - - @overload - async def create( - self, - ruleset_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. - - Args: - ruleset_id: The unique ID of the ruleset. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - async def create( self, ruleset_id: str, @@ -3582,8 +3216,6 @@ async def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] - | Literal["ddos_dynamic"] - | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -4688,128 +4320,6 @@ async def edit( """ ... - @overload - async def edit( - self, - rule_id: str, - *, - ruleset_id: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleEditResponse: - """ - Updates an existing rule in an account or zone ruleset. - - Args: - ruleset_id: The unique ID of the ruleset. - - rule_id: The unique ID of the rule. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - - @overload - async def edit( - self, - rule_id: str, - *, - ruleset_id: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleEditResponse: - """ - Updates an existing rule in an account or zone ruleset. - - Args: - ruleset_id: The unique ID of the ruleset. - - rule_id: The unique ID of the rule. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - @required_args(["ruleset_id"]) async def edit( self, @@ -4835,8 +4345,6 @@ async def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] - | Literal["ddos_dynamic"] - | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index d88c9679596..476a9254497 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index 27f4398d8c9..d1e457901af 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -32,8 +32,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -112,58 +110,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -181,6 +127,4 @@ class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index 3e00524ec11..a92b28cb216 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index 3c7d7b05653..bf04a129360 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index f027d1e1dc5..e08bad9f0e5 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -76,8 +76,6 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", - "RulesetsDDoSDynamicRule", - "RulesetsForceConnectionCloseRule", ] @@ -1207,70 +1205,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" -class RulesetsDDoSDynamicRule(TypedDict, total=False): - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RulesetsForceConnectionCloseRule(TypedDict, total=False): - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - RuleCreateParams = Union[ BlockRule, ChallengeRule, @@ -1288,6 +1222,4 @@ class RulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, - RulesetsDDoSDynamicRule, - RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 04e3457f902..9a729d3fbe1 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 25d801cd5aa..1b6810d585e 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index 8382c7d8687..86c8418e7c8 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -76,8 +76,6 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", - "RulesetsDDoSDynamicRule", - "RulesetsForceConnectionCloseRule", ] @@ -1255,76 +1253,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" -class RulesetsDDoSDynamicRule(TypedDict, total=False): - ruleset_id: Required[str] - """The unique ID of the ruleset.""" - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RulesetsForceConnectionCloseRule(TypedDict, total=False): - ruleset_id: Required[str] - """The unique ID of the ruleset.""" - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - RuleEditParams = Union[ BlockRule, ChallengeRule, @@ -1342,6 +1270,4 @@ class RulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, - RulesetsDDoSDynamicRule, - RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 47dd4534324..3bf0100ef6f 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py index 4e372271bef..6d34a46fac5 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_params.py +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -32,8 +32,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -112,58 +110,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -181,6 +127,4 @@ class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index bfeacd5afd4..f87b58ceec8 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index 328ba42b25a..d5864df9b91 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py index e2ff9a9fcb8..ce723859ed9 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_params.py +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -32,8 +32,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -112,58 +110,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -181,6 +127,4 @@ class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index 9fb84d0d26a..d2aaaa91d6f 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index abb1cfae6c7..4d61f17e3ec 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index 058c549bc29..62def70b1fd 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py index b457e152f24..1496d433303 100644 --- a/tests/api_resources/rulesets/test_rules.py +++ b/tests/api_resources/rulesets/test_rules.py @@ -1394,156 +1394,6 @@ def test_path_params_create_overload_16(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_overload_17(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="ddos_dynamic", - action_parameters={}, - description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create_overload_17(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_overload_18(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="force_connection_close", - action_parameters={}, - description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create_overload_18(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_delete(self, client: Cloudflare) -> None: @@ -3222,184 +3072,6 @@ def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_overload_17(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="ddos_dynamic", - action_parameters={}, - description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_overload_18(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="force_connection_close", - action_parameters={}, - description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_edit_overload_18(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - class TestAsyncRules: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -4637,165 +4309,11 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy }, "origin_cache_control": True, "origin_error_page_passthru": True, - "read_timeout": 900, - "respect_strong_etags": True, - "serve_stale": {"disable_stale_while_updating": True}, - }, - description="Set cache settings when the hostname address is not example.com", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="log_custom_field", - action_parameters={ - "cookie_fields": [{"name": "cookie_name_1"}], - "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], - "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, }, - description="Log custom field when the IP address is not 1.1.1.1", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="ddos_dynamic", - action_parameters={}, - description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + description="Set cache settings when the hostname address is not example.com", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4805,7 +4323,7 @@ async def test_method_create_with_all_params_overload_17(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4818,7 +4336,7 @@ async def test_raw_response_create_overload_17(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4833,7 +4351,7 @@ async def test_streaming_response_create_overload_17(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -4854,7 +4372,7 @@ async def test_path_params_create_overload_17(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4863,14 +4381,18 @@ async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="force_connection_close", - action_parameters={}, - description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4880,7 +4402,7 @@ async def test_method_create_with_all_params_overload_18(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4893,7 +4415,7 @@ async def test_raw_response_create_overload_18(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4908,7 +4430,7 @@ async def test_streaming_response_create_overload_18(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -6604,181 +6126,3 @@ async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="ddos_dynamic", - action_parameters={}, - description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="force_connection_close", - action_parameters={}, - description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_edit_overload_18(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) From 7fb3d7ef1c03925d19bfd4a4f903d1466a324e30 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 10:19:23 +0000 Subject: [PATCH 233/532] feat(api): OpenAPI spec update via Stainless API (#714) --- .stats.yml | 2 +- src/cloudflare/resources/rulesets/rules.py | 492 +++++++++++++ .../types/rulesets/phase_get_response.py | 74 ++ .../types/rulesets/phase_update_params.py | 56 ++ .../types/rulesets/phase_update_response.py | 74 ++ .../rulesets/phases/version_get_response.py | 74 ++ .../types/rulesets/rule_create_params.py | 68 ++ .../types/rulesets/rule_create_response.py | 74 ++ .../types/rulesets/rule_delete_response.py | 74 ++ .../types/rulesets/rule_edit_params.py | 74 ++ .../types/rulesets/rule_edit_response.py | 74 ++ .../types/rulesets/ruleset_create_params.py | 56 ++ .../types/rulesets/ruleset_create_response.py | 74 ++ .../types/rulesets/ruleset_get_response.py | 74 ++ .../types/rulesets/ruleset_update_params.py | 56 ++ .../types/rulesets/ruleset_update_response.py | 74 ++ .../types/rulesets/version_get_response.py | 74 ++ .../rulesets/versions/by_tag_get_response.py | 74 ++ tests/api_resources/rulesets/test_rules.py | 688 +++++++++++++++++- 19 files changed, 2289 insertions(+), 17 deletions(-) diff --git a/.stats.yml b/.stats.yml index 79bbbc19c23..a0ecfde3be8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c7d13bc2b1e78dbaff4150bd44de8a77629619b38db7beb3ab2b0eccab2b0948.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e41a368def1043afe2da6c1a8caa6010941e5880eb2f70a62babdaaf9e03c251.yml diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index bd7c415a47b..ecf569b9efa 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -1003,6 +1003,126 @@ def create( """ ... + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + def create( self, ruleset_id: str, @@ -1026,6 +1146,8 @@ def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -2130,6 +2252,128 @@ def edit( """ ... + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + @required_args(["ruleset_id"]) def edit( self, @@ -2155,6 +2399,8 @@ def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object @@ -3193,6 +3439,126 @@ async def create( """ ... + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + async def create( self, ruleset_id: str, @@ -3216,6 +3582,8 @@ async def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -4320,6 +4688,128 @@ async def edit( """ ... + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + @required_args(["ruleset_id"]) async def edit( self, @@ -4345,6 +4835,8 @@ async def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index 476a9254497..d88c9679596 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index d1e457901af..27f4398d8c9 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index a92b28cb216..3e00524ec11 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index bf04a129360..3c7d7b05653 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index e08bad9f0e5..f027d1e1dc5 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -76,6 +76,8 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", + "RulesetsDDoSDynamicRule", + "RulesetsForceConnectionCloseRule", ] @@ -1205,6 +1207,70 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" +class RulesetsDDoSDynamicRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsForceConnectionCloseRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + RuleCreateParams = Union[ BlockRule, ChallengeRule, @@ -1222,4 +1288,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, + RulesetsDDoSDynamicRule, + RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 9a729d3fbe1..04e3457f902 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 1b6810d585e..25d801cd5aa 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index 86c8418e7c8..8382c7d8687 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -76,6 +76,8 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", + "RulesetsDDoSDynamicRule", + "RulesetsForceConnectionCloseRule", ] @@ -1253,6 +1255,76 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" +class RulesetsDDoSDynamicRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsForceConnectionCloseRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + RuleEditParams = Union[ BlockRule, ChallengeRule, @@ -1270,4 +1342,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, + RulesetsDDoSDynamicRule, + RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 3bf0100ef6f..47dd4534324 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py index 6d34a46fac5..4e372271bef 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_params.py +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index f87b58ceec8..bfeacd5afd4 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index d5864df9b91..328ba42b25a 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py index ce723859ed9..e2ff9a9fcb8 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_params.py +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index d2aaaa91d6f..9fb84d0d26a 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index 4d61f17e3ec..abb1cfae6c7 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index 62def70b1fd..058c549bc29 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py index 1496d433303..b457e152f24 100644 --- a/tests/api_resources/rulesets/test_rules.py +++ b/tests/api_resources/rulesets/test_rules.py @@ -1394,6 +1394,156 @@ def test_path_params_create_overload_16(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_17(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_delete(self, client: Cloudflare) -> None: @@ -3072,6 +3222,184 @@ def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + class TestAsyncRules: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -4313,7 +4641,86 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy "respect_strong_etags": True, "serve_stale": {"disable_stale_while_updating": True}, }, - description="Set cache settings when the hostname address is not example.com", + description="Set cache settings when the hostname address is not example.com", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4323,7 +4730,7 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4336,7 +4743,7 @@ async def test_raw_response_create_overload_15(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4351,7 +4758,7 @@ async def test_streaming_response_create_overload_15(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -4372,7 +4779,7 @@ async def test_path_params_create_overload_15(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4381,18 +4788,14 @@ async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="log_custom_field", - action_parameters={ - "cookie_fields": [{"name": "cookie_name_1"}], - "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], - "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], - }, - description="Log custom field when the IP address is not 1.1.1.1", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4402,7 +4805,7 @@ async def test_method_create_with_all_params_overload_16(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4415,7 +4818,7 @@ async def test_raw_response_create_overload_16(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4430,7 +4833,82 @@ async def test_streaming_response_create_overload_16(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_18(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -6126,3 +6604,181 @@ async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) From 03f1c568d06be069ca7bb5993e9254229d794815 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 11:29:05 +0000 Subject: [PATCH 234/532] feat(api): OpenAPI spec update via Stainless API (#715) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a0ecfde3be8..8af96c21552 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e41a368def1043afe2da6c1a8caa6010941e5880eb2f70a62babdaaf9e03c251.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml From ddb10a2361a2adbfe8073607aec7d0190a3f7ecd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 12:12:04 +0000 Subject: [PATCH 235/532] feat(api): OpenAPI spec update via Stainless API (#716) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8af96c21552..9ad762c7dd4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From dea253d90dd9f903dc01466398188eed54af94bf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 12:14:06 +0000 Subject: [PATCH 236/532] feat(api): OpenAPI spec update via Stainless API (#717) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9ad762c7dd4..8af96c21552 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml diff --git a/api.md b/api.md index 7a0d3b24707..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 49c0c0f46fc15923d11e984994ef908ff80250c4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 12:37:51 +0000 Subject: [PATCH 237/532] feat(api): OpenAPI spec update via Stainless API (#718) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8af96c21552..9ad762c7dd4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 457ac8295b5195508086a73cf8faf740a2a91591 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 15:17:30 +0000 Subject: [PATCH 238/532] feat(api): OpenAPI spec update via Stainless API (#719) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9ad762c7dd4..8af96c21552 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml diff --git a/api.md b/api.md index 7a0d3b24707..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 359cd8e8121618f6c43ef4415a122613f2cf1baa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 15:24:25 +0000 Subject: [PATCH 239/532] feat(api): OpenAPI spec update via Stainless API (#720) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8af96c21552..9ad762c7dd4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 0a5e98b7f27a7440d44b23ac82a97ec9cbf04d7c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 15:30:22 +0000 Subject: [PATCH 240/532] feat(api): OpenAPI spec update via Stainless API (#721) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9ad762c7dd4..8af96c21552 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml diff --git a/api.md b/api.md index 7a0d3b24707..d80f897365c 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From e5ba886179519b93c9324c08487cc41b3cd052c7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 16:29:23 +0000 Subject: [PATCH 241/532] feat(api): OpenAPI spec update via Stainless API (#722) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8af96c21552..a0ecfde3be8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e41a368def1043afe2da6c1a8caa6010941e5880eb2f70a62babdaaf9e03c251.yml From 014819d5d90311d89c2d74870b5d9be61896fb65 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 16:50:35 +0000 Subject: [PATCH 242/532] feat(api): OpenAPI spec update via Stainless API (#723) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a0ecfde3be8..8af96c21552 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e41a368def1043afe2da6c1a8caa6010941e5880eb2f70a62babdaaf9e03c251.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml From 6cceaf781a7e5c5df4d69c0ce308399d16ccb081 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 16:55:02 +0000 Subject: [PATCH 243/532] feat(api): OpenAPI spec update via Stainless API (#724) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8af96c21552..f82336db855 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b7025f4a2d83f57c47f6364ba5805eabd35a10f387bb36b812f7b0d7682bcabe.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cc4844109da35513705ddeb5d6f67b88d237abcc81b7433c0af4ea37feeb44c2.yml diff --git a/api.md b/api.md index d80f897365c..7a0d3b24707 100644 --- a/api.md +++ b/api.md @@ -3796,7 +3796,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 4b98eabcc7782cffd33bc3e90b102aabd28accfc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 17:28:44 +0000 Subject: [PATCH 244/532] feat(api): OpenAPI spec update via Stainless API (#725) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f82336db855..9ad762c7dd4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cc4844109da35513705ddeb5d6f67b88d237abcc81b7433c0af4ea37feeb44c2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml From cb61101d98a02f77a21e538964b193dc33d2e9a3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 00:55:35 +0000 Subject: [PATCH 245/532] feat(api): update via SDK Studio (#726) --- .stats.yml | 4 +- api.md | 182 +- .../cloudforce_one/requests/message.py | 76 +- .../cloudforce_one/requests/priority.py | 88 +- .../cloudforce_one/requests/requests.py | 112 +- src/cloudflare/resources/intel/whois.py | 14 +- src/cloudflare/resources/rulesets/rules.py | 492 --- .../resources/zero_trust/__init__.py | 14 - .../resources/zero_trust/access/__init__.py | 84 - .../resources/zero_trust/access/access.py | 194 - .../access/applications/__init__.py | 14 - .../access/applications/applications.py | 32 - .../zero_trust/access/applications/cas.py | 404 -- .../access/applications/policies.py | 1007 ----- .../resources/zero_trust/access/bookmarks.py | 548 --- .../access/certificates/certificates.py | 407 +- .../zero_trust/access/custom_pages.py | 636 --- .../resources/zero_trust/access/groups.py | 437 +-- .../resources/zero_trust/access/keys.py | 387 -- .../zero_trust/access/logs/__init__.py | 33 - .../zero_trust/access/logs/access_requests.py | 158 - .../resources/zero_trust/access/logs/logs.py | 80 - .../zero_trust/access/service_tokens.py | 611 +-- .../resources/zero_trust/access/tags.py | 566 --- .../zero_trust/access/users/__init__.py | 61 - .../access/users/active_sessions.py | 271 -- .../zero_trust/access/users/failed_logins.py | 161 - .../access/users/last_seen_identity.py | 168 - .../zero_trust/access/users/users.py | 247 -- .../zero_trust/identity_providers.py | 2131 +--------- src/cloudflare/resources/zero_trust/seats.py | 169 - .../resources/zero_trust/zero_trust.py | 32 - src/cloudflare/types/api_gateway/__init__.py | 1 - src/cloudflare/types/api_gateway/schema.py | 19 - .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- .../types/rulesets/phase_get_response.py | 74 - .../types/rulesets/phase_update_params.py | 56 - .../types/rulesets/phase_update_response.py | 74 - .../rulesets/phases/version_get_response.py | 74 - .../types/rulesets/rule_create_params.py | 68 - .../types/rulesets/rule_create_response.py | 74 - .../types/rulesets/rule_delete_response.py | 74 - .../types/rulesets/rule_edit_params.py | 74 - .../types/rulesets/rule_edit_response.py | 74 - .../types/rulesets/ruleset_create_params.py | 56 - .../types/rulesets/ruleset_create_response.py | 74 - .../types/rulesets/ruleset_get_response.py | 74 - .../types/rulesets/ruleset_update_params.py | 56 - .../types/rulesets/ruleset_update_response.py | 74 - .../types/rulesets/version_get_response.py | 74 - .../rulesets/versions/by_tag_get_response.py | 74 - src/cloudflare/types/zero_trust/__init__.py | 5 - .../types/zero_trust/access/__init__.py | 24 - .../types/zero_trust/access/access_user.py | 41 - .../access/applications/__init__.py | 10 - .../access/applications/ca_create_response.py | 7 - .../access/applications/ca_delete_response.py | 12 - .../access/applications/ca_get_response.py | 7 - .../applications/policy_create_params.py | 79 - .../applications/policy_create_response.py | 73 - .../applications/policy_delete_response.py | 12 - .../applications/policy_get_response.py | 73 - .../applications/policy_list_response.py | 73 - .../applications/policy_update_params.py | 82 - .../applications/policy_update_response.py | 73 - .../types/zero_trust/access/bookmark.py | 29 - .../access/bookmark_create_params.py | 13 - .../access/bookmark_delete_response.py | 12 - .../access/bookmark_update_params.py | 13 - .../access/certificate_delete_response.py | 12 - .../access/certificate_update_params.py | 24 - .../types/zero_trust/access/custom_page.py | 30 - .../access/custom_page_create_params.py | 21 - .../access/custom_page_delete_response.py | 12 - .../access/custom_page_update_params.py | 24 - .../access/custom_page_without_html.py | 27 - .../access/group_delete_response.py | 12 - .../zero_trust/access/group_update_params.py | 42 - .../zero_trust/access/key_get_response.py | 7 - .../zero_trust/access/key_rotate_response.py | 7 - .../zero_trust/access/key_update_params.py | 12 - .../zero_trust/access/key_update_response.py | 7 - .../types/zero_trust/access/logs/__init__.py | 3 - .../logs/access_request_list_response.py | 9 - .../access/service_token_rotate_response.py | 40 - .../access/service_token_update_params.py | 25 - src/cloudflare/types/zero_trust/access/tag.py | 20 - .../zero_trust/access/tag_create_params.py | 12 - .../zero_trust/access/tag_delete_response.py | 12 - .../zero_trust/access/tag_update_params.py | 15 - .../types/zero_trust/access/users/__init__.py | 5 - .../users/active_session_get_response.py | 98 - .../users/active_session_list_response.py | 37 - .../users/failed_login_list_response.py | 13 - .../types/zero_trust/access/users/identity.py | 96 - .../identity_provider_delete_response.py | 12 - .../identity_provider_update_params.py | 697 ---- src/cloudflare/types/zero_trust/seat.py | 23 - .../types/zero_trust/seat_edit_params.py | 20 - .../types/zero_trust/seat_edit_response.py | 9 - .../cloudforce_one/requests/test_message.py | 50 +- .../cloudforce_one/requests/test_priority.py | 50 +- .../cloudforce_one/test_requests.py | 82 +- tests/api_resources/intel/test_whois.py | 18 +- tests/api_resources/rulesets/test_rules.py | 694 +--- .../access/applications/test_cas.py | 406 +- .../access/applications/test_policies.py | 1105 ------ .../zero_trust/access/logs/__init__.py | 1 - .../access/logs/test_access_requests.py | 98 - .../zero_trust/access/test_bookmarks.py | 506 --- .../zero_trust/access/test_certificates.py | 423 +- .../zero_trust/access/test_custom_pages.py | 567 --- .../zero_trust/access/test_groups.py | 513 +-- .../zero_trust/access/test_keys.py | 258 -- .../zero_trust/access/test_service_tokens.py | 604 +-- .../zero_trust/access/test_tags.py | 481 --- .../zero_trust/access/test_users.py | 99 - .../zero_trust/access/users/__init__.py | 1 - .../access/users/test_active_sessions.py | 239 -- .../access/users/test_failed_logins.py | 119 - .../access/users/test_last_seen_identity.py | 118 - .../zero_trust/test_identity_providers.py | 3451 +---------------- tests/api_resources/zero_trust/test_seats.py | 218 -- 125 files changed, 627 insertions(+), 22504 deletions(-) delete mode 100644 src/cloudflare/resources/zero_trust/access/applications/policies.py delete mode 100644 src/cloudflare/resources/zero_trust/access/bookmarks.py delete mode 100644 src/cloudflare/resources/zero_trust/access/custom_pages.py delete mode 100644 src/cloudflare/resources/zero_trust/access/keys.py delete mode 100644 src/cloudflare/resources/zero_trust/access/logs/__init__.py delete mode 100644 src/cloudflare/resources/zero_trust/access/logs/access_requests.py delete mode 100644 src/cloudflare/resources/zero_trust/access/logs/logs.py delete mode 100644 src/cloudflare/resources/zero_trust/access/tags.py delete mode 100644 src/cloudflare/resources/zero_trust/access/users/__init__.py delete mode 100644 src/cloudflare/resources/zero_trust/access/users/active_sessions.py delete mode 100644 src/cloudflare/resources/zero_trust/access/users/failed_logins.py delete mode 100644 src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py delete mode 100644 src/cloudflare/resources/zero_trust/access/users/users.py delete mode 100644 src/cloudflare/resources/zero_trust/seats.py delete mode 100644 src/cloudflare/types/api_gateway/schema.py delete mode 100644 src/cloudflare/types/zero_trust/access/access_user.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/ca_create_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/ca_delete_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/ca_get_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_create_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_create_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_delete_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_get_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_list_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_update_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/bookmark.py delete mode 100644 src/cloudflare/types/zero_trust/access/bookmark_create_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/bookmark_delete_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/bookmark_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/certificate_delete_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/certificate_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/custom_page.py delete mode 100644 src/cloudflare/types/zero_trust/access/custom_page_create_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/custom_page_delete_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/custom_page_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/custom_page_without_html.py delete mode 100644 src/cloudflare/types/zero_trust/access/group_delete_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/group_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/key_get_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/key_rotate_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/key_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/key_update_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/service_token_rotate_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/service_token_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/tag.py delete mode 100644 src/cloudflare/types/zero_trust/access/tag_create_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/tag_delete_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/tag_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/access/users/active_session_get_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/users/active_session_list_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/users/failed_login_list_response.py delete mode 100644 src/cloudflare/types/zero_trust/access/users/identity.py delete mode 100644 src/cloudflare/types/zero_trust/identity_provider_delete_response.py delete mode 100644 src/cloudflare/types/zero_trust/identity_provider_update_params.py delete mode 100644 src/cloudflare/types/zero_trust/seat.py delete mode 100644 src/cloudflare/types/zero_trust/seat_edit_params.py delete mode 100644 src/cloudflare/types/zero_trust/seat_edit_response.py delete mode 100644 tests/api_resources/zero_trust/access/applications/test_policies.py delete mode 100644 tests/api_resources/zero_trust/access/logs/__init__.py delete mode 100644 tests/api_resources/zero_trust/access/logs/test_access_requests.py delete mode 100644 tests/api_resources/zero_trust/access/test_bookmarks.py delete mode 100644 tests/api_resources/zero_trust/access/test_custom_pages.py delete mode 100644 tests/api_resources/zero_trust/access/test_keys.py delete mode 100644 tests/api_resources/zero_trust/access/test_tags.py delete mode 100644 tests/api_resources/zero_trust/access/test_users.py delete mode 100644 tests/api_resources/zero_trust/access/users/__init__.py delete mode 100644 tests/api_resources/zero_trust/access/users/test_active_sessions.py delete mode 100644 tests/api_resources/zero_trust/access/users/test_failed_logins.py delete mode 100644 tests/api_resources/zero_trust/access/users/test_last_seen_identity.py delete mode 100644 tests/api_resources/zero_trust/test_seats.py diff --git a/.stats.yml b/.stats.yml index 9ad762c7dd4..30e67c9adb7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15197dfa1bffc0cc6e86526b7f3b95282aa7af4a5ea87406312e87f0586d2dfa.yml +configured_endpoints: 1274 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-14c9c9adbd65eee546c4f54d95b7627f10b02185348e334a68cbebbe3442733e.yml diff --git a/api.md b/api.md index 7a0d3b24707..0a50bcdb16f 100644 --- a/api.md +++ b/api.md @@ -3051,7 +3051,6 @@ Types: from cloudflare.types.api_gateway import ( Message, PublicSchema, - Schema, SchemaUpload, UserSchemaDeleteResponse, ) @@ -3796,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -5179,17 +5178,13 @@ from cloudflare.types.zero_trust import ( IdentityProviderType, ScimConfig, IdentityProviderListResponse, - IdentityProviderDeleteResponse, ) ``` Methods: - client.zero_trust.identity_providers.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.identity_providers.update(uuid, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.identity_providers.list(\*, account_id, zone_id) -> SyncSinglePage[IdentityProviderListResponse] -- client.zero_trust.identity_providers.delete(uuid, \*, account_id, zone_id) -> Optional -- client.zero_trust.identity_providers.get(uuid, \*, account_id, zone_id) -> Optional ## Organizations @@ -5211,13 +5206,9 @@ Methods: Types: ```python -from cloudflare.types.zero_trust import Seat, SeatEditResponse +from cloudflare.types.zero_trust import Seat ``` -Methods: - -- client.zero_trust.seats.edit(identifier, \*\*params) -> Optional - ## Access Types: @@ -5290,20 +5281,12 @@ Methods: Types: ```python -from cloudflare.types.zero_trust.access.applications import ( - CA, - CACreateResponse, - CADeleteResponse, - CAGetResponse, -) +from cloudflare.types.zero_trust.access.applications import CA ``` Methods: -- client.zero_trust.access.applications.cas.create(uuid, \*, account_id, zone_id) -> Optional - client.zero_trust.access.applications.cas.list(\*, account_id, zone_id) -> SyncSinglePage[CA] -- client.zero_trust.access.applications.cas.delete(uuid, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.cas.get(uuid, \*, account_id, zone_id) -> Optional #### UserPolicyChecks @@ -5325,44 +5308,21 @@ Methods: Types: ```python -from cloudflare.types.zero_trust.access.applications import ( - ApprovalGroup, - Policy, - PolicyCreateResponse, - PolicyUpdateResponse, - PolicyListResponse, - PolicyDeleteResponse, - PolicyGetResponse, -) +from cloudflare.types.zero_trust.access.applications import ApprovalGroup, Policy ``` -Methods: - -- client.zero_trust.access.applications.policies.create(uuid, \*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.policies.update(uuid, \*, uuid1, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.applications.policies.list(uuid, \*, account_id, zone_id) -> SyncSinglePage[PolicyListResponse] -- client.zero_trust.access.applications.policies.delete(uuid, \*, uuid1, account_id, zone_id) -> Optional -- client.zero_trust.access.applications.policies.get(uuid, \*, uuid1, account_id, zone_id) -> Optional - ### Certificates Types: ```python -from cloudflare.types.zero_trust.access import ( - AssociatedHostnames, - Certificate, - CertificateDeleteResponse, -) +from cloudflare.types.zero_trust.access import AssociatedHostnames, Certificate ``` Methods: - client.zero_trust.access.certificates.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.certificates.update(uuid, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.certificates.list(\*, account_id, zone_id) -> SyncSinglePage[Certificate] -- client.zero_trust.access.certificates.delete(uuid, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.certificates.get(uuid, \*, account_id, zone_id) -> Optional #### Settings @@ -5386,69 +5346,35 @@ Methods: Types: ```python -from cloudflare.types.zero_trust.access import ZeroTrustGroup, GroupDeleteResponse +from cloudflare.types.zero_trust.access import ZeroTrustGroup ``` Methods: - client.zero_trust.access.groups.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.groups.update(uuid, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.groups.list(\*, account_id, zone_id) -> SyncSinglePage[ZeroTrustGroup] -- client.zero_trust.access.groups.delete(uuid, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.groups.get(uuid, \*, account_id, zone_id) -> Optional ### ServiceTokens Types: ```python -from cloudflare.types.zero_trust.access import ( - ServiceToken, - ServiceTokenCreateResponse, - ServiceTokenRotateResponse, -) +from cloudflare.types.zero_trust.access import ServiceToken, ServiceTokenCreateResponse ``` Methods: - client.zero_trust.access.service_tokens.create(\*, account_id, zone_id, \*\*params) -> Optional -- client.zero_trust.access.service_tokens.update(uuid, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.service_tokens.list(\*, account_id, zone_id) -> SyncSinglePage[ServiceToken] -- client.zero_trust.access.service_tokens.delete(uuid, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.service_tokens.get(uuid, \*, account_id, zone_id) -> Optional -- client.zero_trust.access.service_tokens.refresh(uuid, \*, identifier) -> Optional -- client.zero_trust.access.service_tokens.rotate(uuid, \*, identifier) -> Optional ### Bookmarks Types: ```python -from cloudflare.types.zero_trust.access import Bookmark, BookmarkDeleteResponse +from cloudflare.types.zero_trust.access import Bookmark ``` -Methods: - -- client.zero_trust.access.bookmarks.create(uuid, \*, identifier, \*\*params) -> Optional -- client.zero_trust.access.bookmarks.update(uuid, \*, identifier, \*\*params) -> Optional -- client.zero_trust.access.bookmarks.list(identifier) -> SyncSinglePage[Bookmark] -- client.zero_trust.access.bookmarks.delete(uuid, \*, identifier) -> Optional -- client.zero_trust.access.bookmarks.get(uuid, \*, identifier) -> Optional - -### Keys - -Types: - -```python -from cloudflare.types.zero_trust.access import KeyUpdateResponse, KeyGetResponse, KeyRotateResponse -``` - -Methods: - -- client.zero_trust.access.keys.update(identifier, \*\*params) -> Optional -- client.zero_trust.access.keys.get(identifier) -> Optional -- client.zero_trust.access.keys.rotate(identifier) -> Optional - ### Logs #### AccessRequests @@ -5456,13 +5382,9 @@ Methods: Types: ```python -from cloudflare.types.zero_trust.access.logs import AccessRequests, AccessRequestListResponse +from cloudflare.types.zero_trust.access.logs import AccessRequests ``` -Methods: - -- client.zero_trust.access.logs.access_requests.list(identifier) -> Optional - ### Users Types: @@ -5471,26 +5393,6 @@ Types: from cloudflare.types.zero_trust.access import AccessUser ``` -Methods: - -- client.zero_trust.access.users.list(identifier) -> SyncSinglePage[AccessUser] - -#### ActiveSessions - -Types: - -```python -from cloudflare.types.zero_trust.access.users import ( - ActiveSessionListResponse, - ActiveSessionGetResponse, -) -``` - -Methods: - -- client.zero_trust.access.users.active_sessions.list(id, \*, identifier) -> SyncSinglePage[ActiveSessionListResponse] -- client.zero_trust.access.users.active_sessions.get(nonce, \*, identifier, id) -> Optional - #### LastSeenIdentity Types: @@ -5499,58 +5401,22 @@ Types: from cloudflare.types.zero_trust.access.users import Identity ``` -Methods: - -- client.zero_trust.access.users.last_seen_identity.get(id, \*, identifier) -> Optional - -#### FailedLogins - -Types: - -```python -from cloudflare.types.zero_trust.access.users import FailedLoginListResponse -``` - -Methods: - -- client.zero_trust.access.users.failed_logins.list(id, \*, identifier) -> SyncSinglePage[FailedLoginListResponse] - ### CustomPages Types: ```python -from cloudflare.types.zero_trust.access import ( - CustomPage, - CustomPageWithoutHTML, - CustomPageDeleteResponse, -) +from cloudflare.types.zero_trust.access import CustomPage, CustomPageWithoutHTML ``` -Methods: - -- client.zero_trust.access.custom_pages.create(identifier, \*\*params) -> Optional -- client.zero_trust.access.custom_pages.update(uuid, \*, identifier, \*\*params) -> Optional -- client.zero_trust.access.custom_pages.list(identifier) -> SyncSinglePage[CustomPageWithoutHTML] -- client.zero_trust.access.custom_pages.delete(uuid, \*, identifier) -> Optional -- client.zero_trust.access.custom_pages.get(uuid, \*, identifier) -> Optional - ### Tags Types: ```python -from cloudflare.types.zero_trust.access import Tag, TagDeleteResponse +from cloudflare.types.zero_trust.access import Tag ``` -Methods: - -- client.zero_trust.access.tags.create(identifier, \*\*params) -> Optional -- client.zero_trust.access.tags.update(tag_name, \*, identifier, \*\*params) -> Optional -- client.zero_trust.access.tags.list(identifier) -> SyncSinglePage[Tag] -- client.zero_trust.access.tags.delete(name, \*, identifier) -> Optional -- client.zero_trust.access.tags.get(name, \*, identifier) -> Optional - ## DEX Types: @@ -7643,14 +7509,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7532,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7552,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index ecf569b9efa..bd7c415a47b 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -1003,126 +1003,6 @@ def create( """ ... - @overload - def create( - self, - ruleset_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. - - Args: - ruleset_id: The unique ID of the ruleset. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - - @overload - def create( - self, - ruleset_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. - - Args: - ruleset_id: The unique ID of the ruleset. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - def create( self, ruleset_id: str, @@ -1146,8 +1026,6 @@ def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] - | Literal["ddos_dynamic"] - | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -2252,128 +2130,6 @@ def edit( """ ... - @overload - def edit( - self, - rule_id: str, - *, - ruleset_id: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleEditResponse: - """ - Updates an existing rule in an account or zone ruleset. - - Args: - ruleset_id: The unique ID of the ruleset. - - rule_id: The unique ID of the rule. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - - @overload - def edit( - self, - rule_id: str, - *, - ruleset_id: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleEditResponse: - """ - Updates an existing rule in an account or zone ruleset. - - Args: - ruleset_id: The unique ID of the ruleset. - - rule_id: The unique ID of the rule. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - @required_args(["ruleset_id"]) def edit( self, @@ -2399,8 +2155,6 @@ def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] - | Literal["ddos_dynamic"] - | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object @@ -3439,126 +3193,6 @@ async def create( """ ... - @overload - async def create( - self, - ruleset_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. - - Args: - ruleset_id: The unique ID of the ruleset. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - - @overload - async def create( - self, - ruleset_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. - - Args: - ruleset_id: The unique ID of the ruleset. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - async def create( self, ruleset_id: str, @@ -3582,8 +3216,6 @@ async def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] - | Literal["ddos_dynamic"] - | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -4688,128 +4320,6 @@ async def edit( """ ... - @overload - async def edit( - self, - rule_id: str, - *, - ruleset_id: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleEditResponse: - """ - Updates an existing rule in an account or zone ruleset. - - Args: - ruleset_id: The unique ID of the ruleset. - - rule_id: The unique ID of the rule. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - - @overload - async def edit( - self, - rule_id: str, - *, - ruleset_id: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - id: str | NotGiven = NOT_GIVEN, - action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - logging: LoggingParam | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleEditResponse: - """ - Updates an existing rule in an account or zone ruleset. - - Args: - ruleset_id: The unique ID of the ruleset. - - rule_id: The unique ID of the rule. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - id: The unique ID of the rule. - - action: The action to perform when the rule matches. - - action_parameters: The parameters configuring the rule's action. - - description: An informative description of the rule. - - enabled: Whether the rule should be executed. - - expression: The expression defining which traffic will match the rule. - - logging: An object configuring the rule's logging behavior. - - ref: The reference of the rule (the rule ID by default). - - 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 - """ - ... - @required_args(["ruleset_id"]) async def edit( self, @@ -4835,8 +4345,6 @@ async def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] - | Literal["ddos_dynamic"] - | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object diff --git a/src/cloudflare/resources/zero_trust/__init__.py b/src/cloudflare/resources/zero_trust/__init__.py index 7703df18c9b..0eac27aeedb 100644 --- a/src/cloudflare/resources/zero_trust/__init__.py +++ b/src/cloudflare/resources/zero_trust/__init__.py @@ -16,14 +16,6 @@ DLPResourceWithStreamingResponse, AsyncDLPResourceWithStreamingResponse, ) -from .seats import ( - SeatsResource, - AsyncSeatsResource, - SeatsResourceWithRawResponse, - AsyncSeatsResourceWithRawResponse, - SeatsResourceWithStreamingResponse, - AsyncSeatsResourceWithStreamingResponse, -) from .access import ( AccessResource, AsyncAccessResource, @@ -124,12 +116,6 @@ "AsyncOrganizationsResourceWithRawResponse", "OrganizationsResourceWithStreamingResponse", "AsyncOrganizationsResourceWithStreamingResponse", - "SeatsResource", - "AsyncSeatsResource", - "SeatsResourceWithRawResponse", - "AsyncSeatsResourceWithRawResponse", - "SeatsResourceWithStreamingResponse", - "AsyncSeatsResourceWithStreamingResponse", "AccessResource", "AsyncAccessResource", "AccessResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/access/__init__.py b/src/cloudflare/resources/zero_trust/access/__init__.py index b34af407a86..7f6771c4683 100644 --- a/src/cloudflare/resources/zero_trust/access/__init__.py +++ b/src/cloudflare/resources/zero_trust/access/__init__.py @@ -1,37 +1,5 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from .keys import ( - KeysResource, - AsyncKeysResource, - KeysResourceWithRawResponse, - AsyncKeysResourceWithRawResponse, - KeysResourceWithStreamingResponse, - AsyncKeysResourceWithStreamingResponse, -) -from .logs import ( - LogsResource, - AsyncLogsResource, - LogsResourceWithRawResponse, - AsyncLogsResourceWithRawResponse, - LogsResourceWithStreamingResponse, - AsyncLogsResourceWithStreamingResponse, -) -from .tags import ( - TagsResource, - AsyncTagsResource, - TagsResourceWithRawResponse, - AsyncTagsResourceWithRawResponse, - TagsResourceWithStreamingResponse, - AsyncTagsResourceWithStreamingResponse, -) -from .users import ( - UsersResource, - AsyncUsersResource, - UsersResourceWithRawResponse, - AsyncUsersResourceWithRawResponse, - UsersResourceWithStreamingResponse, - AsyncUsersResourceWithStreamingResponse, -) from .access import ( AccessResource, AsyncAccessResource, @@ -48,14 +16,6 @@ GroupsResourceWithStreamingResponse, AsyncGroupsResourceWithStreamingResponse, ) -from .bookmarks import ( - BookmarksResource, - AsyncBookmarksResource, - BookmarksResourceWithRawResponse, - AsyncBookmarksResourceWithRawResponse, - BookmarksResourceWithStreamingResponse, - AsyncBookmarksResourceWithStreamingResponse, -) from .applications import ( ApplicationsResource, AsyncApplicationsResource, @@ -72,14 +32,6 @@ CertificatesResourceWithStreamingResponse, AsyncCertificatesResourceWithStreamingResponse, ) -from .custom_pages import ( - CustomPagesResource, - AsyncCustomPagesResource, - CustomPagesResourceWithRawResponse, - AsyncCustomPagesResourceWithRawResponse, - CustomPagesResourceWithStreamingResponse, - AsyncCustomPagesResourceWithStreamingResponse, -) from .service_tokens import ( ServiceTokensResource, AsyncServiceTokensResource, @@ -114,42 +66,6 @@ "AsyncServiceTokensResourceWithRawResponse", "ServiceTokensResourceWithStreamingResponse", "AsyncServiceTokensResourceWithStreamingResponse", - "BookmarksResource", - "AsyncBookmarksResource", - "BookmarksResourceWithRawResponse", - "AsyncBookmarksResourceWithRawResponse", - "BookmarksResourceWithStreamingResponse", - "AsyncBookmarksResourceWithStreamingResponse", - "KeysResource", - "AsyncKeysResource", - "KeysResourceWithRawResponse", - "AsyncKeysResourceWithRawResponse", - "KeysResourceWithStreamingResponse", - "AsyncKeysResourceWithStreamingResponse", - "LogsResource", - "AsyncLogsResource", - "LogsResourceWithRawResponse", - "AsyncLogsResourceWithRawResponse", - "LogsResourceWithStreamingResponse", - "AsyncLogsResourceWithStreamingResponse", - "UsersResource", - "AsyncUsersResource", - "UsersResourceWithRawResponse", - "AsyncUsersResourceWithRawResponse", - "UsersResourceWithStreamingResponse", - "AsyncUsersResourceWithStreamingResponse", - "CustomPagesResource", - "AsyncCustomPagesResource", - "CustomPagesResourceWithRawResponse", - "AsyncCustomPagesResourceWithRawResponse", - "CustomPagesResourceWithStreamingResponse", - "AsyncCustomPagesResourceWithStreamingResponse", - "TagsResource", - "AsyncTagsResource", - "TagsResourceWithRawResponse", - "AsyncTagsResourceWithRawResponse", - "TagsResourceWithStreamingResponse", - "AsyncTagsResourceWithStreamingResponse", "AccessResource", "AsyncAccessResource", "AccessResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/access/access.py b/src/cloudflare/resources/zero_trust/access/access.py index 6707c0f7745..f9f03534570 100644 --- a/src/cloudflare/resources/zero_trust/access/access.py +++ b/src/cloudflare/resources/zero_trust/access/access.py @@ -2,38 +2,6 @@ from __future__ import annotations -from .keys import ( - KeysResource, - AsyncKeysResource, - KeysResourceWithRawResponse, - AsyncKeysResourceWithRawResponse, - KeysResourceWithStreamingResponse, - AsyncKeysResourceWithStreamingResponse, -) -from .logs import ( - LogsResource, - AsyncLogsResource, - LogsResourceWithRawResponse, - AsyncLogsResourceWithRawResponse, - LogsResourceWithStreamingResponse, - AsyncLogsResourceWithStreamingResponse, -) -from .tags import ( - TagsResource, - AsyncTagsResource, - TagsResourceWithRawResponse, - AsyncTagsResourceWithRawResponse, - TagsResourceWithStreamingResponse, - AsyncTagsResourceWithStreamingResponse, -) -from .users import ( - UsersResource, - AsyncUsersResource, - UsersResourceWithRawResponse, - AsyncUsersResourceWithRawResponse, - UsersResourceWithStreamingResponse, - AsyncUsersResourceWithStreamingResponse, -) from .groups import ( GroupsResource, AsyncGroupsResource, @@ -42,17 +10,7 @@ GroupsResourceWithStreamingResponse, AsyncGroupsResourceWithStreamingResponse, ) -from .bookmarks import ( - BookmarksResource, - AsyncBookmarksResource, - BookmarksResourceWithRawResponse, - AsyncBookmarksResourceWithRawResponse, - BookmarksResourceWithStreamingResponse, - AsyncBookmarksResourceWithStreamingResponse, -) -from .logs.logs import LogsResource, AsyncLogsResource from ...._compat import cached_property -from .users.users import UsersResource, AsyncUsersResource from ...._resource import SyncAPIResource, AsyncAPIResource from .applications import ( ApplicationsResource, @@ -70,14 +28,6 @@ CertificatesResourceWithStreamingResponse, AsyncCertificatesResourceWithStreamingResponse, ) -from .custom_pages import ( - CustomPagesResource, - AsyncCustomPagesResource, - CustomPagesResourceWithRawResponse, - AsyncCustomPagesResourceWithRawResponse, - CustomPagesResourceWithStreamingResponse, - AsyncCustomPagesResourceWithStreamingResponse, -) from .service_tokens import ( ServiceTokensResource, AsyncServiceTokensResource, @@ -109,30 +59,6 @@ def groups(self) -> GroupsResource: def service_tokens(self) -> ServiceTokensResource: return ServiceTokensResource(self._client) - @cached_property - def bookmarks(self) -> BookmarksResource: - return BookmarksResource(self._client) - - @cached_property - def keys(self) -> KeysResource: - return KeysResource(self._client) - - @cached_property - def logs(self) -> LogsResource: - return LogsResource(self._client) - - @cached_property - def users(self) -> UsersResource: - return UsersResource(self._client) - - @cached_property - def custom_pages(self) -> CustomPagesResource: - return CustomPagesResource(self._client) - - @cached_property - def tags(self) -> TagsResource: - return TagsResource(self._client) - @cached_property def with_raw_response(self) -> AccessResourceWithRawResponse: return AccessResourceWithRawResponse(self) @@ -159,30 +85,6 @@ def groups(self) -> AsyncGroupsResource: def service_tokens(self) -> AsyncServiceTokensResource: return AsyncServiceTokensResource(self._client) - @cached_property - def bookmarks(self) -> AsyncBookmarksResource: - return AsyncBookmarksResource(self._client) - - @cached_property - def keys(self) -> AsyncKeysResource: - return AsyncKeysResource(self._client) - - @cached_property - def logs(self) -> AsyncLogsResource: - return AsyncLogsResource(self._client) - - @cached_property - def users(self) -> AsyncUsersResource: - return AsyncUsersResource(self._client) - - @cached_property - def custom_pages(self) -> AsyncCustomPagesResource: - return AsyncCustomPagesResource(self._client) - - @cached_property - def tags(self) -> AsyncTagsResource: - return AsyncTagsResource(self._client) - @cached_property def with_raw_response(self) -> AsyncAccessResourceWithRawResponse: return AsyncAccessResourceWithRawResponse(self) @@ -212,30 +114,6 @@ def groups(self) -> GroupsResourceWithRawResponse: def service_tokens(self) -> ServiceTokensResourceWithRawResponse: return ServiceTokensResourceWithRawResponse(self._access.service_tokens) - @cached_property - def bookmarks(self) -> BookmarksResourceWithRawResponse: - return BookmarksResourceWithRawResponse(self._access.bookmarks) - - @cached_property - def keys(self) -> KeysResourceWithRawResponse: - return KeysResourceWithRawResponse(self._access.keys) - - @cached_property - def logs(self) -> LogsResourceWithRawResponse: - return LogsResourceWithRawResponse(self._access.logs) - - @cached_property - def users(self) -> UsersResourceWithRawResponse: - return UsersResourceWithRawResponse(self._access.users) - - @cached_property - def custom_pages(self) -> CustomPagesResourceWithRawResponse: - return CustomPagesResourceWithRawResponse(self._access.custom_pages) - - @cached_property - def tags(self) -> TagsResourceWithRawResponse: - return TagsResourceWithRawResponse(self._access.tags) - class AsyncAccessResourceWithRawResponse: def __init__(self, access: AsyncAccessResource) -> None: @@ -257,30 +135,6 @@ def groups(self) -> AsyncGroupsResourceWithRawResponse: def service_tokens(self) -> AsyncServiceTokensResourceWithRawResponse: return AsyncServiceTokensResourceWithRawResponse(self._access.service_tokens) - @cached_property - def bookmarks(self) -> AsyncBookmarksResourceWithRawResponse: - return AsyncBookmarksResourceWithRawResponse(self._access.bookmarks) - - @cached_property - def keys(self) -> AsyncKeysResourceWithRawResponse: - return AsyncKeysResourceWithRawResponse(self._access.keys) - - @cached_property - def logs(self) -> AsyncLogsResourceWithRawResponse: - return AsyncLogsResourceWithRawResponse(self._access.logs) - - @cached_property - def users(self) -> AsyncUsersResourceWithRawResponse: - return AsyncUsersResourceWithRawResponse(self._access.users) - - @cached_property - def custom_pages(self) -> AsyncCustomPagesResourceWithRawResponse: - return AsyncCustomPagesResourceWithRawResponse(self._access.custom_pages) - - @cached_property - def tags(self) -> AsyncTagsResourceWithRawResponse: - return AsyncTagsResourceWithRawResponse(self._access.tags) - class AccessResourceWithStreamingResponse: def __init__(self, access: AccessResource) -> None: @@ -302,30 +156,6 @@ def groups(self) -> GroupsResourceWithStreamingResponse: def service_tokens(self) -> ServiceTokensResourceWithStreamingResponse: return ServiceTokensResourceWithStreamingResponse(self._access.service_tokens) - @cached_property - def bookmarks(self) -> BookmarksResourceWithStreamingResponse: - return BookmarksResourceWithStreamingResponse(self._access.bookmarks) - - @cached_property - def keys(self) -> KeysResourceWithStreamingResponse: - return KeysResourceWithStreamingResponse(self._access.keys) - - @cached_property - def logs(self) -> LogsResourceWithStreamingResponse: - return LogsResourceWithStreamingResponse(self._access.logs) - - @cached_property - def users(self) -> UsersResourceWithStreamingResponse: - return UsersResourceWithStreamingResponse(self._access.users) - - @cached_property - def custom_pages(self) -> CustomPagesResourceWithStreamingResponse: - return CustomPagesResourceWithStreamingResponse(self._access.custom_pages) - - @cached_property - def tags(self) -> TagsResourceWithStreamingResponse: - return TagsResourceWithStreamingResponse(self._access.tags) - class AsyncAccessResourceWithStreamingResponse: def __init__(self, access: AsyncAccessResource) -> None: @@ -346,27 +176,3 @@ def groups(self) -> AsyncGroupsResourceWithStreamingResponse: @cached_property def service_tokens(self) -> AsyncServiceTokensResourceWithStreamingResponse: return AsyncServiceTokensResourceWithStreamingResponse(self._access.service_tokens) - - @cached_property - def bookmarks(self) -> AsyncBookmarksResourceWithStreamingResponse: - return AsyncBookmarksResourceWithStreamingResponse(self._access.bookmarks) - - @cached_property - def keys(self) -> AsyncKeysResourceWithStreamingResponse: - return AsyncKeysResourceWithStreamingResponse(self._access.keys) - - @cached_property - def logs(self) -> AsyncLogsResourceWithStreamingResponse: - return AsyncLogsResourceWithStreamingResponse(self._access.logs) - - @cached_property - def users(self) -> AsyncUsersResourceWithStreamingResponse: - return AsyncUsersResourceWithStreamingResponse(self._access.users) - - @cached_property - def custom_pages(self) -> AsyncCustomPagesResourceWithStreamingResponse: - return AsyncCustomPagesResourceWithStreamingResponse(self._access.custom_pages) - - @cached_property - def tags(self) -> AsyncTagsResourceWithStreamingResponse: - return AsyncTagsResourceWithStreamingResponse(self._access.tags) diff --git a/src/cloudflare/resources/zero_trust/access/applications/__init__.py b/src/cloudflare/resources/zero_trust/access/applications/__init__.py index 8b6f39c4dd8..f4d00c67e8c 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/__init__.py +++ b/src/cloudflare/resources/zero_trust/access/applications/__init__.py @@ -8,14 +8,6 @@ CAsResourceWithStreamingResponse, AsyncCAsResourceWithStreamingResponse, ) -from .policies import ( - PoliciesResource, - AsyncPoliciesResource, - PoliciesResourceWithRawResponse, - AsyncPoliciesResourceWithRawResponse, - PoliciesResourceWithStreamingResponse, - AsyncPoliciesResourceWithStreamingResponse, -) from .applications import ( ApplicationsResource, AsyncApplicationsResource, @@ -46,12 +38,6 @@ "AsyncUserPolicyChecksResourceWithRawResponse", "UserPolicyChecksResourceWithStreamingResponse", "AsyncUserPolicyChecksResourceWithStreamingResponse", - "PoliciesResource", - "AsyncPoliciesResource", - "PoliciesResourceWithRawResponse", - "AsyncPoliciesResourceWithRawResponse", - "PoliciesResourceWithStreamingResponse", - "AsyncPoliciesResourceWithStreamingResponse", "ApplicationsResource", "AsyncApplicationsResource", "ApplicationsResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/access/applications/applications.py b/src/cloudflare/resources/zero_trust/access/applications/applications.py index cb837d07265..7cb75fe8ecc 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/applications.py +++ b/src/cloudflare/resources/zero_trust/access/applications/applications.py @@ -14,14 +14,6 @@ CAsResourceWithStreamingResponse, AsyncCAsResourceWithStreamingResponse, ) -from .policies import ( - PoliciesResource, - AsyncPoliciesResource, - PoliciesResourceWithRawResponse, - AsyncPoliciesResourceWithRawResponse, - PoliciesResourceWithStreamingResponse, - AsyncPoliciesResourceWithStreamingResponse, -) from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ....._utils import ( maybe_transform, @@ -77,10 +69,6 @@ def cas(self) -> CAsResource: def user_policy_checks(self) -> UserPolicyChecksResource: return UserPolicyChecksResource(self._client) - @cached_property - def policies(self) -> PoliciesResource: - return PoliciesResource(self._client) - @cached_property def with_raw_response(self) -> ApplicationsResourceWithRawResponse: return ApplicationsResourceWithRawResponse(self) @@ -1863,10 +1851,6 @@ def cas(self) -> AsyncCAsResource: def user_policy_checks(self) -> AsyncUserPolicyChecksResource: return AsyncUserPolicyChecksResource(self._client) - @cached_property - def policies(self) -> AsyncPoliciesResource: - return AsyncPoliciesResource(self._client) - @cached_property def with_raw_response(self) -> AsyncApplicationsResourceWithRawResponse: return AsyncApplicationsResourceWithRawResponse(self) @@ -3671,10 +3655,6 @@ def cas(self) -> CAsResourceWithRawResponse: def user_policy_checks(self) -> UserPolicyChecksResourceWithRawResponse: return UserPolicyChecksResourceWithRawResponse(self._applications.user_policy_checks) - @cached_property - def policies(self) -> PoliciesResourceWithRawResponse: - return PoliciesResourceWithRawResponse(self._applications.policies) - class AsyncApplicationsResourceWithRawResponse: def __init__(self, applications: AsyncApplicationsResource) -> None: @@ -3707,10 +3687,6 @@ def cas(self) -> AsyncCAsResourceWithRawResponse: def user_policy_checks(self) -> AsyncUserPolicyChecksResourceWithRawResponse: return AsyncUserPolicyChecksResourceWithRawResponse(self._applications.user_policy_checks) - @cached_property - def policies(self) -> AsyncPoliciesResourceWithRawResponse: - return AsyncPoliciesResourceWithRawResponse(self._applications.policies) - class ApplicationsResourceWithStreamingResponse: def __init__(self, applications: ApplicationsResource) -> None: @@ -3743,10 +3719,6 @@ def cas(self) -> CAsResourceWithStreamingResponse: def user_policy_checks(self) -> UserPolicyChecksResourceWithStreamingResponse: return UserPolicyChecksResourceWithStreamingResponse(self._applications.user_policy_checks) - @cached_property - def policies(self) -> PoliciesResourceWithStreamingResponse: - return PoliciesResourceWithStreamingResponse(self._applications.policies) - class AsyncApplicationsResourceWithStreamingResponse: def __init__(self, applications: AsyncApplicationsResource) -> None: @@ -3778,7 +3750,3 @@ def cas(self) -> AsyncCAsResourceWithStreamingResponse: @cached_property def user_policy_checks(self) -> AsyncUserPolicyChecksResourceWithStreamingResponse: return AsyncUserPolicyChecksResourceWithStreamingResponse(self._applications.user_policy_checks) - - @cached_property - def policies(self) -> AsyncPoliciesResourceWithStreamingResponse: - return AsyncPoliciesResourceWithStreamingResponse(self._applications.policies) diff --git a/src/cloudflare/resources/zero_trust/access/applications/cas.py b/src/cloudflare/resources/zero_trust/access/applications/cas.py index 36c6f5f0483..29133e3028c 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/cas.py +++ b/src/cloudflare/resources/zero_trust/access/applications/cas.py @@ -2,8 +2,6 @@ from __future__ import annotations -from typing import Any, Type, Optional, cast - import httpx from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven @@ -15,16 +13,12 @@ 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.access.applications.ca import CA -from .....types.zero_trust.access.applications.ca_get_response import CAGetResponse -from .....types.zero_trust.access.applications.ca_create_response import CACreateResponse -from .....types.zero_trust.access.applications.ca_delete_response import CADeleteResponse __all__ = ["CAsResource", "AsyncCAsResource"] @@ -38,68 +32,6 @@ def with_raw_response(self) -> CAsResourceWithRawResponse: def with_streaming_response(self) -> CAsResourceWithStreamingResponse: return CAsResourceWithStreamingResponse(self) - def create( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CACreateResponse]: - """ - Generates a new short-lived certificate CA and public key. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return cast( - Optional[CACreateResponse], - self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/ca", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CACreateResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[CACreateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - def list( self, *, @@ -149,125 +81,6 @@ def list( model=CA, ) - def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CADeleteResponse]: - """ - Deletes a short-lived certificate CA. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/ca", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CADeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[CADeleteResponse]], ResultWrapper[CADeleteResponse]), - ) - - def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CAGetResponse]: - """ - Fetches a short-lived certificate CA and its public key. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return cast( - Optional[CAGetResponse], - self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/ca", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CAGetResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[CAGetResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - class AsyncCAsResource(AsyncAPIResource): @cached_property @@ -278,68 +91,6 @@ def with_raw_response(self) -> AsyncCAsResourceWithRawResponse: def with_streaming_response(self) -> AsyncCAsResourceWithStreamingResponse: return AsyncCAsResourceWithStreamingResponse(self) - async def create( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CACreateResponse]: - """ - Generates a new short-lived certificate CA and public key. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return cast( - Optional[CACreateResponse], - await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/ca", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CACreateResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[CACreateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - def list( self, *, @@ -389,193 +140,38 @@ def list( model=CA, ) - async def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CADeleteResponse]: - """ - Deletes a short-lived certificate CA. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/ca", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CADeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[CADeleteResponse]], ResultWrapper[CADeleteResponse]), - ) - - async def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CAGetResponse]: - """ - Fetches a short-lived certificate CA and its public key. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return cast( - Optional[CAGetResponse], - await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/ca", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CAGetResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[CAGetResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - class CAsResourceWithRawResponse: def __init__(self, cas: CAsResource) -> None: self._cas = cas - self.create = to_raw_response_wrapper( - cas.create, - ) self.list = to_raw_response_wrapper( cas.list, ) - self.delete = to_raw_response_wrapper( - cas.delete, - ) - self.get = to_raw_response_wrapper( - cas.get, - ) class AsyncCAsResourceWithRawResponse: def __init__(self, cas: AsyncCAsResource) -> None: self._cas = cas - self.create = async_to_raw_response_wrapper( - cas.create, - ) self.list = async_to_raw_response_wrapper( cas.list, ) - self.delete = async_to_raw_response_wrapper( - cas.delete, - ) - self.get = async_to_raw_response_wrapper( - cas.get, - ) class CAsResourceWithStreamingResponse: def __init__(self, cas: CAsResource) -> None: self._cas = cas - self.create = to_streamed_response_wrapper( - cas.create, - ) self.list = to_streamed_response_wrapper( cas.list, ) - self.delete = to_streamed_response_wrapper( - cas.delete, - ) - self.get = to_streamed_response_wrapper( - cas.get, - ) class AsyncCAsResourceWithStreamingResponse: def __init__(self, cas: AsyncCAsResource) -> None: self._cas = cas - self.create = async_to_streamed_response_wrapper( - cas.create, - ) self.list = async_to_streamed_response_wrapper( cas.list, ) - self.delete = async_to_streamed_response_wrapper( - cas.delete, - ) - self.get = async_to_streamed_response_wrapper( - cas.get, - ) diff --git a/src/cloudflare/resources/zero_trust/access/applications/policies.py b/src/cloudflare/resources/zero_trust/access/applications/policies.py deleted file mode 100644 index b5c9f110dee..00000000000 --- a/src/cloudflare/resources/zero_trust/access/applications/policies.py +++ /dev/null @@ -1,1007 +0,0 @@ -# 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 .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import ( - AsyncPaginator, - make_request_options, -) -from .....types.zero_trust.access import Decision -from .....types.zero_trust.access.decision import Decision -from .....types.zero_trust.access_rule_param import AccessRuleParam -from .....types.zero_trust.access.applications import policy_create_params, policy_update_params -from .....types.zero_trust.access.applications.policy_get_response import PolicyGetResponse -from .....types.zero_trust.access.applications.approval_group_param import ApprovalGroupParam -from .....types.zero_trust.access.applications.policy_list_response import PolicyListResponse -from .....types.zero_trust.access.applications.policy_create_response import PolicyCreateResponse -from .....types.zero_trust.access.applications.policy_delete_response import PolicyDeleteResponse -from .....types.zero_trust.access.applications.policy_update_response import PolicyUpdateResponse - -__all__ = ["PoliciesResource", "AsyncPoliciesResource"] - - -class PoliciesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> PoliciesResourceWithRawResponse: - return PoliciesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: - return PoliciesResourceWithStreamingResponse(self) - - def create( - self, - uuid: str, - *, - decision: Decision, - include: Iterable[AccessRuleParam], - name: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, - approval_required: bool | NotGiven = NOT_GIVEN, - exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - isolation_required: bool | NotGiven = NOT_GIVEN, - precedence: int | NotGiven = NOT_GIVEN, - purpose_justification_prompt: str | NotGiven = NOT_GIVEN, - purpose_justification_required: bool | NotGiven = NOT_GIVEN, - require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - session_duration: 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[PolicyCreateResponse]: - """ - Creates a policy applying exclusive to a single application that defines the - users or groups who can reach it. We recommend creating a reusable policy - instead and subsequently referencing its ID in the application's 'policies' - array. - - Args: - uuid: UUID - - decision: The action Access will take if a user matches this policy. - - include: Rules evaluated with an OR logical operator. A user needs to meet only one of - the Include rules. - - name: The name of the Access policy. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - approval_groups: Administrators who can approve a temporary authentication request. - - approval_required: Requires the user to request access from an administrator at the start of each - session. - - exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot - meet any of the Exclude rules. - - isolation_required: Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - - precedence: The order of execution for this policy. Must be unique for each policy within an - app. - - purpose_justification_prompt: A custom message that will appear on the purpose justification screen. - - purpose_justification_required: Require users to enter a justification when they log in to the application. - - require: Rules evaluated with an AND logical operator. To match the policy, a user must - meet all of the Require rules. - - session_duration: The amount of time that tokens issued for the application will be valid. Must be - in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - m, h. - - 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 uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", - body=maybe_transform( - { - "decision": decision, - "include": include, - "name": name, - "approval_groups": approval_groups, - "approval_required": approval_required, - "exclude": exclude, - "isolation_required": isolation_required, - "precedence": precedence, - "purpose_justification_prompt": purpose_justification_prompt, - "purpose_justification_required": purpose_justification_required, - "require": require, - "session_duration": session_duration, - }, - 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[PolicyCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), - ) - - def update( - self, - uuid: str, - *, - uuid1: str, - decision: Decision, - include: Iterable[AccessRuleParam], - name: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, - approval_required: bool | NotGiven = NOT_GIVEN, - exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - isolation_required: bool | NotGiven = NOT_GIVEN, - precedence: int | NotGiven = NOT_GIVEN, - purpose_justification_prompt: str | NotGiven = NOT_GIVEN, - purpose_justification_required: bool | NotGiven = NOT_GIVEN, - require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - session_duration: 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[PolicyUpdateResponse]: - """Updates an Access policy specific to an application. - - To update a reusable - policy, use the /account or zones/{identifier}/policies/{uid} endpoint. - - Args: - uuid1: UUID - - uuid: UUID - - decision: The action Access will take if a user matches this policy. - - include: Rules evaluated with an OR logical operator. A user needs to meet only one of - the Include rules. - - name: The name of the Access policy. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - approval_groups: Administrators who can approve a temporary authentication request. - - approval_required: Requires the user to request access from an administrator at the start of each - session. - - exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot - meet any of the Exclude rules. - - isolation_required: Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - - precedence: The order of execution for this policy. Must be unique for each policy within an - app. - - purpose_justification_prompt: A custom message that will appear on the purpose justification screen. - - purpose_justification_required: Require users to enter a justification when they log in to the application. - - require: Rules evaluated with an AND logical operator. To match the policy, a user must - meet all of the Require rules. - - session_duration: The amount of time that tokens issued for the application will be valid. Must be - in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - m, h. - - 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 uuid1: - raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid1}/policies/{uuid}", - body=maybe_transform( - { - "decision": decision, - "include": include, - "name": name, - "approval_groups": approval_groups, - "approval_required": approval_required, - "exclude": exclude, - "isolation_required": isolation_required, - "precedence": precedence, - "purpose_justification_prompt": purpose_justification_prompt, - "purpose_justification_required": purpose_justification_required, - "require": require, - "session_duration": session_duration, - }, - policy_update_params.PolicyUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), - ) - - def list( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[PolicyListResponse]: - """Lists Access policies configured for an application. - - Returns both exclusively - scoped and reusable policies used by the application. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", - page=SyncSinglePage[PolicyListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=PolicyListResponse, - ) - - def delete( - self, - uuid: str, - *, - uuid1: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PolicyDeleteResponse]: - """Deletes an Access policy specific to an application. - - To delete a reusable - policy, use the /account or zones/{identifier}/policies/{uid} endpoint. - - Args: - uuid1: UUID - - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid1: - raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid1}/policies/{uuid}", - 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 get( - self, - uuid: str, - *, - uuid1: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PolicyGetResponse]: - """Fetches a single Access policy configured for an application. - - Returns both - exclusively owned and reusable policies used by the application. - - Args: - uuid1: UUID - - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid1: - raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid1}/policies/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), - ) - - -class AsyncPoliciesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncPoliciesResourceWithRawResponse: - return AsyncPoliciesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: - return AsyncPoliciesResourceWithStreamingResponse(self) - - async def create( - self, - uuid: str, - *, - decision: Decision, - include: Iterable[AccessRuleParam], - name: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, - approval_required: bool | NotGiven = NOT_GIVEN, - exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - isolation_required: bool | NotGiven = NOT_GIVEN, - precedence: int | NotGiven = NOT_GIVEN, - purpose_justification_prompt: str | NotGiven = NOT_GIVEN, - purpose_justification_required: bool | NotGiven = NOT_GIVEN, - require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - session_duration: 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[PolicyCreateResponse]: - """ - Creates a policy applying exclusive to a single application that defines the - users or groups who can reach it. We recommend creating a reusable policy - instead and subsequently referencing its ID in the application's 'policies' - array. - - Args: - uuid: UUID - - decision: The action Access will take if a user matches this policy. - - include: Rules evaluated with an OR logical operator. A user needs to meet only one of - the Include rules. - - name: The name of the Access policy. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - approval_groups: Administrators who can approve a temporary authentication request. - - approval_required: Requires the user to request access from an administrator at the start of each - session. - - exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot - meet any of the Exclude rules. - - isolation_required: Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - - precedence: The order of execution for this policy. Must be unique for each policy within an - app. - - purpose_justification_prompt: A custom message that will appear on the purpose justification screen. - - purpose_justification_required: Require users to enter a justification when they log in to the application. - - require: Rules evaluated with an AND logical operator. To match the policy, a user must - meet all of the Require rules. - - session_duration: The amount of time that tokens issued for the application will be valid. Must be - in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - m, h. - - 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 uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", - body=await async_maybe_transform( - { - "decision": decision, - "include": include, - "name": name, - "approval_groups": approval_groups, - "approval_required": approval_required, - "exclude": exclude, - "isolation_required": isolation_required, - "precedence": precedence, - "purpose_justification_prompt": purpose_justification_prompt, - "purpose_justification_required": purpose_justification_required, - "require": require, - "session_duration": session_duration, - }, - 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[PolicyCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), - ) - - async def update( - self, - uuid: str, - *, - uuid1: str, - decision: Decision, - include: Iterable[AccessRuleParam], - name: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, - approval_required: bool | NotGiven = NOT_GIVEN, - exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - isolation_required: bool | NotGiven = NOT_GIVEN, - precedence: int | NotGiven = NOT_GIVEN, - purpose_justification_prompt: str | NotGiven = NOT_GIVEN, - purpose_justification_required: bool | NotGiven = NOT_GIVEN, - require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - session_duration: 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[PolicyUpdateResponse]: - """Updates an Access policy specific to an application. - - To update a reusable - policy, use the /account or zones/{identifier}/policies/{uid} endpoint. - - Args: - uuid1: UUID - - uuid: UUID - - decision: The action Access will take if a user matches this policy. - - include: Rules evaluated with an OR logical operator. A user needs to meet only one of - the Include rules. - - name: The name of the Access policy. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - approval_groups: Administrators who can approve a temporary authentication request. - - approval_required: Requires the user to request access from an administrator at the start of each - session. - - exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot - meet any of the Exclude rules. - - isolation_required: Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - - precedence: The order of execution for this policy. Must be unique for each policy within an - app. - - purpose_justification_prompt: A custom message that will appear on the purpose justification screen. - - purpose_justification_required: Require users to enter a justification when they log in to the application. - - require: Rules evaluated with an AND logical operator. To match the policy, a user must - meet all of the Require rules. - - session_duration: The amount of time that tokens issued for the application will be valid. Must be - in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - m, h. - - 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 uuid1: - raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid1}/policies/{uuid}", - body=await async_maybe_transform( - { - "decision": decision, - "include": include, - "name": name, - "approval_groups": approval_groups, - "approval_required": approval_required, - "exclude": exclude, - "isolation_required": isolation_required, - "precedence": precedence, - "purpose_justification_prompt": purpose_justification_prompt, - "purpose_justification_required": purpose_justification_required, - "require": require, - "session_duration": session_duration, - }, - policy_update_params.PolicyUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), - ) - - def list( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[PolicyListResponse, AsyncSinglePage[PolicyListResponse]]: - """Lists Access policies configured for an application. - - Returns both exclusively - scoped and reusable policies used by the application. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid}/policies", - page=AsyncSinglePage[PolicyListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=PolicyListResponse, - ) - - async def delete( - self, - uuid: str, - *, - uuid1: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PolicyDeleteResponse]: - """Deletes an Access policy specific to an application. - - To delete a reusable - policy, use the /account or zones/{identifier}/policies/{uid} endpoint. - - Args: - uuid1: UUID - - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid1: - raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid1}/policies/{uuid}", - 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 get( - self, - uuid: str, - *, - uuid1: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PolicyGetResponse]: - """Fetches a single Access policy configured for an application. - - Returns both - exclusively owned and reusable policies used by the application. - - Args: - uuid1: UUID - - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid1: - raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/apps/{uuid1}/policies/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), - ) - - -class PoliciesResourceWithRawResponse: - def __init__(self, policies: PoliciesResource) -> None: - self._policies = policies - - self.create = to_raw_response_wrapper( - policies.create, - ) - self.update = to_raw_response_wrapper( - policies.update, - ) - self.list = to_raw_response_wrapper( - policies.list, - ) - self.delete = to_raw_response_wrapper( - policies.delete, - ) - self.get = to_raw_response_wrapper( - policies.get, - ) - - -class AsyncPoliciesResourceWithRawResponse: - def __init__(self, policies: AsyncPoliciesResource) -> None: - self._policies = policies - - self.create = async_to_raw_response_wrapper( - policies.create, - ) - self.update = async_to_raw_response_wrapper( - policies.update, - ) - self.list = async_to_raw_response_wrapper( - policies.list, - ) - self.delete = async_to_raw_response_wrapper( - policies.delete, - ) - self.get = async_to_raw_response_wrapper( - policies.get, - ) - - -class PoliciesResourceWithStreamingResponse: - def __init__(self, policies: PoliciesResource) -> None: - self._policies = policies - - self.create = to_streamed_response_wrapper( - policies.create, - ) - self.update = to_streamed_response_wrapper( - policies.update, - ) - self.list = to_streamed_response_wrapper( - policies.list, - ) - self.delete = to_streamed_response_wrapper( - policies.delete, - ) - self.get = to_streamed_response_wrapper( - policies.get, - ) - - -class AsyncPoliciesResourceWithStreamingResponse: - def __init__(self, policies: AsyncPoliciesResource) -> None: - self._policies = policies - - self.create = async_to_streamed_response_wrapper( - policies.create, - ) - self.update = async_to_streamed_response_wrapper( - policies.update, - ) - self.list = async_to_streamed_response_wrapper( - policies.list, - ) - self.delete = async_to_streamed_response_wrapper( - policies.delete, - ) - self.get = async_to_streamed_response_wrapper( - policies.get, - ) diff --git a/src/cloudflare/resources/zero_trust/access/bookmarks.py b/src/cloudflare/resources/zero_trust/access/bookmarks.py deleted file mode 100644 index 00f06515c4c..00000000000 --- a/src/cloudflare/resources/zero_trust/access/bookmarks.py +++ /dev/null @@ -1,548 +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 ...._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 ...._base_client import ( - AsyncPaginator, - make_request_options, -) -from ....types.zero_trust.access import bookmark_create_params, bookmark_update_params -from ....types.zero_trust.access.bookmark import Bookmark -from ....types.zero_trust.access.bookmark_delete_response import BookmarkDeleteResponse - -__all__ = ["BookmarksResource", "AsyncBookmarksResource"] - - -class BookmarksResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> BookmarksResourceWithRawResponse: - return BookmarksResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> BookmarksResourceWithStreamingResponse: - return BookmarksResourceWithStreamingResponse(self) - - def create( - self, - uuid: str, - *, - identifier: str, - body: object, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Bookmark]: - """ - Create a new Bookmark application. - - Args: - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._post( - f"/accounts/{identifier}/access/bookmarks/{uuid}", - body=maybe_transform(body, bookmark_create_params.BookmarkCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, - ), - cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), - ) - - def update( - self, - uuid: str, - *, - identifier: str, - body: object, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Bookmark]: - """ - Updates a configured Bookmark application. - - Args: - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._put( - f"/accounts/{identifier}/access/bookmarks/{uuid}", - body=maybe_transform(body, bookmark_update_params.BookmarkUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, - ), - cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), - ) - - def list( - self, - identifier: 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[Bookmark]: - """ - Lists Bookmark applications. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/bookmarks", - page=SyncSinglePage[Bookmark], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=Bookmark, - ) - - def delete( - self, - uuid: str, - *, - identifier: 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[BookmarkDeleteResponse]: - """ - Deletes a Bookmark application. - - Args: - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._delete( - f"/accounts/{identifier}/access/bookmarks/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[BookmarkDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[BookmarkDeleteResponse]], ResultWrapper[BookmarkDeleteResponse]), - ) - - def get( - self, - uuid: str, - *, - identifier: 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[Bookmark]: - """ - Fetches a single Bookmark application. - - Args: - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._get( - f"/accounts/{identifier}/access/bookmarks/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, - ), - cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), - ) - - -class AsyncBookmarksResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncBookmarksResourceWithRawResponse: - return AsyncBookmarksResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncBookmarksResourceWithStreamingResponse: - return AsyncBookmarksResourceWithStreamingResponse(self) - - async def create( - self, - uuid: str, - *, - identifier: str, - body: object, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Bookmark]: - """ - Create a new Bookmark application. - - Args: - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._post( - f"/accounts/{identifier}/access/bookmarks/{uuid}", - body=await async_maybe_transform(body, bookmark_create_params.BookmarkCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, - ), - cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), - ) - - async def update( - self, - uuid: str, - *, - identifier: str, - body: object, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Bookmark]: - """ - Updates a configured Bookmark application. - - Args: - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._put( - f"/accounts/{identifier}/access/bookmarks/{uuid}", - body=await async_maybe_transform(body, bookmark_update_params.BookmarkUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, - ), - cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), - ) - - def list( - self, - identifier: 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[Bookmark, AsyncSinglePage[Bookmark]]: - """ - Lists Bookmark applications. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/bookmarks", - page=AsyncSinglePage[Bookmark], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=Bookmark, - ) - - async def delete( - self, - uuid: str, - *, - identifier: 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[BookmarkDeleteResponse]: - """ - Deletes a Bookmark application. - - Args: - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._delete( - f"/accounts/{identifier}/access/bookmarks/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[BookmarkDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[BookmarkDeleteResponse]], ResultWrapper[BookmarkDeleteResponse]), - ) - - async def get( - self, - uuid: str, - *, - identifier: 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[Bookmark]: - """ - Fetches a single Bookmark application. - - Args: - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._get( - f"/accounts/{identifier}/access/bookmarks/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, - ), - cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), - ) - - -class BookmarksResourceWithRawResponse: - def __init__(self, bookmarks: BookmarksResource) -> None: - self._bookmarks = bookmarks - - self.create = to_raw_response_wrapper( - bookmarks.create, - ) - self.update = to_raw_response_wrapper( - bookmarks.update, - ) - self.list = to_raw_response_wrapper( - bookmarks.list, - ) - self.delete = to_raw_response_wrapper( - bookmarks.delete, - ) - self.get = to_raw_response_wrapper( - bookmarks.get, - ) - - -class AsyncBookmarksResourceWithRawResponse: - def __init__(self, bookmarks: AsyncBookmarksResource) -> None: - self._bookmarks = bookmarks - - self.create = async_to_raw_response_wrapper( - bookmarks.create, - ) - self.update = async_to_raw_response_wrapper( - bookmarks.update, - ) - self.list = async_to_raw_response_wrapper( - bookmarks.list, - ) - self.delete = async_to_raw_response_wrapper( - bookmarks.delete, - ) - self.get = async_to_raw_response_wrapper( - bookmarks.get, - ) - - -class BookmarksResourceWithStreamingResponse: - def __init__(self, bookmarks: BookmarksResource) -> None: - self._bookmarks = bookmarks - - self.create = to_streamed_response_wrapper( - bookmarks.create, - ) - self.update = to_streamed_response_wrapper( - bookmarks.update, - ) - self.list = to_streamed_response_wrapper( - bookmarks.list, - ) - self.delete = to_streamed_response_wrapper( - bookmarks.delete, - ) - self.get = to_streamed_response_wrapper( - bookmarks.get, - ) - - -class AsyncBookmarksResourceWithStreamingResponse: - def __init__(self, bookmarks: AsyncBookmarksResource) -> None: - self._bookmarks = bookmarks - - self.create = async_to_streamed_response_wrapper( - bookmarks.create, - ) - self.update = async_to_streamed_response_wrapper( - bookmarks.update, - ) - self.list = async_to_streamed_response_wrapper( - bookmarks.list, - ) - self.delete = async_to_streamed_response_wrapper( - bookmarks.delete, - ) - self.get = async_to_streamed_response_wrapper( - bookmarks.get, - ) diff --git a/src/cloudflare/resources/zero_trust/access/certificates/certificates.py b/src/cloudflare/resources/zero_trust/access/certificates/certificates.py index e0e729cb755..a7e07081133 100644 --- a/src/cloudflare/resources/zero_trust/access/certificates/certificates.py +++ b/src/cloudflare/resources/zero_trust/access/certificates/certificates.py @@ -33,10 +33,9 @@ AsyncPaginator, make_request_options, ) -from .....types.zero_trust.access import certificate_create_params, certificate_update_params +from .....types.zero_trust.access import certificate_create_params from .....types.zero_trust.access.certificate import Certificate from .....types.zero_trust.access.associated_hostnames import AssociatedHostnames -from .....types.zero_trust.access.certificate_delete_response import CertificateDeleteResponse __all__ = ["CertificatesResource", "AsyncCertificatesResource"] @@ -123,76 +122,6 @@ def create( cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), ) - def update( - self, - uuid: str, - *, - associated_hostnames: List[AssociatedHostnames], - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - name: 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[Certificate]: - """ - Updates a configured mTLS certificate. - - Args: - uuid: UUID - - associated_hostnames: The hostnames of the applications that will use this certificate. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - name: The name of the certificate. - - 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 uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{uuid}", - body=maybe_transform( - { - "associated_hostnames": associated_hostnames, - "name": name, - }, - certificate_update_params.CertificateUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Certificate]]._unwrapper, - ), - cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), - ) - def list( self, *, @@ -242,120 +171,6 @@ def list( model=Certificate, ) - def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CertificateDeleteResponse]: - """ - Deletes an mTLS certificate. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CertificateDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[CertificateDeleteResponse]], ResultWrapper[CertificateDeleteResponse]), - ) - - def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Certificate]: - """ - Fetches a single mTLS certificate. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Certificate]]._unwrapper, - ), - cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), - ) - class AsyncCertificatesResource(AsyncAPIResource): @cached_property @@ -439,76 +254,6 @@ async def create( cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), ) - async def update( - self, - uuid: str, - *, - associated_hostnames: List[AssociatedHostnames], - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - name: 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[Certificate]: - """ - Updates a configured mTLS certificate. - - Args: - uuid: UUID - - associated_hostnames: The hostnames of the applications that will use this certificate. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - name: The name of the certificate. - - 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 uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{uuid}", - body=await async_maybe_transform( - { - "associated_hostnames": associated_hostnames, - "name": name, - }, - certificate_update_params.CertificateUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Certificate]]._unwrapper, - ), - cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), - ) - def list( self, *, @@ -558,120 +303,6 @@ def list( model=Certificate, ) - async def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CertificateDeleteResponse]: - """ - Deletes an mTLS certificate. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CertificateDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[CertificateDeleteResponse]], ResultWrapper[CertificateDeleteResponse]), - ) - - async def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Certificate]: - """ - Fetches a single mTLS certificate. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Certificate]]._unwrapper, - ), - cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), - ) - class CertificatesResourceWithRawResponse: def __init__(self, certificates: CertificatesResource) -> None: @@ -680,18 +311,9 @@ def __init__(self, certificates: CertificatesResource) -> None: self.create = to_raw_response_wrapper( certificates.create, ) - self.update = to_raw_response_wrapper( - certificates.update, - ) self.list = to_raw_response_wrapper( certificates.list, ) - self.delete = to_raw_response_wrapper( - certificates.delete, - ) - self.get = to_raw_response_wrapper( - certificates.get, - ) @cached_property def settings(self) -> SettingsResourceWithRawResponse: @@ -705,18 +327,9 @@ def __init__(self, certificates: AsyncCertificatesResource) -> None: self.create = async_to_raw_response_wrapper( certificates.create, ) - self.update = async_to_raw_response_wrapper( - certificates.update, - ) self.list = async_to_raw_response_wrapper( certificates.list, ) - self.delete = async_to_raw_response_wrapper( - certificates.delete, - ) - self.get = async_to_raw_response_wrapper( - certificates.get, - ) @cached_property def settings(self) -> AsyncSettingsResourceWithRawResponse: @@ -730,18 +343,9 @@ def __init__(self, certificates: CertificatesResource) -> None: self.create = to_streamed_response_wrapper( certificates.create, ) - self.update = to_streamed_response_wrapper( - certificates.update, - ) self.list = to_streamed_response_wrapper( certificates.list, ) - self.delete = to_streamed_response_wrapper( - certificates.delete, - ) - self.get = to_streamed_response_wrapper( - certificates.get, - ) @cached_property def settings(self) -> SettingsResourceWithStreamingResponse: @@ -755,18 +359,9 @@ def __init__(self, certificates: AsyncCertificatesResource) -> None: self.create = async_to_streamed_response_wrapper( certificates.create, ) - self.update = async_to_streamed_response_wrapper( - certificates.update, - ) self.list = async_to_streamed_response_wrapper( certificates.list, ) - self.delete = async_to_streamed_response_wrapper( - certificates.delete, - ) - self.get = async_to_streamed_response_wrapper( - certificates.get, - ) @cached_property def settings(self) -> AsyncSettingsResourceWithStreamingResponse: diff --git a/src/cloudflare/resources/zero_trust/access/custom_pages.py b/src/cloudflare/resources/zero_trust/access/custom_pages.py deleted file mode 100644 index 1314c7e01b9..00000000000 --- a/src/cloudflare/resources/zero_trust/access/custom_pages.py +++ /dev/null @@ -1,636 +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 -from typing_extensions import Literal - -import httpx - -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ...._wrappers import ResultWrapper -from ....pagination import SyncSinglePage, AsyncSinglePage -from ...._base_client import ( - AsyncPaginator, - make_request_options, -) -from ....types.zero_trust.access import custom_page_create_params, custom_page_update_params -from ....types.zero_trust.access.custom_page import CustomPage -from ....types.zero_trust.access.custom_page_without_html import CustomPageWithoutHTML -from ....types.zero_trust.access.custom_page_delete_response import CustomPageDeleteResponse - -__all__ = ["CustomPagesResource", "AsyncCustomPagesResource"] - - -class CustomPagesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> CustomPagesResourceWithRawResponse: - return CustomPagesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> CustomPagesResourceWithStreamingResponse: - return CustomPagesResourceWithStreamingResponse(self) - - def create( - self, - identifier: str, - *, - custom_html: str, - name: str, - type: Literal["identity_denied", "forbidden"], - app_count: int | 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[CustomPageWithoutHTML]: - """ - Create a custom page - - Args: - identifier: Identifier - - custom_html: Custom page HTML. - - name: Custom page name. - - type: Custom page type. - - app_count: Number of apps the custom page is assigned to. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._post( - f"/accounts/{identifier}/access/custom_pages", - body=maybe_transform( - { - "custom_html": custom_html, - "name": name, - "type": type, - "app_count": app_count, - }, - custom_page_create_params.CustomPageCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), - ) - - def update( - self, - uuid: str, - *, - identifier: str, - custom_html: str, - name: str, - type: Literal["identity_denied", "forbidden"], - app_count: int | 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[CustomPageWithoutHTML]: - """ - Update a custom page - - Args: - identifier: Identifier - - uuid: UUID - - custom_html: Custom page HTML. - - name: Custom page name. - - type: Custom page type. - - app_count: Number of apps the custom page is assigned to. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._put( - f"/accounts/{identifier}/access/custom_pages/{uuid}", - body=maybe_transform( - { - "custom_html": custom_html, - "name": name, - "type": type, - "app_count": app_count, - }, - custom_page_update_params.CustomPageUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), - ) - - def list( - self, - identifier: 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[CustomPageWithoutHTML]: - """ - List custom pages - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/custom_pages", - page=SyncSinglePage[CustomPageWithoutHTML], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=CustomPageWithoutHTML, - ) - - def delete( - self, - uuid: str, - *, - identifier: 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[CustomPageDeleteResponse]: - """ - Delete a custom page - - Args: - identifier: Identifier - - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._delete( - f"/accounts/{identifier}/access/custom_pages/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPageDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPageDeleteResponse]], ResultWrapper[CustomPageDeleteResponse]), - ) - - def get( - self, - uuid: str, - *, - identifier: 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[CustomPage]: - """ - Fetches a custom page and also returns its HTML. - - Args: - identifier: Identifier - - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._get( - f"/accounts/{identifier}/access/custom_pages/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPage]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPage]], ResultWrapper[CustomPage]), - ) - - -class AsyncCustomPagesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncCustomPagesResourceWithRawResponse: - return AsyncCustomPagesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncCustomPagesResourceWithStreamingResponse: - return AsyncCustomPagesResourceWithStreamingResponse(self) - - async def create( - self, - identifier: str, - *, - custom_html: str, - name: str, - type: Literal["identity_denied", "forbidden"], - app_count: int | 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[CustomPageWithoutHTML]: - """ - Create a custom page - - Args: - identifier: Identifier - - custom_html: Custom page HTML. - - name: Custom page name. - - type: Custom page type. - - app_count: Number of apps the custom page is assigned to. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return await self._post( - f"/accounts/{identifier}/access/custom_pages", - body=await async_maybe_transform( - { - "custom_html": custom_html, - "name": name, - "type": type, - "app_count": app_count, - }, - custom_page_create_params.CustomPageCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), - ) - - async def update( - self, - uuid: str, - *, - identifier: str, - custom_html: str, - name: str, - type: Literal["identity_denied", "forbidden"], - app_count: int | 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[CustomPageWithoutHTML]: - """ - Update a custom page - - Args: - identifier: Identifier - - uuid: UUID - - custom_html: Custom page HTML. - - name: Custom page name. - - type: Custom page type. - - app_count: Number of apps the custom page is assigned to. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._put( - f"/accounts/{identifier}/access/custom_pages/{uuid}", - body=await async_maybe_transform( - { - "custom_html": custom_html, - "name": name, - "type": type, - "app_count": app_count, - }, - custom_page_update_params.CustomPageUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), - ) - - def list( - self, - identifier: 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[CustomPageWithoutHTML, AsyncSinglePage[CustomPageWithoutHTML]]: - """ - List custom pages - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/custom_pages", - page=AsyncSinglePage[CustomPageWithoutHTML], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=CustomPageWithoutHTML, - ) - - async def delete( - self, - uuid: str, - *, - identifier: 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[CustomPageDeleteResponse]: - """ - Delete a custom page - - Args: - identifier: Identifier - - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._delete( - f"/accounts/{identifier}/access/custom_pages/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPageDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPageDeleteResponse]], ResultWrapper[CustomPageDeleteResponse]), - ) - - async def get( - self, - uuid: str, - *, - identifier: 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[CustomPage]: - """ - Fetches a custom page and also returns its HTML. - - Args: - identifier: Identifier - - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._get( - f"/accounts/{identifier}/access/custom_pages/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[CustomPage]]._unwrapper, - ), - cast_to=cast(Type[Optional[CustomPage]], ResultWrapper[CustomPage]), - ) - - -class CustomPagesResourceWithRawResponse: - def __init__(self, custom_pages: CustomPagesResource) -> None: - self._custom_pages = custom_pages - - self.create = to_raw_response_wrapper( - custom_pages.create, - ) - self.update = to_raw_response_wrapper( - custom_pages.update, - ) - self.list = to_raw_response_wrapper( - custom_pages.list, - ) - self.delete = to_raw_response_wrapper( - custom_pages.delete, - ) - self.get = to_raw_response_wrapper( - custom_pages.get, - ) - - -class AsyncCustomPagesResourceWithRawResponse: - def __init__(self, custom_pages: AsyncCustomPagesResource) -> None: - self._custom_pages = custom_pages - - self.create = async_to_raw_response_wrapper( - custom_pages.create, - ) - self.update = async_to_raw_response_wrapper( - custom_pages.update, - ) - self.list = async_to_raw_response_wrapper( - custom_pages.list, - ) - self.delete = async_to_raw_response_wrapper( - custom_pages.delete, - ) - self.get = async_to_raw_response_wrapper( - custom_pages.get, - ) - - -class CustomPagesResourceWithStreamingResponse: - def __init__(self, custom_pages: CustomPagesResource) -> None: - self._custom_pages = custom_pages - - self.create = to_streamed_response_wrapper( - custom_pages.create, - ) - self.update = to_streamed_response_wrapper( - custom_pages.update, - ) - self.list = to_streamed_response_wrapper( - custom_pages.list, - ) - self.delete = to_streamed_response_wrapper( - custom_pages.delete, - ) - self.get = to_streamed_response_wrapper( - custom_pages.get, - ) - - -class AsyncCustomPagesResourceWithStreamingResponse: - def __init__(self, custom_pages: AsyncCustomPagesResource) -> None: - self._custom_pages = custom_pages - - self.create = async_to_streamed_response_wrapper( - custom_pages.create, - ) - self.update = async_to_streamed_response_wrapper( - custom_pages.update, - ) - self.list = async_to_streamed_response_wrapper( - custom_pages.list, - ) - self.delete = async_to_streamed_response_wrapper( - custom_pages.delete, - ) - self.get = async_to_streamed_response_wrapper( - custom_pages.get, - ) diff --git a/src/cloudflare/resources/zero_trust/access/groups.py b/src/cloudflare/resources/zero_trust/access/groups.py index 62bde18942b..74f6f4a066d 100644 --- a/src/cloudflare/resources/zero_trust/access/groups.py +++ b/src/cloudflare/resources/zero_trust/access/groups.py @@ -25,10 +25,9 @@ AsyncPaginator, make_request_options, ) -from ....types.zero_trust.access import group_create_params, group_update_params +from ....types.zero_trust.access import group_create_params from ....types.zero_trust.access_rule_param import AccessRuleParam from ....types.zero_trust.access.zero_trust_group import ZeroTrustGroup -from ....types.zero_trust.access.group_delete_response import GroupDeleteResponse __all__ = ["GroupsResource", "AsyncGroupsResource"] @@ -122,91 +121,6 @@ def create( cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), ) - def update( - self, - uuid: str, - *, - include: Iterable[AccessRuleParam], - name: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - is_default: bool | NotGiven = NOT_GIVEN, - require: Iterable[AccessRuleParam] | 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[ZeroTrustGroup]: - """ - Updates a configured Access group. - - Args: - uuid: UUID - - include: Rules evaluated with an OR logical operator. A user needs to meet only one of - the Include rules. - - name: The name of the Access group. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - exclude: Rules evaluated with a NOT logical operator. To match a policy, a user cannot - meet any of the Exclude rules. - - is_default: Whether this is the default group - - require: Rules evaluated with an AND logical operator. To match a policy, a user must - meet all of the Require rules. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{uuid}", - body=maybe_transform( - { - "include": include, - "name": name, - "exclude": exclude, - "is_default": is_default, - "require": require, - }, - group_update_params.GroupUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ZeroTrustGroup]]._unwrapper, - ), - cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), - ) - def list( self, *, @@ -256,120 +170,6 @@ def list( model=ZeroTrustGroup, ) - def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[GroupDeleteResponse]: - """ - Deletes an Access group. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[GroupDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[GroupDeleteResponse]], ResultWrapper[GroupDeleteResponse]), - ) - - def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ZeroTrustGroup]: - """ - Fetches a single Access group. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ZeroTrustGroup]]._unwrapper, - ), - cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), - ) - class AsyncGroupsResource(AsyncAPIResource): @cached_property @@ -460,91 +260,6 @@ async def create( cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), ) - async def update( - self, - uuid: str, - *, - include: Iterable[AccessRuleParam], - name: str, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, - is_default: bool | NotGiven = NOT_GIVEN, - require: Iterable[AccessRuleParam] | 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[ZeroTrustGroup]: - """ - Updates a configured Access group. - - Args: - uuid: UUID - - include: Rules evaluated with an OR logical operator. A user needs to meet only one of - the Include rules. - - name: The name of the Access group. - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - exclude: Rules evaluated with a NOT logical operator. To match a policy, a user cannot - meet any of the Exclude rules. - - is_default: Whether this is the default group - - require: Rules evaluated with an AND logical operator. To match a policy, a user must - meet all of the Require rules. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{uuid}", - body=await async_maybe_transform( - { - "include": include, - "name": name, - "exclude": exclude, - "is_default": is_default, - "require": require, - }, - group_update_params.GroupUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ZeroTrustGroup]]._unwrapper, - ), - cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), - ) - def list( self, *, @@ -594,120 +309,6 @@ def list( model=ZeroTrustGroup, ) - async def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[GroupDeleteResponse]: - """ - Deletes an Access group. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[GroupDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[GroupDeleteResponse]], ResultWrapper[GroupDeleteResponse]), - ) - - async def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ZeroTrustGroup]: - """ - Fetches a single Access group. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/groups/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ZeroTrustGroup]]._unwrapper, - ), - cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), - ) - class GroupsResourceWithRawResponse: def __init__(self, groups: GroupsResource) -> None: @@ -716,18 +317,9 @@ def __init__(self, groups: GroupsResource) -> None: self.create = to_raw_response_wrapper( groups.create, ) - self.update = to_raw_response_wrapper( - groups.update, - ) self.list = to_raw_response_wrapper( groups.list, ) - self.delete = to_raw_response_wrapper( - groups.delete, - ) - self.get = to_raw_response_wrapper( - groups.get, - ) class AsyncGroupsResourceWithRawResponse: @@ -737,18 +329,9 @@ def __init__(self, groups: AsyncGroupsResource) -> None: self.create = async_to_raw_response_wrapper( groups.create, ) - self.update = async_to_raw_response_wrapper( - groups.update, - ) self.list = async_to_raw_response_wrapper( groups.list, ) - self.delete = async_to_raw_response_wrapper( - groups.delete, - ) - self.get = async_to_raw_response_wrapper( - groups.get, - ) class GroupsResourceWithStreamingResponse: @@ -758,18 +341,9 @@ def __init__(self, groups: GroupsResource) -> None: self.create = to_streamed_response_wrapper( groups.create, ) - self.update = to_streamed_response_wrapper( - groups.update, - ) self.list = to_streamed_response_wrapper( groups.list, ) - self.delete = to_streamed_response_wrapper( - groups.delete, - ) - self.get = to_streamed_response_wrapper( - groups.get, - ) class AsyncGroupsResourceWithStreamingResponse: @@ -779,15 +353,6 @@ def __init__(self, groups: AsyncGroupsResource) -> None: self.create = async_to_streamed_response_wrapper( groups.create, ) - self.update = async_to_streamed_response_wrapper( - groups.update, - ) self.list = async_to_streamed_response_wrapper( groups.list, ) - self.delete = async_to_streamed_response_wrapper( - groups.delete, - ) - self.get = async_to_streamed_response_wrapper( - groups.get, - ) diff --git a/src/cloudflare/resources/zero_trust/access/keys.py b/src/cloudflare/resources/zero_trust/access/keys.py deleted file mode 100644 index dcb6a69a3d2..00000000000 --- a/src/cloudflare/resources/zero_trust/access/keys.py +++ /dev/null @@ -1,387 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Any, 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.access import key_update_params -from ....types.zero_trust.access.key_get_response import KeyGetResponse -from ....types.zero_trust.access.key_rotate_response import KeyRotateResponse -from ....types.zero_trust.access.key_update_response import KeyUpdateResponse - -__all__ = ["KeysResource", "AsyncKeysResource"] - - -class KeysResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> KeysResourceWithRawResponse: - return KeysResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> KeysResourceWithStreamingResponse: - return KeysResourceWithStreamingResponse(self) - - def update( - self, - identifier: str, - *, - key_rotation_interval_days: float, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[KeyUpdateResponse]: - """ - Updates the Access key rotation settings for an account. - - Args: - identifier: Identifier - - key_rotation_interval_days: The number of days between key rotations. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return cast( - Optional[KeyUpdateResponse], - self._put( - f"/accounts/{identifier}/access/keys", - body=maybe_transform( - {"key_rotation_interval_days": key_rotation_interval_days}, key_update_params.KeyUpdateParams - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[KeyUpdateResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[KeyUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def get( - self, - identifier: 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[KeyGetResponse]: - """ - Gets the Access key rotation settings for an account. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return cast( - Optional[KeyGetResponse], - self._get( - f"/accounts/{identifier}/access/keys", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[KeyGetResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[KeyGetResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def rotate( - self, - identifier: 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[KeyRotateResponse]: - """ - Perfoms a key rotation for an account. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return cast( - Optional[KeyRotateResponse], - self._post( - f"/accounts/{identifier}/access/keys/rotate", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[KeyRotateResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[KeyRotateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - -class AsyncKeysResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncKeysResourceWithRawResponse: - return AsyncKeysResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncKeysResourceWithStreamingResponse: - return AsyncKeysResourceWithStreamingResponse(self) - - async def update( - self, - identifier: str, - *, - key_rotation_interval_days: float, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[KeyUpdateResponse]: - """ - Updates the Access key rotation settings for an account. - - Args: - identifier: Identifier - - key_rotation_interval_days: The number of days between key rotations. - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return cast( - Optional[KeyUpdateResponse], - await self._put( - f"/accounts/{identifier}/access/keys", - body=await async_maybe_transform( - {"key_rotation_interval_days": key_rotation_interval_days}, key_update_params.KeyUpdateParams - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[KeyUpdateResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[KeyUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - async def get( - self, - identifier: 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[KeyGetResponse]: - """ - Gets the Access key rotation settings for an account. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return cast( - Optional[KeyGetResponse], - await self._get( - f"/accounts/{identifier}/access/keys", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[KeyGetResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[KeyGetResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - async def rotate( - self, - identifier: 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[KeyRotateResponse]: - """ - Perfoms a key rotation for an account. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return cast( - Optional[KeyRotateResponse], - await self._post( - f"/accounts/{identifier}/access/keys/rotate", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[KeyRotateResponse]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[KeyRotateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - -class KeysResourceWithRawResponse: - def __init__(self, keys: KeysResource) -> None: - self._keys = keys - - self.update = to_raw_response_wrapper( - keys.update, - ) - self.get = to_raw_response_wrapper( - keys.get, - ) - self.rotate = to_raw_response_wrapper( - keys.rotate, - ) - - -class AsyncKeysResourceWithRawResponse: - def __init__(self, keys: AsyncKeysResource) -> None: - self._keys = keys - - self.update = async_to_raw_response_wrapper( - keys.update, - ) - self.get = async_to_raw_response_wrapper( - keys.get, - ) - self.rotate = async_to_raw_response_wrapper( - keys.rotate, - ) - - -class KeysResourceWithStreamingResponse: - def __init__(self, keys: KeysResource) -> None: - self._keys = keys - - self.update = to_streamed_response_wrapper( - keys.update, - ) - self.get = to_streamed_response_wrapper( - keys.get, - ) - self.rotate = to_streamed_response_wrapper( - keys.rotate, - ) - - -class AsyncKeysResourceWithStreamingResponse: - def __init__(self, keys: AsyncKeysResource) -> None: - self._keys = keys - - self.update = async_to_streamed_response_wrapper( - keys.update, - ) - self.get = async_to_streamed_response_wrapper( - keys.get, - ) - self.rotate = async_to_streamed_response_wrapper( - keys.rotate, - ) diff --git a/src/cloudflare/resources/zero_trust/access/logs/__init__.py b/src/cloudflare/resources/zero_trust/access/logs/__init__.py deleted file mode 100644 index 7479c1fbef8..00000000000 --- a/src/cloudflare/resources/zero_trust/access/logs/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .logs import ( - LogsResource, - AsyncLogsResource, - LogsResourceWithRawResponse, - AsyncLogsResourceWithRawResponse, - LogsResourceWithStreamingResponse, - AsyncLogsResourceWithStreamingResponse, -) -from .access_requests import ( - AccessRequestsResource, - AsyncAccessRequestsResource, - AccessRequestsResourceWithRawResponse, - AsyncAccessRequestsResourceWithRawResponse, - AccessRequestsResourceWithStreamingResponse, - AsyncAccessRequestsResourceWithStreamingResponse, -) - -__all__ = [ - "AccessRequestsResource", - "AsyncAccessRequestsResource", - "AccessRequestsResourceWithRawResponse", - "AsyncAccessRequestsResourceWithRawResponse", - "AccessRequestsResourceWithStreamingResponse", - "AsyncAccessRequestsResourceWithStreamingResponse", - "LogsResource", - "AsyncLogsResource", - "LogsResourceWithRawResponse", - "AsyncLogsResourceWithRawResponse", - "LogsResourceWithStreamingResponse", - "AsyncLogsResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py deleted file mode 100644 index 8425be9c392..00000000000 --- a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py +++ /dev/null @@ -1,158 +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.access.logs.access_request_list_response import AccessRequestListResponse - -__all__ = ["AccessRequestsResource", "AsyncAccessRequestsResource"] - - -class AccessRequestsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> AccessRequestsResourceWithRawResponse: - return AccessRequestsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AccessRequestsResourceWithStreamingResponse: - return AccessRequestsResourceWithStreamingResponse(self) - - def list( - self, - identifier: 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[AccessRequestListResponse]: - """ - Gets a list of Access authentication audit logs for an account. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get( - f"/accounts/{identifier}/access/logs/access_requests", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AccessRequestListResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AccessRequestListResponse]], ResultWrapper[AccessRequestListResponse]), - ) - - -class AsyncAccessRequestsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncAccessRequestsResourceWithRawResponse: - return AsyncAccessRequestsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncAccessRequestsResourceWithStreamingResponse: - return AsyncAccessRequestsResourceWithStreamingResponse(self) - - async def list( - self, - identifier: 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[AccessRequestListResponse]: - """ - Gets a list of Access authentication audit logs for an account. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return await self._get( - f"/accounts/{identifier}/access/logs/access_requests", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AccessRequestListResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AccessRequestListResponse]], ResultWrapper[AccessRequestListResponse]), - ) - - -class AccessRequestsResourceWithRawResponse: - def __init__(self, access_requests: AccessRequestsResource) -> None: - self._access_requests = access_requests - - self.list = to_raw_response_wrapper( - access_requests.list, - ) - - -class AsyncAccessRequestsResourceWithRawResponse: - def __init__(self, access_requests: AsyncAccessRequestsResource) -> None: - self._access_requests = access_requests - - self.list = async_to_raw_response_wrapper( - access_requests.list, - ) - - -class AccessRequestsResourceWithStreamingResponse: - def __init__(self, access_requests: AccessRequestsResource) -> None: - self._access_requests = access_requests - - self.list = to_streamed_response_wrapper( - access_requests.list, - ) - - -class AsyncAccessRequestsResourceWithStreamingResponse: - def __init__(self, access_requests: AsyncAccessRequestsResource) -> None: - self._access_requests = access_requests - - self.list = async_to_streamed_response_wrapper( - access_requests.list, - ) diff --git a/src/cloudflare/resources/zero_trust/access/logs/logs.py b/src/cloudflare/resources/zero_trust/access/logs/logs.py deleted file mode 100644 index 39226d42917..00000000000 --- a/src/cloudflare/resources/zero_trust/access/logs/logs.py +++ /dev/null @@ -1,80 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from .access_requests import ( - AccessRequestsResource, - AsyncAccessRequestsResource, - AccessRequestsResourceWithRawResponse, - AsyncAccessRequestsResourceWithRawResponse, - AccessRequestsResourceWithStreamingResponse, - AsyncAccessRequestsResourceWithStreamingResponse, -) - -__all__ = ["LogsResource", "AsyncLogsResource"] - - -class LogsResource(SyncAPIResource): - @cached_property - def access_requests(self) -> AccessRequestsResource: - return AccessRequestsResource(self._client) - - @cached_property - def with_raw_response(self) -> LogsResourceWithRawResponse: - return LogsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> LogsResourceWithStreamingResponse: - return LogsResourceWithStreamingResponse(self) - - -class AsyncLogsResource(AsyncAPIResource): - @cached_property - def access_requests(self) -> AsyncAccessRequestsResource: - return AsyncAccessRequestsResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncLogsResourceWithRawResponse: - return AsyncLogsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncLogsResourceWithStreamingResponse: - return AsyncLogsResourceWithStreamingResponse(self) - - -class LogsResourceWithRawResponse: - def __init__(self, logs: LogsResource) -> None: - self._logs = logs - - @cached_property - def access_requests(self) -> AccessRequestsResourceWithRawResponse: - return AccessRequestsResourceWithRawResponse(self._logs.access_requests) - - -class AsyncLogsResourceWithRawResponse: - def __init__(self, logs: AsyncLogsResource) -> None: - self._logs = logs - - @cached_property - def access_requests(self) -> AsyncAccessRequestsResourceWithRawResponse: - return AsyncAccessRequestsResourceWithRawResponse(self._logs.access_requests) - - -class LogsResourceWithStreamingResponse: - def __init__(self, logs: LogsResource) -> None: - self._logs = logs - - @cached_property - def access_requests(self) -> AccessRequestsResourceWithStreamingResponse: - return AccessRequestsResourceWithStreamingResponse(self._logs.access_requests) - - -class AsyncLogsResourceWithStreamingResponse: - def __init__(self, logs: AsyncLogsResource) -> None: - self._logs = logs - - @cached_property - def access_requests(self) -> AsyncAccessRequestsResourceWithStreamingResponse: - return AsyncAccessRequestsResourceWithStreamingResponse(self._logs.access_requests) diff --git a/src/cloudflare/resources/zero_trust/access/service_tokens.py b/src/cloudflare/resources/zero_trust/access/service_tokens.py index 99c07117732..679b675fdaa 100644 --- a/src/cloudflare/resources/zero_trust/access/service_tokens.py +++ b/src/cloudflare/resources/zero_trust/access/service_tokens.py @@ -25,10 +25,9 @@ AsyncPaginator, make_request_options, ) -from ....types.zero_trust.access import service_token_create_params, service_token_update_params +from ....types.zero_trust.access import service_token_create_params from ....types.zero_trust.access.service_token import ServiceToken from ....types.zero_trust.access.service_token_create_response import ServiceTokenCreateResponse -from ....types.zero_trust.access.service_token_rotate_response import ServiceTokenRotateResponse __all__ = ["ServiceTokensResource", "AsyncServiceTokensResource"] @@ -112,78 +111,6 @@ def create( cast_to=cast(Type[Optional[ServiceTokenCreateResponse]], ResultWrapper[ServiceTokenCreateResponse]), ) - def update( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - duration: str | NotGiven = NOT_GIVEN, - name: 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[ServiceToken]: - """ - Updates a configured service token. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - duration: The duration for how long the service token will be valid. Must be in the format - `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - default is 1 year in hours (8760h). - - name: The name of the service token. - - 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 uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{uuid}", - body=maybe_transform( - { - "duration": duration, - "name": name, - }, - service_token_update_params.ServiceTokenUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), - ) - def list( self, *, @@ -233,208 +160,6 @@ def list( model=ServiceToken, ) - def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ServiceToken]: - """ - Deletes a service token. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), - ) - - def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ServiceToken]: - """ - Fetches a single service token. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), - ) - - def refresh( - self, - uuid: str, - *, - identifier: 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[ServiceToken]: - """ - Refreshes the expiration of a service token. - - Args: - identifier: Identifier - - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._post( - f"/accounts/{identifier}/access/service_tokens/{uuid}/refresh", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), - ) - - def rotate( - self, - uuid: str, - *, - identifier: 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[ServiceTokenRotateResponse]: - """ - Generates a new Client Secret for a service token and revokes the old one. - - Args: - identifier: Identifier - - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return self._post( - f"/accounts/{identifier}/access/service_tokens/{uuid}/rotate", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceTokenRotateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceTokenRotateResponse]], ResultWrapper[ServiceTokenRotateResponse]), - ) - class AsyncServiceTokensResource(AsyncAPIResource): @cached_property @@ -515,78 +240,6 @@ async def create( cast_to=cast(Type[Optional[ServiceTokenCreateResponse]], ResultWrapper[ServiceTokenCreateResponse]), ) - async def update( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - duration: str | NotGiven = NOT_GIVEN, - name: 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[ServiceToken]: - """ - Updates a configured service token. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - duration: The duration for how long the service token will be valid. Must be in the format - `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - default is 1 year in hours (8760h). - - name: The name of the service token. - - 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 uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{uuid}", - body=await async_maybe_transform( - { - "duration": duration, - "name": name, - }, - service_token_update_params.ServiceTokenUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), - ) - def list( self, *, @@ -636,208 +289,6 @@ def list( model=ServiceToken, ) - async def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ServiceToken]: - """ - Deletes a service token. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), - ) - - async def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ServiceToken]: - """ - Fetches a single service token. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), - ) - - async def refresh( - self, - uuid: str, - *, - identifier: 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[ServiceToken]: - """ - Refreshes the expiration of a service token. - - Args: - identifier: Identifier - - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._post( - f"/accounts/{identifier}/access/service_tokens/{uuid}/refresh", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), - ) - - async def rotate( - self, - uuid: str, - *, - identifier: 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[ServiceTokenRotateResponse]: - """ - Generates a new Client Secret for a service token and revokes the old one. - - Args: - identifier: Identifier - - uuid: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - return await self._post( - f"/accounts/{identifier}/access/service_tokens/{uuid}/rotate", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ServiceTokenRotateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ServiceTokenRotateResponse]], ResultWrapper[ServiceTokenRotateResponse]), - ) - class ServiceTokensResourceWithRawResponse: def __init__(self, service_tokens: ServiceTokensResource) -> None: @@ -846,24 +297,9 @@ def __init__(self, service_tokens: ServiceTokensResource) -> None: self.create = to_raw_response_wrapper( service_tokens.create, ) - self.update = to_raw_response_wrapper( - service_tokens.update, - ) self.list = to_raw_response_wrapper( service_tokens.list, ) - self.delete = to_raw_response_wrapper( - service_tokens.delete, - ) - self.get = to_raw_response_wrapper( - service_tokens.get, - ) - self.refresh = to_raw_response_wrapper( - service_tokens.refresh, - ) - self.rotate = to_raw_response_wrapper( - service_tokens.rotate, - ) class AsyncServiceTokensResourceWithRawResponse: @@ -873,24 +309,9 @@ def __init__(self, service_tokens: AsyncServiceTokensResource) -> None: self.create = async_to_raw_response_wrapper( service_tokens.create, ) - self.update = async_to_raw_response_wrapper( - service_tokens.update, - ) self.list = async_to_raw_response_wrapper( service_tokens.list, ) - self.delete = async_to_raw_response_wrapper( - service_tokens.delete, - ) - self.get = async_to_raw_response_wrapper( - service_tokens.get, - ) - self.refresh = async_to_raw_response_wrapper( - service_tokens.refresh, - ) - self.rotate = async_to_raw_response_wrapper( - service_tokens.rotate, - ) class ServiceTokensResourceWithStreamingResponse: @@ -900,24 +321,9 @@ def __init__(self, service_tokens: ServiceTokensResource) -> None: self.create = to_streamed_response_wrapper( service_tokens.create, ) - self.update = to_streamed_response_wrapper( - service_tokens.update, - ) self.list = to_streamed_response_wrapper( service_tokens.list, ) - self.delete = to_streamed_response_wrapper( - service_tokens.delete, - ) - self.get = to_streamed_response_wrapper( - service_tokens.get, - ) - self.refresh = to_streamed_response_wrapper( - service_tokens.refresh, - ) - self.rotate = to_streamed_response_wrapper( - service_tokens.rotate, - ) class AsyncServiceTokensResourceWithStreamingResponse: @@ -927,21 +333,6 @@ def __init__(self, service_tokens: AsyncServiceTokensResource) -> None: self.create = async_to_streamed_response_wrapper( service_tokens.create, ) - self.update = async_to_streamed_response_wrapper( - service_tokens.update, - ) self.list = async_to_streamed_response_wrapper( service_tokens.list, ) - self.delete = async_to_streamed_response_wrapper( - service_tokens.delete, - ) - self.get = async_to_streamed_response_wrapper( - service_tokens.get, - ) - self.refresh = async_to_streamed_response_wrapper( - service_tokens.refresh, - ) - self.rotate = async_to_streamed_response_wrapper( - service_tokens.rotate, - ) diff --git a/src/cloudflare/resources/zero_trust/access/tags.py b/src/cloudflare/resources/zero_trust/access/tags.py deleted file mode 100644 index d7ba373faf7..00000000000 --- a/src/cloudflare/resources/zero_trust/access/tags.py +++ /dev/null @@ -1,566 +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 ...._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 ...._base_client import ( - AsyncPaginator, - make_request_options, -) -from ....types.zero_trust.access import tag_create_params, tag_update_params -from ....types.zero_trust.access.tag import Tag -from ....types.zero_trust.access.tag_delete_response import TagDeleteResponse - -__all__ = ["TagsResource", "AsyncTagsResource"] - - -class TagsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> TagsResourceWithRawResponse: - return TagsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> TagsResourceWithStreamingResponse: - return TagsResourceWithStreamingResponse(self) - - def create( - self, - identifier: str, - *, - name: 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[Tag]: - """ - Create a tag - - Args: - identifier: Identifier - - name: The name of the tag - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._post( - f"/accounts/{identifier}/access/tags", - body=maybe_transform({"name": name}, tag_create_params.TagCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Tag]]._unwrapper, - ), - cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), - ) - - def update( - self, - tag_name: str, - *, - identifier: str, - name: 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[Tag]: - """ - Update a tag - - Args: - identifier: Identifier - - tag_name: The name of the tag - - name: The name of the tag - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not tag_name: - raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") - return self._put( - f"/accounts/{identifier}/access/tags/{tag_name}", - body=maybe_transform({"name": name}, tag_update_params.TagUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Tag]]._unwrapper, - ), - cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), - ) - - def list( - self, - identifier: 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[Tag]: - """ - List tags - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/tags", - page=SyncSinglePage[Tag], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=Tag, - ) - - def delete( - self, - name: str, - *, - identifier: 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[TagDeleteResponse]: - """ - Delete a tag - - Args: - identifier: Identifier - - name: The name of the tag - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - return self._delete( - f"/accounts/{identifier}/access/tags/{name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[TagDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[TagDeleteResponse]], ResultWrapper[TagDeleteResponse]), - ) - - def get( - self, - name: str, - *, - identifier: 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[Tag]: - """ - Get a tag - - Args: - identifier: Identifier - - name: The name of the tag - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - return self._get( - f"/accounts/{identifier}/access/tags/{name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Tag]]._unwrapper, - ), - cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), - ) - - -class AsyncTagsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncTagsResourceWithRawResponse: - return AsyncTagsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncTagsResourceWithStreamingResponse: - return AsyncTagsResourceWithStreamingResponse(self) - - async def create( - self, - identifier: str, - *, - name: 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[Tag]: - """ - Create a tag - - Args: - identifier: Identifier - - name: The name of the tag - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return await self._post( - f"/accounts/{identifier}/access/tags", - body=await async_maybe_transform({"name": name}, tag_create_params.TagCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Tag]]._unwrapper, - ), - cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), - ) - - async def update( - self, - tag_name: str, - *, - identifier: str, - name: 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[Tag]: - """ - Update a tag - - Args: - identifier: Identifier - - tag_name: The name of the tag - - name: The name of the tag - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not tag_name: - raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") - return await self._put( - f"/accounts/{identifier}/access/tags/{tag_name}", - body=await async_maybe_transform({"name": name}, tag_update_params.TagUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Tag]]._unwrapper, - ), - cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), - ) - - def list( - self, - identifier: 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[Tag, AsyncSinglePage[Tag]]: - """ - List tags - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/tags", - page=AsyncSinglePage[Tag], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=Tag, - ) - - async def delete( - self, - name: str, - *, - identifier: 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[TagDeleteResponse]: - """ - Delete a tag - - Args: - identifier: Identifier - - name: The name of the tag - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - return await self._delete( - f"/accounts/{identifier}/access/tags/{name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[TagDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[TagDeleteResponse]], ResultWrapper[TagDeleteResponse]), - ) - - async def get( - self, - name: str, - *, - identifier: 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[Tag]: - """ - Get a tag - - Args: - identifier: Identifier - - name: The name of the tag - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - return await self._get( - f"/accounts/{identifier}/access/tags/{name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Tag]]._unwrapper, - ), - cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), - ) - - -class TagsResourceWithRawResponse: - def __init__(self, tags: TagsResource) -> None: - self._tags = tags - - self.create = to_raw_response_wrapper( - tags.create, - ) - self.update = to_raw_response_wrapper( - tags.update, - ) - self.list = to_raw_response_wrapper( - tags.list, - ) - self.delete = to_raw_response_wrapper( - tags.delete, - ) - self.get = to_raw_response_wrapper( - tags.get, - ) - - -class AsyncTagsResourceWithRawResponse: - def __init__(self, tags: AsyncTagsResource) -> None: - self._tags = tags - - self.create = async_to_raw_response_wrapper( - tags.create, - ) - self.update = async_to_raw_response_wrapper( - tags.update, - ) - self.list = async_to_raw_response_wrapper( - tags.list, - ) - self.delete = async_to_raw_response_wrapper( - tags.delete, - ) - self.get = async_to_raw_response_wrapper( - tags.get, - ) - - -class TagsResourceWithStreamingResponse: - def __init__(self, tags: TagsResource) -> None: - self._tags = tags - - self.create = to_streamed_response_wrapper( - tags.create, - ) - self.update = to_streamed_response_wrapper( - tags.update, - ) - self.list = to_streamed_response_wrapper( - tags.list, - ) - self.delete = to_streamed_response_wrapper( - tags.delete, - ) - self.get = to_streamed_response_wrapper( - tags.get, - ) - - -class AsyncTagsResourceWithStreamingResponse: - def __init__(self, tags: AsyncTagsResource) -> None: - self._tags = tags - - self.create = async_to_streamed_response_wrapper( - tags.create, - ) - self.update = async_to_streamed_response_wrapper( - tags.update, - ) - self.list = async_to_streamed_response_wrapper( - tags.list, - ) - self.delete = async_to_streamed_response_wrapper( - tags.delete, - ) - self.get = async_to_streamed_response_wrapper( - tags.get, - ) diff --git a/src/cloudflare/resources/zero_trust/access/users/__init__.py b/src/cloudflare/resources/zero_trust/access/users/__init__.py deleted file mode 100644 index c5766c1427a..00000000000 --- a/src/cloudflare/resources/zero_trust/access/users/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .users import ( - UsersResource, - AsyncUsersResource, - UsersResourceWithRawResponse, - AsyncUsersResourceWithRawResponse, - UsersResourceWithStreamingResponse, - AsyncUsersResourceWithStreamingResponse, -) -from .failed_logins import ( - FailedLoginsResource, - AsyncFailedLoginsResource, - FailedLoginsResourceWithRawResponse, - AsyncFailedLoginsResourceWithRawResponse, - FailedLoginsResourceWithStreamingResponse, - AsyncFailedLoginsResourceWithStreamingResponse, -) -from .active_sessions import ( - ActiveSessionsResource, - AsyncActiveSessionsResource, - ActiveSessionsResourceWithRawResponse, - AsyncActiveSessionsResourceWithRawResponse, - ActiveSessionsResourceWithStreamingResponse, - AsyncActiveSessionsResourceWithStreamingResponse, -) -from .last_seen_identity import ( - LastSeenIdentityResource, - AsyncLastSeenIdentityResource, - LastSeenIdentityResourceWithRawResponse, - AsyncLastSeenIdentityResourceWithRawResponse, - LastSeenIdentityResourceWithStreamingResponse, - AsyncLastSeenIdentityResourceWithStreamingResponse, -) - -__all__ = [ - "ActiveSessionsResource", - "AsyncActiveSessionsResource", - "ActiveSessionsResourceWithRawResponse", - "AsyncActiveSessionsResourceWithRawResponse", - "ActiveSessionsResourceWithStreamingResponse", - "AsyncActiveSessionsResourceWithStreamingResponse", - "LastSeenIdentityResource", - "AsyncLastSeenIdentityResource", - "LastSeenIdentityResourceWithRawResponse", - "AsyncLastSeenIdentityResourceWithRawResponse", - "LastSeenIdentityResourceWithStreamingResponse", - "AsyncLastSeenIdentityResourceWithStreamingResponse", - "FailedLoginsResource", - "AsyncFailedLoginsResource", - "FailedLoginsResourceWithRawResponse", - "AsyncFailedLoginsResourceWithRawResponse", - "FailedLoginsResourceWithStreamingResponse", - "AsyncFailedLoginsResourceWithStreamingResponse", - "UsersResource", - "AsyncUsersResource", - "UsersResourceWithRawResponse", - "AsyncUsersResourceWithRawResponse", - "UsersResourceWithStreamingResponse", - "AsyncUsersResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/zero_trust/access/users/active_sessions.py b/src/cloudflare/resources/zero_trust/access/users/active_sessions.py deleted file mode 100644 index 0a39ccddb3d..00000000000 --- a/src/cloudflare/resources/zero_trust/access/users/active_sessions.py +++ /dev/null @@ -1,271 +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 .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import ( - AsyncPaginator, - make_request_options, -) -from .....types.zero_trust.access.users.active_session_get_response import ActiveSessionGetResponse -from .....types.zero_trust.access.users.active_session_list_response import ActiveSessionListResponse - -__all__ = ["ActiveSessionsResource", "AsyncActiveSessionsResource"] - - -class ActiveSessionsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> ActiveSessionsResourceWithRawResponse: - return ActiveSessionsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> ActiveSessionsResourceWithStreamingResponse: - return ActiveSessionsResourceWithStreamingResponse(self) - - def list( - self, - id: str, - *, - identifier: 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[ActiveSessionListResponse]: - """ - Get active sessions for a single user. - - Args: - identifier: Identifier - - id: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/users/{id}/active_sessions", - page=SyncSinglePage[ActiveSessionListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=ActiveSessionListResponse, - ) - - def get( - self, - nonce: str, - *, - identifier: str, - 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[ActiveSessionGetResponse]: - """ - Get an active session for a single user. - - Args: - identifier: Identifier - - id: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - if not nonce: - raise ValueError(f"Expected a non-empty value for `nonce` but received {nonce!r}") - return self._get( - f"/accounts/{identifier}/access/users/{id}/active_sessions/{nonce}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ActiveSessionGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ActiveSessionGetResponse]], ResultWrapper[ActiveSessionGetResponse]), - ) - - -class AsyncActiveSessionsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncActiveSessionsResourceWithRawResponse: - return AsyncActiveSessionsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncActiveSessionsResourceWithStreamingResponse: - return AsyncActiveSessionsResourceWithStreamingResponse(self) - - def list( - self, - id: str, - *, - identifier: 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[ActiveSessionListResponse, AsyncSinglePage[ActiveSessionListResponse]]: - """ - Get active sessions for a single user. - - Args: - identifier: Identifier - - id: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/users/{id}/active_sessions", - page=AsyncSinglePage[ActiveSessionListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=ActiveSessionListResponse, - ) - - async def get( - self, - nonce: str, - *, - identifier: str, - 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[ActiveSessionGetResponse]: - """ - Get an active session for a single user. - - Args: - identifier: Identifier - - id: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - if not nonce: - raise ValueError(f"Expected a non-empty value for `nonce` but received {nonce!r}") - return await self._get( - f"/accounts/{identifier}/access/users/{id}/active_sessions/{nonce}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[ActiveSessionGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[ActiveSessionGetResponse]], ResultWrapper[ActiveSessionGetResponse]), - ) - - -class ActiveSessionsResourceWithRawResponse: - def __init__(self, active_sessions: ActiveSessionsResource) -> None: - self._active_sessions = active_sessions - - self.list = to_raw_response_wrapper( - active_sessions.list, - ) - self.get = to_raw_response_wrapper( - active_sessions.get, - ) - - -class AsyncActiveSessionsResourceWithRawResponse: - def __init__(self, active_sessions: AsyncActiveSessionsResource) -> None: - self._active_sessions = active_sessions - - self.list = async_to_raw_response_wrapper( - active_sessions.list, - ) - self.get = async_to_raw_response_wrapper( - active_sessions.get, - ) - - -class ActiveSessionsResourceWithStreamingResponse: - def __init__(self, active_sessions: ActiveSessionsResource) -> None: - self._active_sessions = active_sessions - - self.list = to_streamed_response_wrapper( - active_sessions.list, - ) - self.get = to_streamed_response_wrapper( - active_sessions.get, - ) - - -class AsyncActiveSessionsResourceWithStreamingResponse: - def __init__(self, active_sessions: AsyncActiveSessionsResource) -> None: - self._active_sessions = active_sessions - - self.list = async_to_streamed_response_wrapper( - active_sessions.list, - ) - self.get = async_to_streamed_response_wrapper( - active_sessions.get, - ) diff --git a/src/cloudflare/resources/zero_trust/access/users/failed_logins.py b/src/cloudflare/resources/zero_trust/access/users/failed_logins.py deleted file mode 100644 index 6b2b7d19f57..00000000000 --- a/src/cloudflare/resources/zero_trust/access/users/failed_logins.py +++ /dev/null @@ -1,161 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -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 .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import ( - AsyncPaginator, - make_request_options, -) -from .....types.zero_trust.access.users.failed_login_list_response import FailedLoginListResponse - -__all__ = ["FailedLoginsResource", "AsyncFailedLoginsResource"] - - -class FailedLoginsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> FailedLoginsResourceWithRawResponse: - return FailedLoginsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> FailedLoginsResourceWithStreamingResponse: - return FailedLoginsResourceWithStreamingResponse(self) - - def list( - self, - id: str, - *, - identifier: 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[FailedLoginListResponse]: - """ - Get all failed login attempts for a single user. - - Args: - identifier: Identifier - - id: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/users/{id}/failed_logins", - page=SyncSinglePage[FailedLoginListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=FailedLoginListResponse, - ) - - -class AsyncFailedLoginsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncFailedLoginsResourceWithRawResponse: - return AsyncFailedLoginsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncFailedLoginsResourceWithStreamingResponse: - return AsyncFailedLoginsResourceWithStreamingResponse(self) - - def list( - self, - id: str, - *, - identifier: 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[FailedLoginListResponse, AsyncSinglePage[FailedLoginListResponse]]: - """ - Get all failed login attempts for a single user. - - Args: - identifier: Identifier - - id: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/users/{id}/failed_logins", - page=AsyncSinglePage[FailedLoginListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=FailedLoginListResponse, - ) - - -class FailedLoginsResourceWithRawResponse: - def __init__(self, failed_logins: FailedLoginsResource) -> None: - self._failed_logins = failed_logins - - self.list = to_raw_response_wrapper( - failed_logins.list, - ) - - -class AsyncFailedLoginsResourceWithRawResponse: - def __init__(self, failed_logins: AsyncFailedLoginsResource) -> None: - self._failed_logins = failed_logins - - self.list = async_to_raw_response_wrapper( - failed_logins.list, - ) - - -class FailedLoginsResourceWithStreamingResponse: - def __init__(self, failed_logins: FailedLoginsResource) -> None: - self._failed_logins = failed_logins - - self.list = to_streamed_response_wrapper( - failed_logins.list, - ) - - -class AsyncFailedLoginsResourceWithStreamingResponse: - def __init__(self, failed_logins: AsyncFailedLoginsResource) -> None: - self._failed_logins = failed_logins - - self.list = async_to_streamed_response_wrapper( - failed_logins.list, - ) diff --git a/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py b/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py deleted file mode 100644 index 4e913e2720c..00000000000 --- a/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py +++ /dev/null @@ -1,168 +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.access.users.identity import Identity - -__all__ = ["LastSeenIdentityResource", "AsyncLastSeenIdentityResource"] - - -class LastSeenIdentityResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> LastSeenIdentityResourceWithRawResponse: - return LastSeenIdentityResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> LastSeenIdentityResourceWithStreamingResponse: - return LastSeenIdentityResourceWithStreamingResponse(self) - - def get( - self, - id: str, - *, - identifier: 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[Identity]: - """ - Get last seen identity for a single user. - - Args: - identifier: Identifier - - id: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get( - f"/accounts/{identifier}/access/users/{id}/last_seen_identity", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Identity]]._unwrapper, - ), - cast_to=cast(Type[Optional[Identity]], ResultWrapper[Identity]), - ) - - -class AsyncLastSeenIdentityResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncLastSeenIdentityResourceWithRawResponse: - return AsyncLastSeenIdentityResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncLastSeenIdentityResourceWithStreamingResponse: - return AsyncLastSeenIdentityResourceWithStreamingResponse(self) - - async def get( - self, - id: str, - *, - identifier: 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[Identity]: - """ - Get last seen identity for a single user. - - Args: - identifier: Identifier - - id: UUID - - 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 identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._get( - f"/accounts/{identifier}/access/users/{id}/last_seen_identity", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[Identity]]._unwrapper, - ), - cast_to=cast(Type[Optional[Identity]], ResultWrapper[Identity]), - ) - - -class LastSeenIdentityResourceWithRawResponse: - def __init__(self, last_seen_identity: LastSeenIdentityResource) -> None: - self._last_seen_identity = last_seen_identity - - self.get = to_raw_response_wrapper( - last_seen_identity.get, - ) - - -class AsyncLastSeenIdentityResourceWithRawResponse: - def __init__(self, last_seen_identity: AsyncLastSeenIdentityResource) -> None: - self._last_seen_identity = last_seen_identity - - self.get = async_to_raw_response_wrapper( - last_seen_identity.get, - ) - - -class LastSeenIdentityResourceWithStreamingResponse: - def __init__(self, last_seen_identity: LastSeenIdentityResource) -> None: - self._last_seen_identity = last_seen_identity - - self.get = to_streamed_response_wrapper( - last_seen_identity.get, - ) - - -class AsyncLastSeenIdentityResourceWithStreamingResponse: - def __init__(self, last_seen_identity: AsyncLastSeenIdentityResource) -> None: - self._last_seen_identity = last_seen_identity - - self.get = async_to_streamed_response_wrapper( - last_seen_identity.get, - ) diff --git a/src/cloudflare/resources/zero_trust/access/users/users.py b/src/cloudflare/resources/zero_trust/access/users/users.py deleted file mode 100644 index 97bce1fa075..00000000000 --- a/src/cloudflare/resources/zero_trust/access/users/users.py +++ /dev/null @@ -1,247 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -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 .failed_logins import ( - FailedLoginsResource, - AsyncFailedLoginsResource, - FailedLoginsResourceWithRawResponse, - AsyncFailedLoginsResourceWithRawResponse, - FailedLoginsResourceWithStreamingResponse, - AsyncFailedLoginsResourceWithStreamingResponse, -) -from .....pagination import SyncSinglePage, AsyncSinglePage -from .active_sessions import ( - ActiveSessionsResource, - AsyncActiveSessionsResource, - ActiveSessionsResourceWithRawResponse, - AsyncActiveSessionsResourceWithRawResponse, - ActiveSessionsResourceWithStreamingResponse, - AsyncActiveSessionsResourceWithStreamingResponse, -) -from ....._base_client import ( - AsyncPaginator, - make_request_options, -) -from .last_seen_identity import ( - LastSeenIdentityResource, - AsyncLastSeenIdentityResource, - LastSeenIdentityResourceWithRawResponse, - AsyncLastSeenIdentityResourceWithRawResponse, - LastSeenIdentityResourceWithStreamingResponse, - AsyncLastSeenIdentityResourceWithStreamingResponse, -) -from .....types.zero_trust.access.access_user import AccessUser - -__all__ = ["UsersResource", "AsyncUsersResource"] - - -class UsersResource(SyncAPIResource): - @cached_property - def active_sessions(self) -> ActiveSessionsResource: - return ActiveSessionsResource(self._client) - - @cached_property - def last_seen_identity(self) -> LastSeenIdentityResource: - return LastSeenIdentityResource(self._client) - - @cached_property - def failed_logins(self) -> FailedLoginsResource: - return FailedLoginsResource(self._client) - - @cached_property - def with_raw_response(self) -> UsersResourceWithRawResponse: - return UsersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> UsersResourceWithStreamingResponse: - return UsersResourceWithStreamingResponse(self) - - def list( - self, - identifier: 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[AccessUser]: - """ - Gets a list of users for an account. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/users", - page=SyncSinglePage[AccessUser], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=AccessUser, - ) - - -class AsyncUsersResource(AsyncAPIResource): - @cached_property - def active_sessions(self) -> AsyncActiveSessionsResource: - return AsyncActiveSessionsResource(self._client) - - @cached_property - def last_seen_identity(self) -> AsyncLastSeenIdentityResource: - return AsyncLastSeenIdentityResource(self._client) - - @cached_property - def failed_logins(self) -> AsyncFailedLoginsResource: - return AsyncFailedLoginsResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncUsersResourceWithRawResponse: - return AsyncUsersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncUsersResourceWithStreamingResponse: - return AsyncUsersResourceWithStreamingResponse(self) - - def list( - self, - identifier: 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[AccessUser, AsyncSinglePage[AccessUser]]: - """ - Gets a list of users for an account. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._get_api_list( - f"/accounts/{identifier}/access/users", - page=AsyncSinglePage[AccessUser], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=AccessUser, - ) - - -class UsersResourceWithRawResponse: - def __init__(self, users: UsersResource) -> None: - self._users = users - - self.list = to_raw_response_wrapper( - users.list, - ) - - @cached_property - def active_sessions(self) -> ActiveSessionsResourceWithRawResponse: - return ActiveSessionsResourceWithRawResponse(self._users.active_sessions) - - @cached_property - def last_seen_identity(self) -> LastSeenIdentityResourceWithRawResponse: - return LastSeenIdentityResourceWithRawResponse(self._users.last_seen_identity) - - @cached_property - def failed_logins(self) -> FailedLoginsResourceWithRawResponse: - return FailedLoginsResourceWithRawResponse(self._users.failed_logins) - - -class AsyncUsersResourceWithRawResponse: - def __init__(self, users: AsyncUsersResource) -> None: - self._users = users - - self.list = async_to_raw_response_wrapper( - users.list, - ) - - @cached_property - def active_sessions(self) -> AsyncActiveSessionsResourceWithRawResponse: - return AsyncActiveSessionsResourceWithRawResponse(self._users.active_sessions) - - @cached_property - def last_seen_identity(self) -> AsyncLastSeenIdentityResourceWithRawResponse: - return AsyncLastSeenIdentityResourceWithRawResponse(self._users.last_seen_identity) - - @cached_property - def failed_logins(self) -> AsyncFailedLoginsResourceWithRawResponse: - return AsyncFailedLoginsResourceWithRawResponse(self._users.failed_logins) - - -class UsersResourceWithStreamingResponse: - def __init__(self, users: UsersResource) -> None: - self._users = users - - self.list = to_streamed_response_wrapper( - users.list, - ) - - @cached_property - def active_sessions(self) -> ActiveSessionsResourceWithStreamingResponse: - return ActiveSessionsResourceWithStreamingResponse(self._users.active_sessions) - - @cached_property - def last_seen_identity(self) -> LastSeenIdentityResourceWithStreamingResponse: - return LastSeenIdentityResourceWithStreamingResponse(self._users.last_seen_identity) - - @cached_property - def failed_logins(self) -> FailedLoginsResourceWithStreamingResponse: - return FailedLoginsResourceWithStreamingResponse(self._users.failed_logins) - - -class AsyncUsersResourceWithStreamingResponse: - def __init__(self, users: AsyncUsersResource) -> None: - self._users = users - - self.list = async_to_streamed_response_wrapper( - users.list, - ) - - @cached_property - def active_sessions(self) -> AsyncActiveSessionsResourceWithStreamingResponse: - return AsyncActiveSessionsResourceWithStreamingResponse(self._users.active_sessions) - - @cached_property - def last_seen_identity(self) -> AsyncLastSeenIdentityResourceWithStreamingResponse: - return AsyncLastSeenIdentityResourceWithStreamingResponse(self._users.last_seen_identity) - - @cached_property - def failed_logins(self) -> AsyncFailedLoginsResourceWithStreamingResponse: - return AsyncFailedLoginsResourceWithStreamingResponse(self._users.failed_logins) diff --git a/src/cloudflare/resources/zero_trust/identity_providers.py b/src/cloudflare/resources/zero_trust/identity_providers.py index c07d0a4f1fb..22a66d860cd 100644 --- a/src/cloudflare/resources/zero_trust/identity_providers.py +++ b/src/cloudflare/resources/zero_trust/identity_providers.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Optional, cast, overload +from typing import Any, Optional, cast, overload import httpx @@ -26,17 +26,12 @@ AsyncPaginator, make_request_options, ) -from ...types.zero_trust import ( - IdentityProviderType, - identity_provider_create_params, - identity_provider_update_params, -) +from ...types.zero_trust import IdentityProviderType, identity_provider_create_params from ...types.zero_trust.identity_provider import IdentityProvider from ...types.zero_trust.scim_config_param import ScimConfigParam from ...types.zero_trust.identity_provider_type import IdentityProviderType from ...types.zero_trust.generic_oauth_config_param import GenericOAuthConfigParam from ...types.zero_trust.identity_provider_list_response import IdentityProviderListResponse -from ...types.zero_trust.identity_provider_delete_response import IdentityProviderDeleteResponse __all__ = ["IdentityProvidersResource", "AsyncIdentityProvidersResource"] @@ -787,12 +782,72 @@ def create( ), ) + def list( + self, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[IdentityProviderListResponse]: + """ + Lists all configured identity providers. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + page=SyncSinglePage[IdentityProviderListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=cast( + Any, IdentityProviderListResponse + ), # Union types cannot be passed in as arguments in the type system + ) + + +class AsyncIdentityProvidersResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIdentityProvidersResourceWithRawResponse: + return AsyncIdentityProvidersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIdentityProvidersResourceWithStreamingResponse: + return AsyncIdentityProvidersResourceWithStreamingResponse(self) + @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AzureADConfig, + config: identity_provider_create_params.AzureADConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -806,11 +861,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -839,11 +892,10 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AccessCentrifyConfig, + config: identity_provider_create_params.AccessCentrifyConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -857,11 +909,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -890,9 +940,8 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, config: GenericOAuthConfigParam, name: str, @@ -908,11 +957,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -941,9 +988,8 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, config: GenericOAuthConfigParam, name: str, @@ -959,11 +1005,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -992,11 +1036,10 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AccessGoogleConfig, + config: identity_provider_create_params.AccessGoogleConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1010,11 +1053,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1043,11 +1084,10 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AccessGoogleAppsConfig, + config: identity_provider_create_params.AccessGoogleAppsConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1061,11 +1101,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1094,9 +1132,8 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, config: GenericOAuthConfigParam, name: str, @@ -1112,11 +1149,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1145,11 +1180,10 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AccessOIDCConfig, + config: identity_provider_create_params.AccessOIDCConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1163,11 +1197,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1196,11 +1228,10 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AccessOktaConfig, + config: identity_provider_create_params.AccessOktaConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1214,11 +1245,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1247,11 +1276,10 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AccessOneloginConfig, + config: identity_provider_create_params.AccessOneloginConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1265,11 +1293,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1298,11 +1324,10 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AccessPingoneConfig, + config: identity_provider_create_params.AccessPingoneConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1316,11 +1341,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1349,11 +1372,10 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AccessSAMLConfig, + config: identity_provider_create_params.AccessSAMLConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1367,11 +1389,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1400,9 +1420,8 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, config: GenericOAuthConfigParam, name: str, @@ -1418,11 +1437,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1451,9 +1468,8 @@ def update( ... @overload - def update( + async def create( self, - uuid: str, *, config: object, name: str, @@ -1469,11 +1485,9 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Updates a configured identity provider. + Adds a new identity provider to Access. Args: - uuid: UUID - config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1502,20 +1516,19 @@ def update( ... @required_args(["config", "name", "type"]) - def update( + async def create( self, - uuid: str, *, - config: identity_provider_update_params.AzureADConfig - | identity_provider_update_params.AccessCentrifyConfig + config: identity_provider_create_params.AzureADConfig + | identity_provider_create_params.AccessCentrifyConfig | GenericOAuthConfigParam - | identity_provider_update_params.AccessGoogleConfig - | identity_provider_update_params.AccessGoogleAppsConfig - | identity_provider_update_params.AccessOIDCConfig - | identity_provider_update_params.AccessOktaConfig - | identity_provider_update_params.AccessOneloginConfig - | identity_provider_update_params.AccessPingoneConfig - | identity_provider_update_params.AccessSAMLConfig + | identity_provider_create_params.AccessGoogleConfig + | identity_provider_create_params.AccessGoogleAppsConfig + | identity_provider_create_params.AccessOIDCConfig + | identity_provider_create_params.AccessOktaConfig + | identity_provider_create_params.AccessOneloginConfig + | identity_provider_create_params.AccessPingoneConfig + | identity_provider_create_params.AccessSAMLConfig | object, name: str, type: IdentityProviderType, @@ -1529,8 +1542,6 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1545,16 +1556,16 @@ def update( account_or_zone_id = zone_id return cast( Optional[IdentityProvider], - self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{uuid}", - body=maybe_transform( + await self._post( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + body=await async_maybe_transform( { "config": config, "name": name, "type": type, "scim_config": scim_config, }, - identity_provider_update_params.IdentityProviderUpdateParams, + identity_provider_create_params.IdentityProviderCreateParams, ), options=make_request_options( extra_headers=extra_headers, @@ -1580,7 +1591,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[IdentityProviderListResponse]: + ) -> AsyncPaginator[IdentityProviderListResponse, AsyncSinglePage[IdentityProviderListResponse]]: """ Lists all configured identity providers. @@ -1611,7 +1622,7 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", - page=SyncSinglePage[IdentityProviderListResponse], + page=AsyncSinglePage[IdentityProviderListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1620,1904 +1631,50 @@ def list( ), # Union types cannot be passed in as arguments in the type system ) - def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[IdentityProviderDeleteResponse]: - """ - Deletes an identity provider from Access. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") +class IdentityProvidersResourceWithRawResponse: + def __init__(self, identity_providers: IdentityProvidersResource) -> None: + self._identity_providers = identity_providers - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IdentityProviderDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[IdentityProviderDeleteResponse]], ResultWrapper[IdentityProviderDeleteResponse]), + self.create = to_raw_response_wrapper( + identity_providers.create, + ) + self.list = to_raw_response_wrapper( + identity_providers.list, ) - def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[IdentityProvider]: - """ - Fetches a configured identity provider. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - extra_query: Add additional query parameters to the request +class AsyncIdentityProvidersResourceWithRawResponse: + def __init__(self, identity_providers: AsyncIdentityProvidersResource) -> None: + self._identity_providers = identity_providers - extra_body: Add additional JSON properties to the request + self.create = async_to_raw_response_wrapper( + identity_providers.create, + ) + self.list = async_to_raw_response_wrapper( + identity_providers.list, + ) - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") +class IdentityProvidersResourceWithStreamingResponse: + def __init__(self, identity_providers: IdentityProvidersResource) -> None: + self._identity_providers = identity_providers - account_or_zone = "zones" - account_or_zone_id = zone_id - return cast( - Optional[IdentityProvider], - self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IdentityProvider]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[IdentityProvider] - ), # Union types cannot be passed in as arguments in the type system - ), + self.create = to_streamed_response_wrapper( + identity_providers.create, + ) + self.list = to_streamed_response_wrapper( + identity_providers.list, ) -class AsyncIdentityProvidersResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncIdentityProvidersResourceWithRawResponse: - return AsyncIdentityProvidersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncIdentityProvidersResourceWithStreamingResponse: - return AsyncIdentityProvidersResourceWithStreamingResponse(self) - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AzureADConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AccessCentrifyConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: GenericOAuthConfigParam, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: GenericOAuthConfigParam, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AccessGoogleConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AccessGoogleAppsConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: GenericOAuthConfigParam, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AccessOIDCConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AccessOktaConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AccessOneloginConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AccessPingoneConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: identity_provider_create_params.AccessSAMLConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: GenericOAuthConfigParam, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def create( - self, - *, - config: object, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Adds a new identity provider to Access. - - Args: - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @required_args(["config", "name", "type"]) - async def create( - self, - *, - config: identity_provider_create_params.AzureADConfig - | identity_provider_create_params.AccessCentrifyConfig - | GenericOAuthConfigParam - | identity_provider_create_params.AccessGoogleConfig - | identity_provider_create_params.AccessGoogleAppsConfig - | identity_provider_create_params.AccessOIDCConfig - | identity_provider_create_params.AccessOktaConfig - | identity_provider_create_params.AccessOneloginConfig - | identity_provider_create_params.AccessPingoneConfig - | identity_provider_create_params.AccessSAMLConfig - | object, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return cast( - Optional[IdentityProvider], - await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", - body=await async_maybe_transform( - { - "config": config, - "name": name, - "type": type, - "scim_config": scim_config, - }, - identity_provider_create_params.IdentityProviderCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IdentityProvider]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[IdentityProvider] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AzureADConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AccessCentrifyConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: GenericOAuthConfigParam, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: GenericOAuthConfigParam, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AccessGoogleConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AccessGoogleAppsConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: GenericOAuthConfigParam, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AccessOIDCConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AccessOktaConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AccessOneloginConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AccessPingoneConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AccessSAMLConfig, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: GenericOAuthConfigParam, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @overload - async def update( - self, - uuid: str, - *, - config: object, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - """ - Updates a configured identity provider. - - Args: - uuid: UUID - - config: The configuration parameters for the identity provider. To view the required - parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - name: The name of the identity provider, shown to users on the login page. - - type: The type of identity provider. To determine the value for a specific provider, - refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - scim_config: The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - - 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 - """ - ... - - @required_args(["config", "name", "type"]) - async def update( - self, - uuid: str, - *, - config: identity_provider_update_params.AzureADConfig - | identity_provider_update_params.AccessCentrifyConfig - | GenericOAuthConfigParam - | identity_provider_update_params.AccessGoogleConfig - | identity_provider_update_params.AccessGoogleAppsConfig - | identity_provider_update_params.AccessOIDCConfig - | identity_provider_update_params.AccessOktaConfig - | identity_provider_update_params.AccessOneloginConfig - | identity_provider_update_params.AccessPingoneConfig - | identity_provider_update_params.AccessSAMLConfig - | object, - name: str, - type: IdentityProviderType, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | 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[IdentityProvider]: - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return cast( - Optional[IdentityProvider], - await self._put( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{uuid}", - body=await async_maybe_transform( - { - "config": config, - "name": name, - "type": type, - "scim_config": scim_config, - }, - identity_provider_update_params.IdentityProviderUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IdentityProvider]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[IdentityProvider] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def list( - self, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[IdentityProviderListResponse, AsyncSinglePage[IdentityProviderListResponse]]: - """ - Lists all configured identity providers. - - Args: - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", - page=AsyncSinglePage[IdentityProviderListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=cast( - Any, IdentityProviderListResponse - ), # Union types cannot be passed in as arguments in the type system - ) - - async def delete( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[IdentityProviderDeleteResponse]: - """ - Deletes an identity provider from Access. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IdentityProviderDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[IdentityProviderDeleteResponse]], ResultWrapper[IdentityProviderDeleteResponse]), - ) - - async def get( - self, - uuid: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[IdentityProvider]: - """ - Fetches a configured identity provider. - - Args: - uuid: UUID - - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not uuid: - raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return cast( - Optional[IdentityProvider], - await self._get( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{uuid}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[IdentityProvider]]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[IdentityProvider] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - -class IdentityProvidersResourceWithRawResponse: - def __init__(self, identity_providers: IdentityProvidersResource) -> None: - self._identity_providers = identity_providers - - self.create = to_raw_response_wrapper( - identity_providers.create, - ) - self.update = to_raw_response_wrapper( - identity_providers.update, - ) - self.list = to_raw_response_wrapper( - identity_providers.list, - ) - self.delete = to_raw_response_wrapper( - identity_providers.delete, - ) - self.get = to_raw_response_wrapper( - identity_providers.get, - ) - - -class AsyncIdentityProvidersResourceWithRawResponse: - def __init__(self, identity_providers: AsyncIdentityProvidersResource) -> None: - self._identity_providers = identity_providers - - self.create = async_to_raw_response_wrapper( - identity_providers.create, - ) - self.update = async_to_raw_response_wrapper( - identity_providers.update, - ) - self.list = async_to_raw_response_wrapper( - identity_providers.list, - ) - self.delete = async_to_raw_response_wrapper( - identity_providers.delete, - ) - self.get = async_to_raw_response_wrapper( - identity_providers.get, - ) - - -class IdentityProvidersResourceWithStreamingResponse: - def __init__(self, identity_providers: IdentityProvidersResource) -> None: - self._identity_providers = identity_providers - - self.create = to_streamed_response_wrapper( - identity_providers.create, - ) - self.update = to_streamed_response_wrapper( - identity_providers.update, - ) - self.list = to_streamed_response_wrapper( - identity_providers.list, - ) - self.delete = to_streamed_response_wrapper( - identity_providers.delete, - ) - self.get = to_streamed_response_wrapper( - identity_providers.get, - ) - - -class AsyncIdentityProvidersResourceWithStreamingResponse: - def __init__(self, identity_providers: AsyncIdentityProvidersResource) -> None: - self._identity_providers = identity_providers +class AsyncIdentityProvidersResourceWithStreamingResponse: + def __init__(self, identity_providers: AsyncIdentityProvidersResource) -> None: + self._identity_providers = identity_providers self.create = async_to_streamed_response_wrapper( identity_providers.create, ) - self.update = async_to_streamed_response_wrapper( - identity_providers.update, - ) self.list = async_to_streamed_response_wrapper( identity_providers.list, ) - self.delete = async_to_streamed_response_wrapper( - identity_providers.delete, - ) - self.get = async_to_streamed_response_wrapper( - identity_providers.get, - ) diff --git a/src/cloudflare/resources/zero_trust/seats.py b/src/cloudflare/resources/zero_trust/seats.py deleted file mode 100644 index c1368cd0512..00000000000 --- a/src/cloudflare/resources/zero_trust/seats.py +++ /dev/null @@ -1,169 +0,0 @@ -# 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 import seat_edit_params -from ...types.zero_trust.seat_edit_response import SeatEditResponse - -__all__ = ["SeatsResource", "AsyncSeatsResource"] - - -class SeatsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> SeatsResourceWithRawResponse: - return SeatsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> SeatsResourceWithStreamingResponse: - return SeatsResourceWithStreamingResponse(self) - - def edit( - self, - identifier: str, - *, - body: Iterable[seat_edit_params.Body], - # 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[SeatEditResponse]: - """ - Removes a user from a Zero Trust seat when both `access_seat` and `gateway_seat` - are set to false. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return self._patch( - f"/accounts/{identifier}/access/seats", - body=maybe_transform(body, seat_edit_params.SeatEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[SeatEditResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[SeatEditResponse]], ResultWrapper[SeatEditResponse]), - ) - - -class AsyncSeatsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncSeatsResourceWithRawResponse: - return AsyncSeatsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncSeatsResourceWithStreamingResponse: - return AsyncSeatsResourceWithStreamingResponse(self) - - async def edit( - self, - identifier: str, - *, - body: Iterable[seat_edit_params.Body], - # 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[SeatEditResponse]: - """ - Removes a user from a Zero Trust seat when both `access_seat` and `gateway_seat` - are set to false. - - Args: - identifier: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not identifier: - raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") - return await self._patch( - f"/accounts/{identifier}/access/seats", - body=await async_maybe_transform(body, seat_edit_params.SeatEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[SeatEditResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[SeatEditResponse]], ResultWrapper[SeatEditResponse]), - ) - - -class SeatsResourceWithRawResponse: - def __init__(self, seats: SeatsResource) -> None: - self._seats = seats - - self.edit = to_raw_response_wrapper( - seats.edit, - ) - - -class AsyncSeatsResourceWithRawResponse: - def __init__(self, seats: AsyncSeatsResource) -> None: - self._seats = seats - - self.edit = async_to_raw_response_wrapper( - seats.edit, - ) - - -class SeatsResourceWithStreamingResponse: - def __init__(self, seats: SeatsResource) -> None: - self._seats = seats - - self.edit = to_streamed_response_wrapper( - seats.edit, - ) - - -class AsyncSeatsResourceWithStreamingResponse: - def __init__(self, seats: AsyncSeatsResource) -> None: - self._seats = seats - - self.edit = async_to_streamed_response_wrapper( - seats.edit, - ) diff --git a/src/cloudflare/resources/zero_trust/zero_trust.py b/src/cloudflare/resources/zero_trust/zero_trust.py index 63aefc65ac1..880f0f44ea4 100644 --- a/src/cloudflare/resources/zero_trust/zero_trust.py +++ b/src/cloudflare/resources/zero_trust/zero_trust.py @@ -18,14 +18,6 @@ DLPResourceWithStreamingResponse, AsyncDLPResourceWithStreamingResponse, ) -from .seats import ( - SeatsResource, - AsyncSeatsResource, - SeatsResourceWithRawResponse, - AsyncSeatsResourceWithRawResponse, - SeatsResourceWithStreamingResponse, - AsyncSeatsResourceWithStreamingResponse, -) from .access import ( AccessResource, AsyncAccessResource, @@ -125,10 +117,6 @@ def identity_providers(self) -> IdentityProvidersResource: def organizations(self) -> OrganizationsResource: return OrganizationsResource(self._client) - @cached_property - def seats(self) -> SeatsResource: - return SeatsResource(self._client) - @cached_property def access(self) -> AccessResource: return AccessResource(self._client) @@ -183,10 +171,6 @@ def identity_providers(self) -> AsyncIdentityProvidersResource: def organizations(self) -> AsyncOrganizationsResource: return AsyncOrganizationsResource(self._client) - @cached_property - def seats(self) -> AsyncSeatsResource: - return AsyncSeatsResource(self._client) - @cached_property def access(self) -> AsyncAccessResource: return AsyncAccessResource(self._client) @@ -244,10 +228,6 @@ def identity_providers(self) -> IdentityProvidersResourceWithRawResponse: def organizations(self) -> OrganizationsResourceWithRawResponse: return OrganizationsResourceWithRawResponse(self._zero_trust.organizations) - @cached_property - def seats(self) -> SeatsResourceWithRawResponse: - return SeatsResourceWithRawResponse(self._zero_trust.seats) - @cached_property def access(self) -> AccessResourceWithRawResponse: return AccessResourceWithRawResponse(self._zero_trust.access) @@ -297,10 +277,6 @@ def identity_providers(self) -> AsyncIdentityProvidersResourceWithRawResponse: def organizations(self) -> AsyncOrganizationsResourceWithRawResponse: return AsyncOrganizationsResourceWithRawResponse(self._zero_trust.organizations) - @cached_property - def seats(self) -> AsyncSeatsResourceWithRawResponse: - return AsyncSeatsResourceWithRawResponse(self._zero_trust.seats) - @cached_property def access(self) -> AsyncAccessResourceWithRawResponse: return AsyncAccessResourceWithRawResponse(self._zero_trust.access) @@ -350,10 +326,6 @@ def identity_providers(self) -> IdentityProvidersResourceWithStreamingResponse: def organizations(self) -> OrganizationsResourceWithStreamingResponse: return OrganizationsResourceWithStreamingResponse(self._zero_trust.organizations) - @cached_property - def seats(self) -> SeatsResourceWithStreamingResponse: - return SeatsResourceWithStreamingResponse(self._zero_trust.seats) - @cached_property def access(self) -> AccessResourceWithStreamingResponse: return AccessResourceWithStreamingResponse(self._zero_trust.access) @@ -403,10 +375,6 @@ def identity_providers(self) -> AsyncIdentityProvidersResourceWithStreamingRespo def organizations(self) -> AsyncOrganizationsResourceWithStreamingResponse: return AsyncOrganizationsResourceWithStreamingResponse(self._zero_trust.organizations) - @cached_property - def seats(self) -> AsyncSeatsResourceWithStreamingResponse: - return AsyncSeatsResourceWithStreamingResponse(self._zero_trust.seats) - @cached_property def access(self) -> AsyncAccessResourceWithStreamingResponse: return AsyncAccessResourceWithStreamingResponse(self._zero_trust.access) diff --git a/src/cloudflare/types/api_gateway/__init__.py b/src/cloudflare/types/api_gateway/__init__.py index 9b7ba5574de..15e921a339f 100644 --- a/src/cloudflare/types/api_gateway/__init__.py +++ b/src/cloudflare/types/api_gateway/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations -from .schema import Schema as Schema from .message import Message as Message from .api_shield import APIShield as APIShield from .configuration import Configuration as Configuration diff --git a/src/cloudflare/types/api_gateway/schema.py b/src/cloudflare/types/api_gateway/schema.py deleted file mode 100644 index 5b44bcf0853..00000000000 --- a/src/cloudflare/types/api_gateway/schema.py +++ /dev/null @@ -1,19 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -from .message import Message -from ..._models import BaseModel - -__all__ = ["Schema"] - - -class Schema(BaseModel): - errors: Message - - messages: Message - - result: Union[Optional[str], Optional[object]] - - success: bool - """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index d88c9679596..476a9254497 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index 27f4398d8c9..d1e457901af 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -32,8 +32,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -112,58 +110,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -181,6 +127,4 @@ class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index 3e00524ec11..a92b28cb216 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index 3c7d7b05653..bf04a129360 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index f027d1e1dc5..e08bad9f0e5 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -76,8 +76,6 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", - "RulesetsDDoSDynamicRule", - "RulesetsForceConnectionCloseRule", ] @@ -1207,70 +1205,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" -class RulesetsDDoSDynamicRule(TypedDict, total=False): - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RulesetsForceConnectionCloseRule(TypedDict, total=False): - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - RuleCreateParams = Union[ BlockRule, ChallengeRule, @@ -1288,6 +1222,4 @@ class RulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, - RulesetsDDoSDynamicRule, - RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 04e3457f902..9a729d3fbe1 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 25d801cd5aa..1b6810d585e 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index 8382c7d8687..86c8418e7c8 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -76,8 +76,6 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", - "RulesetsDDoSDynamicRule", - "RulesetsForceConnectionCloseRule", ] @@ -1255,76 +1253,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" -class RulesetsDDoSDynamicRule(TypedDict, total=False): - ruleset_id: Required[str] - """The unique ID of the ruleset.""" - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RulesetsForceConnectionCloseRule(TypedDict, total=False): - ruleset_id: Required[str] - """The unique ID of the ruleset.""" - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - RuleEditParams = Union[ BlockRule, ChallengeRule, @@ -1342,6 +1270,4 @@ class RulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, - RulesetsDDoSDynamicRule, - RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 47dd4534324..3bf0100ef6f 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py index 4e372271bef..6d34a46fac5 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_params.py +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -32,8 +32,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -112,58 +110,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -181,6 +127,4 @@ class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index bfeacd5afd4..f87b58ceec8 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index 328ba42b25a..d5864df9b91 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py index e2ff9a9fcb8..ce723859ed9 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_params.py +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -32,8 +32,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -112,58 +110,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["ddos_dynamic"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["force_connection_close"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: LoggingParam - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -181,6 +127,4 @@ class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index 9fb84d0d26a..d2aaaa91d6f 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index abb1cfae6c7..4d61f17e3ec 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index 058c549bc29..62def70b1fd 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -33,8 +33,6 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", - "RuleRulesetsDDoSDynamicRule", - "RuleRulesetsForceConnectionCloseRule", ] @@ -99,76 +97,6 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" -class RuleRulesetsDDoSDynamicRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["ddos_dynamic"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsForceConnectionCloseRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["force_connection_close"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[Logging] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - Rule = Annotated[ Union[ BlockRule, @@ -187,8 +115,6 @@ class RuleRulesetsForceConnectionCloseRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, - RuleRulesetsDDoSDynamicRule, - RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/zero_trust/__init__.py b/src/cloudflare/types/zero_trust/__init__.py index fe2de93ed13..2cd39fd22ee 100644 --- a/src/cloudflare/types/zero_trust/__init__.py +++ b/src/cloudflare/types/zero_trust/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations -from .seat import Seat as Seat from .device import Device as Device from .ip_rule import IPRule as IPRule from .azure_ad import AzureAD as AzureAD @@ -27,7 +26,6 @@ from .certificate_rule import CertificateRule as CertificateRule from .email_rule_param import EmailRuleParam as EmailRuleParam from .group_rule_param import GroupRuleParam as GroupRuleParam -from .seat_edit_params import SeatEditParams as SeatEditParams from .access_rule_param import AccessRuleParam as AccessRuleParam from .domain_rule_param import DomainRuleParam as DomainRuleParam from .gsuite_group_rule import GSuiteGroupRule as GSuiteGroupRule @@ -36,7 +34,6 @@ from .country_rule_param import CountryRuleParam as CountryRuleParam from .ip_list_rule_param import IPListRuleParam as IPListRuleParam from .login_design_param import LoginDesignParam as LoginDesignParam -from .seat_edit_response import SeatEditResponse as SeatEditResponse from .service_token_rule import ServiceTokenRule as ServiceTokenRule from .tunnel_edit_params import TunnelEditParams as TunnelEditParams from .tunnel_list_params import TunnelListParams as TunnelListParams @@ -76,13 +73,11 @@ from .github_organization_rule_param import GitHubOrganizationRuleParam as GitHubOrganizationRuleParam from .identity_provider_create_params import IdentityProviderCreateParams as IdentityProviderCreateParams from .identity_provider_list_response import IdentityProviderListResponse as IdentityProviderListResponse -from .identity_provider_update_params import IdentityProviderUpdateParams as IdentityProviderUpdateParams from .access_device_posture_rule_param import AccessDevicePostureRuleParam as AccessDevicePostureRuleParam from .authentication_method_rule_param import AuthenticationMethodRuleParam as AuthenticationMethodRuleParam from .connectivity_setting_edit_params import ConnectivitySettingEditParams as ConnectivitySettingEditParams from .organization_revoke_users_params import OrganizationRevokeUsersParams as OrganizationRevokeUsersParams from .connectivity_setting_get_response import ConnectivitySettingGetResponse as ConnectivitySettingGetResponse -from .identity_provider_delete_response import IdentityProviderDeleteResponse as IdentityProviderDeleteResponse from .any_valid_service_token_rule_param import AnyValidServiceTokenRuleParam as AnyValidServiceTokenRuleParam from .connectivity_setting_edit_response import ConnectivitySettingEditResponse as ConnectivitySettingEditResponse from .organization_revoke_users_response import OrganizationRevokeUsersResponse as OrganizationRevokeUsersResponse diff --git a/src/cloudflare/types/zero_trust/access/__init__.py b/src/cloudflare/types/zero_trust/access/__init__.py index 8b8d5c829cf..2645e488cfc 100644 --- a/src/cloudflare/types/zero_trust/access/__init__.py +++ b/src/cloudflare/types/zero_trust/access/__init__.py @@ -2,12 +2,8 @@ from __future__ import annotations -from .tag import Tag as Tag -from .bookmark import Bookmark as Bookmark from .decision import Decision as Decision -from .access_user import AccessUser as AccessUser from .certificate import Certificate as Certificate -from .custom_page import CustomPage as CustomPage from .allowed_idps import AllowedIdPs as AllowedIdPs from .app_id_param import AppIDParam as AppIDParam from .cors_headers import CORSHeaders as CORSHeaders @@ -18,42 +14,22 @@ from .allowed_origins import AllowedOrigins as AllowedOrigins from .saas_app_source import SaaSAppSource as SaaSAppSource from .application_type import ApplicationType as ApplicationType -from .key_get_response import KeyGetResponse as KeyGetResponse from .zero_trust_group import ZeroTrustGroup as ZeroTrustGroup -from .key_update_params import KeyUpdateParams as KeyUpdateParams -from .tag_create_params import TagCreateParams as TagCreateParams -from .tag_update_params import TagUpdateParams as TagUpdateParams from .cors_headers_param import CORSHeadersParam as CORSHeadersParam from .group_create_params import GroupCreateParams as GroupCreateParams -from .group_update_params import GroupUpdateParams as GroupUpdateParams -from .key_rotate_response import KeyRotateResponse as KeyRotateResponse -from .key_update_response import KeyUpdateResponse as KeyUpdateResponse from .saml_saas_app_param import SAMLSaaSAppParam as SAMLSaaSAppParam from .self_hosted_domains import SelfHostedDomains as SelfHostedDomains -from .tag_delete_response import TagDeleteResponse as TagDeleteResponse from .associated_hostnames import AssociatedHostnames as AssociatedHostnames from .saas_app_name_format import SaaSAppNameFormat as SaaSAppNameFormat -from .group_delete_response import GroupDeleteResponse as GroupDeleteResponse from .saas_app_source_param import SaaSAppSourceParam as SaaSAppSourceParam -from .bookmark_create_params import BookmarkCreateParams as BookmarkCreateParams -from .bookmark_update_params import BookmarkUpdateParams as BookmarkUpdateParams from .saas_app_name_id_format import SaaSAppNameIDFormat as SaaSAppNameIDFormat from .application_get_response import ApplicationGetResponse as ApplicationGetResponse -from .bookmark_delete_response import BookmarkDeleteResponse as BookmarkDeleteResponse -from .custom_page_without_html import CustomPageWithoutHTML as CustomPageWithoutHTML from .application_create_params import ApplicationCreateParams as ApplicationCreateParams from .application_list_response import ApplicationListResponse as ApplicationListResponse from .application_update_params import ApplicationUpdateParams as ApplicationUpdateParams from .certificate_create_params import CertificateCreateParams as CertificateCreateParams -from .certificate_update_params import CertificateUpdateParams as CertificateUpdateParams -from .custom_page_create_params import CustomPageCreateParams as CustomPageCreateParams -from .custom_page_update_params import CustomPageUpdateParams as CustomPageUpdateParams from .application_create_response import ApplicationCreateResponse as ApplicationCreateResponse from .application_delete_response import ApplicationDeleteResponse as ApplicationDeleteResponse from .application_update_response import ApplicationUpdateResponse as ApplicationUpdateResponse -from .certificate_delete_response import CertificateDeleteResponse as CertificateDeleteResponse -from .custom_page_delete_response import CustomPageDeleteResponse as CustomPageDeleteResponse from .service_token_create_params import ServiceTokenCreateParams as ServiceTokenCreateParams -from .service_token_update_params import ServiceTokenUpdateParams as ServiceTokenUpdateParams from .service_token_create_response import ServiceTokenCreateResponse as ServiceTokenCreateResponse -from .service_token_rotate_response import ServiceTokenRotateResponse as ServiceTokenRotateResponse diff --git a/src/cloudflare/types/zero_trust/access/access_user.py b/src/cloudflare/types/zero_trust/access/access_user.py deleted file mode 100644 index 2430d721cf2..00000000000 --- a/src/cloudflare/types/zero_trust/access/access_user.py +++ /dev/null @@ -1,41 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime - -from ...._models import BaseModel - -__all__ = ["AccessUser"] - - -class AccessUser(BaseModel): - id: Optional[str] = None - """UUID""" - - access_seat: Optional[bool] = None - """True if the user has authenticated with Cloudflare Access.""" - - active_device_count: Optional[float] = None - """The number of active devices registered to the user.""" - - created_at: Optional[datetime] = None - - email: Optional[str] = None - """The email of the user.""" - - gateway_seat: Optional[bool] = None - """True if the user has logged into the WARP client.""" - - last_successful_login: Optional[datetime] = None - """The time at which the user last successfully logged in.""" - - name: Optional[str] = None - """The name of the user.""" - - seat_uid: Optional[str] = None - """The unique API identifier for the Zero Trust seat.""" - - uid: Optional[str] = None - """The unique API identifier for the user.""" - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/__init__.py b/src/cloudflare/types/zero_trust/access/applications/__init__.py index 206ec39071b..f34cf3dac26 100644 --- a/src/cloudflare/types/zero_trust/access/applications/__init__.py +++ b/src/cloudflare/types/zero_trust/access/applications/__init__.py @@ -4,16 +4,6 @@ from .ca import CA as CA from .approval_group import ApprovalGroup as ApprovalGroup -from .ca_get_response import CAGetResponse as CAGetResponse -from .ca_create_response import CACreateResponse as CACreateResponse -from .ca_delete_response import CADeleteResponse as CADeleteResponse -from .policy_get_response import PolicyGetResponse as PolicyGetResponse from .approval_group_param import ApprovalGroupParam as ApprovalGroupParam -from .policy_create_params import PolicyCreateParams as PolicyCreateParams -from .policy_list_response import PolicyListResponse as PolicyListResponse -from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams from .user_policy_check_geo import UserPolicyCheckGeo as UserPolicyCheckGeo -from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse -from .policy_delete_response import PolicyDeleteResponse as PolicyDeleteResponse -from .policy_update_response import PolicyUpdateResponse as PolicyUpdateResponse from .user_policy_check_list_response import UserPolicyCheckListResponse as UserPolicyCheckListResponse diff --git a/src/cloudflare/types/zero_trust/access/applications/ca_create_response.py b/src/cloudflare/types/zero_trust/access/applications/ca_create_response.py deleted file mode 100644 index c0a4d7af889..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/ca_create_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["CACreateResponse"] - -CACreateResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/zero_trust/access/applications/ca_delete_response.py b/src/cloudflare/types/zero_trust/access/applications/ca_delete_response.py deleted file mode 100644 index 1067f82cd87..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/ca_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ....._models import BaseModel - -__all__ = ["CADeleteResponse"] - - -class CADeleteResponse(BaseModel): - id: Optional[str] = None - """The ID of the CA.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/ca_get_response.py b/src/cloudflare/types/zero_trust/access/applications/ca_get_response.py deleted file mode 100644 index 8a2b05ffa92..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/ca_get_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["CAGetResponse"] - -CAGetResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py deleted file mode 100644 index 358425ac3f4..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py +++ /dev/null @@ -1,79 +0,0 @@ -# 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 ..decision import Decision -from ...access_rule_param import AccessRuleParam -from .approval_group_param import ApprovalGroupParam - -__all__ = ["PolicyCreateParams"] - - -class PolicyCreateParams(TypedDict, total=False): - decision: Required[Decision] - """The action Access will take if a user matches this policy.""" - - include: Required[Iterable[AccessRuleParam]] - """Rules evaluated with an OR logical operator. - - A user needs to meet only one of the Include rules. - """ - - name: Required[str] - """The name of the Access policy.""" - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - approval_groups: Iterable[ApprovalGroupParam] - """Administrators who can approve a temporary authentication request.""" - - approval_required: bool - """ - Requires the user to request access from an administrator at the start of each - session. - """ - - exclude: Iterable[AccessRuleParam] - """Rules evaluated with a NOT logical operator. - - To match the policy, a user cannot meet any of the Exclude rules. - """ - - isolation_required: bool - """ - Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - """ - - precedence: int - """The order of execution for this policy. - - Must be unique for each policy within an app. - """ - - purpose_justification_prompt: str - """A custom message that will appear on the purpose justification screen.""" - - purpose_justification_required: bool - """Require users to enter a justification when they log in to the application.""" - - require: Iterable[AccessRuleParam] - """Rules evaluated with an AND logical operator. - - To match the policy, a user must meet all of the Require rules. - """ - - session_duration: str - """The amount of time that tokens issued for the application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py deleted file mode 100644 index 4b8e4a6d329..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py +++ /dev/null @@ -1,73 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime - -from ..decision import Decision -from ....._models import BaseModel -from ...access_rule import AccessRule -from .approval_group import ApprovalGroup - -__all__ = ["PolicyCreateResponse"] - - -class PolicyCreateResponse(BaseModel): - id: Optional[str] = None - """UUID""" - - approval_groups: Optional[List[ApprovalGroup]] = None - """Administrators who can approve a temporary authentication request.""" - - approval_required: Optional[bool] = None - """ - Requires the user to request access from an administrator at the start of each - session. - """ - - created_at: Optional[datetime] = None - - decision: Optional[Decision] = None - """The action Access will take if a user matches this policy.""" - - exclude: Optional[List[AccessRule]] = None - """Rules evaluated with a NOT logical operator. - - To match the policy, a user cannot meet any of the Exclude rules. - """ - - include: Optional[List[AccessRule]] = None - """Rules evaluated with an OR logical operator. - - A user needs to meet only one of the Include rules. - """ - - isolation_required: Optional[bool] = None - """ - Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - """ - - name: Optional[str] = None - """The name of the Access policy.""" - - purpose_justification_prompt: Optional[str] = None - """A custom message that will appear on the purpose justification screen.""" - - purpose_justification_required: Optional[bool] = None - """Require users to enter a justification when they log in to the application.""" - - require: Optional[List[AccessRule]] = None - """Rules evaluated with an AND logical operator. - - To match the policy, a user must meet all of the Require rules. - """ - - session_duration: Optional[str] = None - """The amount of time that tokens issued for the application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_delete_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_delete_response.py deleted file mode 100644 index 1d70dce656a..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/policy_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ....._models import BaseModel - -__all__ = ["PolicyDeleteResponse"] - - -class PolicyDeleteResponse(BaseModel): - id: Optional[str] = None - """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py deleted file mode 100644 index 8f6eac8cf3f..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py +++ /dev/null @@ -1,73 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime - -from ..decision import Decision -from ....._models import BaseModel -from ...access_rule import AccessRule -from .approval_group import ApprovalGroup - -__all__ = ["PolicyGetResponse"] - - -class PolicyGetResponse(BaseModel): - id: Optional[str] = None - """UUID""" - - approval_groups: Optional[List[ApprovalGroup]] = None - """Administrators who can approve a temporary authentication request.""" - - approval_required: Optional[bool] = None - """ - Requires the user to request access from an administrator at the start of each - session. - """ - - created_at: Optional[datetime] = None - - decision: Optional[Decision] = None - """The action Access will take if a user matches this policy.""" - - exclude: Optional[List[AccessRule]] = None - """Rules evaluated with a NOT logical operator. - - To match the policy, a user cannot meet any of the Exclude rules. - """ - - include: Optional[List[AccessRule]] = None - """Rules evaluated with an OR logical operator. - - A user needs to meet only one of the Include rules. - """ - - isolation_required: Optional[bool] = None - """ - Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - """ - - name: Optional[str] = None - """The name of the Access policy.""" - - purpose_justification_prompt: Optional[str] = None - """A custom message that will appear on the purpose justification screen.""" - - purpose_justification_required: Optional[bool] = None - """Require users to enter a justification when they log in to the application.""" - - require: Optional[List[AccessRule]] = None - """Rules evaluated with an AND logical operator. - - To match the policy, a user must meet all of the Require rules. - """ - - session_duration: Optional[str] = None - """The amount of time that tokens issued for the application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py deleted file mode 100644 index 176b10bf16d..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py +++ /dev/null @@ -1,73 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime - -from ..decision import Decision -from ....._models import BaseModel -from ...access_rule import AccessRule -from .approval_group import ApprovalGroup - -__all__ = ["PolicyListResponse"] - - -class PolicyListResponse(BaseModel): - id: Optional[str] = None - """UUID""" - - approval_groups: Optional[List[ApprovalGroup]] = None - """Administrators who can approve a temporary authentication request.""" - - approval_required: Optional[bool] = None - """ - Requires the user to request access from an administrator at the start of each - session. - """ - - created_at: Optional[datetime] = None - - decision: Optional[Decision] = None - """The action Access will take if a user matches this policy.""" - - exclude: Optional[List[AccessRule]] = None - """Rules evaluated with a NOT logical operator. - - To match the policy, a user cannot meet any of the Exclude rules. - """ - - include: Optional[List[AccessRule]] = None - """Rules evaluated with an OR logical operator. - - A user needs to meet only one of the Include rules. - """ - - isolation_required: Optional[bool] = None - """ - Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - """ - - name: Optional[str] = None - """The name of the Access policy.""" - - purpose_justification_prompt: Optional[str] = None - """A custom message that will appear on the purpose justification screen.""" - - purpose_justification_required: Optional[bool] = None - """Require users to enter a justification when they log in to the application.""" - - require: Optional[List[AccessRule]] = None - """Rules evaluated with an AND logical operator. - - To match the policy, a user must meet all of the Require rules. - """ - - session_duration: Optional[str] = None - """The amount of time that tokens issued for the application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py deleted file mode 100644 index eab91a04759..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py +++ /dev/null @@ -1,82 +0,0 @@ -# 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 ..decision import Decision -from ...access_rule_param import AccessRuleParam -from .approval_group_param import ApprovalGroupParam - -__all__ = ["PolicyUpdateParams"] - - -class PolicyUpdateParams(TypedDict, total=False): - uuid1: Required[str] - """UUID""" - - decision: Required[Decision] - """The action Access will take if a user matches this policy.""" - - include: Required[Iterable[AccessRuleParam]] - """Rules evaluated with an OR logical operator. - - A user needs to meet only one of the Include rules. - """ - - name: Required[str] - """The name of the Access policy.""" - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - approval_groups: Iterable[ApprovalGroupParam] - """Administrators who can approve a temporary authentication request.""" - - approval_required: bool - """ - Requires the user to request access from an administrator at the start of each - session. - """ - - exclude: Iterable[AccessRuleParam] - """Rules evaluated with a NOT logical operator. - - To match the policy, a user cannot meet any of the Exclude rules. - """ - - isolation_required: bool - """ - Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - """ - - precedence: int - """The order of execution for this policy. - - Must be unique for each policy within an app. - """ - - purpose_justification_prompt: str - """A custom message that will appear on the purpose justification screen.""" - - purpose_justification_required: bool - """Require users to enter a justification when they log in to the application.""" - - require: Iterable[AccessRuleParam] - """Rules evaluated with an AND logical operator. - - To match the policy, a user must meet all of the Require rules. - """ - - session_duration: str - """The amount of time that tokens issued for the application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py deleted file mode 100644 index b5c91e2230c..00000000000 --- a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py +++ /dev/null @@ -1,73 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime - -from ..decision import Decision -from ....._models import BaseModel -from ...access_rule import AccessRule -from .approval_group import ApprovalGroup - -__all__ = ["PolicyUpdateResponse"] - - -class PolicyUpdateResponse(BaseModel): - id: Optional[str] = None - """UUID""" - - approval_groups: Optional[List[ApprovalGroup]] = None - """Administrators who can approve a temporary authentication request.""" - - approval_required: Optional[bool] = None - """ - Requires the user to request access from an administrator at the start of each - session. - """ - - created_at: Optional[datetime] = None - - decision: Optional[Decision] = None - """The action Access will take if a user matches this policy.""" - - exclude: Optional[List[AccessRule]] = None - """Rules evaluated with a NOT logical operator. - - To match the policy, a user cannot meet any of the Exclude rules. - """ - - include: Optional[List[AccessRule]] = None - """Rules evaluated with an OR logical operator. - - A user needs to meet only one of the Include rules. - """ - - isolation_required: Optional[bool] = None - """ - Require this application to be served in an isolated browser for users matching - this policy. 'Client Web Isolation' must be on for the account in order to use - this feature. - """ - - name: Optional[str] = None - """The name of the Access policy.""" - - purpose_justification_prompt: Optional[str] = None - """A custom message that will appear on the purpose justification screen.""" - - purpose_justification_required: Optional[bool] = None - """Require users to enter a justification when they log in to the application.""" - - require: Optional[List[AccessRule]] = None - """Rules evaluated with an AND logical operator. - - To match the policy, a user must meet all of the Require rules. - """ - - session_duration: Optional[str] = None - """The amount of time that tokens issued for the application will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. - """ - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/bookmark.py b/src/cloudflare/types/zero_trust/access/bookmark.py deleted file mode 100644 index 5d20f8b964c..00000000000 --- a/src/cloudflare/types/zero_trust/access/bookmark.py +++ /dev/null @@ -1,29 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime - -from ...._models import BaseModel - -__all__ = ["Bookmark"] - - -class Bookmark(BaseModel): - id: Optional[str] = None - """The unique identifier for the Bookmark application.""" - - app_launcher_visible: Optional[bool] = None - """Displays the application in the App Launcher.""" - - created_at: Optional[datetime] = None - - domain: Optional[str] = None - """The domain of the Bookmark application.""" - - logo_url: Optional[str] = None - """The image URL for the logo shown in the App Launcher dashboard.""" - - name: Optional[str] = None - """The name of the Bookmark application.""" - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/bookmark_create_params.py b/src/cloudflare/types/zero_trust/access/bookmark_create_params.py deleted file mode 100644 index 4680f846d12..00000000000 --- a/src/cloudflare/types/zero_trust/access/bookmark_create_params.py +++ /dev/null @@ -1,13 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["BookmarkCreateParams"] - - -class BookmarkCreateParams(TypedDict, total=False): - identifier: Required[str] - - body: Required[object] diff --git a/src/cloudflare/types/zero_trust/access/bookmark_delete_response.py b/src/cloudflare/types/zero_trust/access/bookmark_delete_response.py deleted file mode 100644 index 93d03aba051..00000000000 --- a/src/cloudflare/types/zero_trust/access/bookmark_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["BookmarkDeleteResponse"] - - -class BookmarkDeleteResponse(BaseModel): - id: Optional[str] = None - """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/bookmark_update_params.py b/src/cloudflare/types/zero_trust/access/bookmark_update_params.py deleted file mode 100644 index 58286a723f3..00000000000 --- a/src/cloudflare/types/zero_trust/access/bookmark_update_params.py +++ /dev/null @@ -1,13 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["BookmarkUpdateParams"] - - -class BookmarkUpdateParams(TypedDict, total=False): - identifier: Required[str] - - body: Required[object] diff --git a/src/cloudflare/types/zero_trust/access/certificate_delete_response.py b/src/cloudflare/types/zero_trust/access/certificate_delete_response.py deleted file mode 100644 index 01177266648..00000000000 --- a/src/cloudflare/types/zero_trust/access/certificate_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["CertificateDeleteResponse"] - - -class CertificateDeleteResponse(BaseModel): - id: Optional[str] = None - """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/certificate_update_params.py b/src/cloudflare/types/zero_trust/access/certificate_update_params.py deleted file mode 100644 index e546c333f21..00000000000 --- a/src/cloudflare/types/zero_trust/access/certificate_update_params.py +++ /dev/null @@ -1,24 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List -from typing_extensions import Required, TypedDict - -from .associated_hostnames import AssociatedHostnames - -__all__ = ["CertificateUpdateParams"] - - -class CertificateUpdateParams(TypedDict, total=False): - associated_hostnames: Required[List[AssociatedHostnames]] - """The hostnames of the applications that will use this certificate.""" - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - name: str - """The name of the certificate.""" diff --git a/src/cloudflare/types/zero_trust/access/custom_page.py b/src/cloudflare/types/zero_trust/access/custom_page.py deleted file mode 100644 index 4593071d37a..00000000000 --- a/src/cloudflare/types/zero_trust/access/custom_page.py +++ /dev/null @@ -1,30 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["CustomPage"] - - -class CustomPage(BaseModel): - custom_html: str - """Custom page HTML.""" - - name: str - """Custom page name.""" - - type: Literal["identity_denied", "forbidden"] - """Custom page type.""" - - app_count: Optional[int] = None - """Number of apps the custom page is assigned to.""" - - created_at: Optional[datetime] = None - - uid: Optional[str] = None - """UUID""" - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/custom_page_create_params.py b/src/cloudflare/types/zero_trust/access/custom_page_create_params.py deleted file mode 100644 index f1890d141b8..00000000000 --- a/src/cloudflare/types/zero_trust/access/custom_page_create_params.py +++ /dev/null @@ -1,21 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["CustomPageCreateParams"] - - -class CustomPageCreateParams(TypedDict, total=False): - custom_html: Required[str] - """Custom page HTML.""" - - name: Required[str] - """Custom page name.""" - - type: Required[Literal["identity_denied", "forbidden"]] - """Custom page type.""" - - app_count: int - """Number of apps the custom page is assigned to.""" diff --git a/src/cloudflare/types/zero_trust/access/custom_page_delete_response.py b/src/cloudflare/types/zero_trust/access/custom_page_delete_response.py deleted file mode 100644 index bb6e38bee3b..00000000000 --- a/src/cloudflare/types/zero_trust/access/custom_page_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["CustomPageDeleteResponse"] - - -class CustomPageDeleteResponse(BaseModel): - id: Optional[str] = None - """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/custom_page_update_params.py b/src/cloudflare/types/zero_trust/access/custom_page_update_params.py deleted file mode 100644 index 71c52739e3f..00000000000 --- a/src/cloudflare/types/zero_trust/access/custom_page_update_params.py +++ /dev/null @@ -1,24 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["CustomPageUpdateParams"] - - -class CustomPageUpdateParams(TypedDict, total=False): - identifier: Required[str] - """Identifier""" - - custom_html: Required[str] - """Custom page HTML.""" - - name: Required[str] - """Custom page name.""" - - type: Required[Literal["identity_denied", "forbidden"]] - """Custom page type.""" - - app_count: int - """Number of apps the custom page is assigned to.""" diff --git a/src/cloudflare/types/zero_trust/access/custom_page_without_html.py b/src/cloudflare/types/zero_trust/access/custom_page_without_html.py deleted file mode 100644 index d0aecfa61f5..00000000000 --- a/src/cloudflare/types/zero_trust/access/custom_page_without_html.py +++ /dev/null @@ -1,27 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["CustomPageWithoutHTML"] - - -class CustomPageWithoutHTML(BaseModel): - name: str - """Custom page name.""" - - type: Literal["identity_denied", "forbidden"] - """Custom page type.""" - - app_count: Optional[int] = None - """Number of apps the custom page is assigned to.""" - - created_at: Optional[datetime] = None - - uid: Optional[str] = None - """UUID""" - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/group_delete_response.py b/src/cloudflare/types/zero_trust/access/group_delete_response.py deleted file mode 100644 index 4f17b96b793..00000000000 --- a/src/cloudflare/types/zero_trust/access/group_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["GroupDeleteResponse"] - - -class GroupDeleteResponse(BaseModel): - id: Optional[str] = None - """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/group_update_params.py b/src/cloudflare/types/zero_trust/access/group_update_params.py deleted file mode 100644 index 68672edb40e..00000000000 --- a/src/cloudflare/types/zero_trust/access/group_update_params.py +++ /dev/null @@ -1,42 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Iterable -from typing_extensions import Required, TypedDict - -from ..access_rule_param import AccessRuleParam - -__all__ = ["GroupUpdateParams"] - - -class GroupUpdateParams(TypedDict, total=False): - include: Required[Iterable[AccessRuleParam]] - """Rules evaluated with an OR logical operator. - - A user needs to meet only one of the Include rules. - """ - - name: Required[str] - """The name of the Access group.""" - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - exclude: Iterable[AccessRuleParam] - """Rules evaluated with a NOT logical operator. - - To match a policy, a user cannot meet any of the Exclude rules. - """ - - is_default: bool - """Whether this is the default group""" - - require: Iterable[AccessRuleParam] - """Rules evaluated with an AND logical operator. - - To match a policy, a user must meet all of the Require rules. - """ diff --git a/src/cloudflare/types/zero_trust/access/key_get_response.py b/src/cloudflare/types/zero_trust/access/key_get_response.py deleted file mode 100644 index 79cfd988d58..00000000000 --- a/src/cloudflare/types/zero_trust/access/key_get_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union - -__all__ = ["KeyGetResponse"] - -KeyGetResponse = Union[str, object] diff --git a/src/cloudflare/types/zero_trust/access/key_rotate_response.py b/src/cloudflare/types/zero_trust/access/key_rotate_response.py deleted file mode 100644 index 1ababd82b3c..00000000000 --- a/src/cloudflare/types/zero_trust/access/key_rotate_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union - -__all__ = ["KeyRotateResponse"] - -KeyRotateResponse = Union[str, object] diff --git a/src/cloudflare/types/zero_trust/access/key_update_params.py b/src/cloudflare/types/zero_trust/access/key_update_params.py deleted file mode 100644 index 2c0f1d6ec45..00000000000 --- a/src/cloudflare/types/zero_trust/access/key_update_params.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["KeyUpdateParams"] - - -class KeyUpdateParams(TypedDict, total=False): - key_rotation_interval_days: Required[float] - """The number of days between key rotations.""" diff --git a/src/cloudflare/types/zero_trust/access/key_update_response.py b/src/cloudflare/types/zero_trust/access/key_update_response.py deleted file mode 100644 index a63396635f6..00000000000 --- a/src/cloudflare/types/zero_trust/access/key_update_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union - -__all__ = ["KeyUpdateResponse"] - -KeyUpdateResponse = Union[str, object] diff --git a/src/cloudflare/types/zero_trust/access/logs/__init__.py b/src/cloudflare/types/zero_trust/access/logs/__init__.py index 8044ec713b3..f8ee8b14b1c 100644 --- a/src/cloudflare/types/zero_trust/access/logs/__init__.py +++ b/src/cloudflare/types/zero_trust/access/logs/__init__.py @@ -1,6 +1,3 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations - -from .access_requests import AccessRequests as AccessRequests -from .access_request_list_response import AccessRequestListResponse as AccessRequestListResponse diff --git a/src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py b/src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py deleted file mode 100644 index b48a60046d9..00000000000 --- a/src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py +++ /dev/null @@ -1,9 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List - -from .access_requests import AccessRequests - -__all__ = ["AccessRequestListResponse"] - -AccessRequestListResponse = List[AccessRequests] diff --git a/src/cloudflare/types/zero_trust/access/service_token_rotate_response.py b/src/cloudflare/types/zero_trust/access/service_token_rotate_response.py deleted file mode 100644 index b4a74bcfc69..00000000000 --- a/src/cloudflare/types/zero_trust/access/service_token_rotate_response.py +++ /dev/null @@ -1,40 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime - -from ...._models import BaseModel - -__all__ = ["ServiceTokenRotateResponse"] - - -class ServiceTokenRotateResponse(BaseModel): - id: Optional[str] = None - """The ID of the service token.""" - - client_id: Optional[str] = None - """The Client ID for the service token. - - Access will check for this value in the `CF-Access-Client-ID` request header. - """ - - client_secret: Optional[str] = None - """The Client Secret for the service token. - - Access will check for this value in the `CF-Access-Client-Secret` request - header. - """ - - created_at: Optional[datetime] = None - - duration: Optional[str] = None - """The duration for how long the service token will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. The default is 1 year in hours (8760h). - """ - - name: Optional[str] = None - """The name of the service token.""" - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/service_token_update_params.py b/src/cloudflare/types/zero_trust/access/service_token_update_params.py deleted file mode 100644 index 93dc5d1c5bc..00000000000 --- a/src/cloudflare/types/zero_trust/access/service_token_update_params.py +++ /dev/null @@ -1,25 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -__all__ = ["ServiceTokenUpdateParams"] - - -class ServiceTokenUpdateParams(TypedDict, total=False): - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - duration: str - """The duration for how long the service token will be valid. - - Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), - ms, s, m, h. The default is 1 year in hours (8760h). - """ - - name: str - """The name of the service token.""" diff --git a/src/cloudflare/types/zero_trust/access/tag.py b/src/cloudflare/types/zero_trust/access/tag.py deleted file mode 100644 index bf386015544..00000000000 --- a/src/cloudflare/types/zero_trust/access/tag.py +++ /dev/null @@ -1,20 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime - -from ...._models import BaseModel - -__all__ = ["Tag"] - - -class Tag(BaseModel): - name: str - """The name of the tag""" - - app_count: Optional[int] = None - """The number of applications that have this tag""" - - created_at: Optional[datetime] = None - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/tag_create_params.py b/src/cloudflare/types/zero_trust/access/tag_create_params.py deleted file mode 100644 index d73f4a9177b..00000000000 --- a/src/cloudflare/types/zero_trust/access/tag_create_params.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["TagCreateParams"] - - -class TagCreateParams(TypedDict, total=False): - name: Required[str] - """The name of the tag""" diff --git a/src/cloudflare/types/zero_trust/access/tag_delete_response.py b/src/cloudflare/types/zero_trust/access/tag_delete_response.py deleted file mode 100644 index 8ffb88e56bf..00000000000 --- a/src/cloudflare/types/zero_trust/access/tag_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["TagDeleteResponse"] - - -class TagDeleteResponse(BaseModel): - name: Optional[str] = None - """The name of the tag""" diff --git a/src/cloudflare/types/zero_trust/access/tag_update_params.py b/src/cloudflare/types/zero_trust/access/tag_update_params.py deleted file mode 100644 index 8c7cbb096cb..00000000000 --- a/src/cloudflare/types/zero_trust/access/tag_update_params.py +++ /dev/null @@ -1,15 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["TagUpdateParams"] - - -class TagUpdateParams(TypedDict, total=False): - identifier: Required[str] - """Identifier""" - - name: Required[str] - """The name of the tag""" diff --git a/src/cloudflare/types/zero_trust/access/users/__init__.py b/src/cloudflare/types/zero_trust/access/users/__init__.py index 5f23decf1fe..f8ee8b14b1c 100644 --- a/src/cloudflare/types/zero_trust/access/users/__init__.py +++ b/src/cloudflare/types/zero_trust/access/users/__init__.py @@ -1,8 +1,3 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations - -from .identity import Identity as Identity -from .failed_login_list_response import FailedLoginListResponse as FailedLoginListResponse -from .active_session_get_response import ActiveSessionGetResponse as ActiveSessionGetResponse -from .active_session_list_response import ActiveSessionListResponse as ActiveSessionListResponse diff --git a/src/cloudflare/types/zero_trust/access/users/active_session_get_response.py b/src/cloudflare/types/zero_trust/access/users/active_session_get_response.py deleted file mode 100644 index 2414f09a55c..00000000000 --- a/src/cloudflare/types/zero_trust/access/users/active_session_get_response.py +++ /dev/null @@ -1,98 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, Optional - -from pydantic import Field as FieldInfo - -from ....._models import BaseModel -from ..applications.user_policy_check_geo import UserPolicyCheckGeo - -__all__ = ["ActiveSessionGetResponse", "DeviceSessions", "DevicePosture", "DevicePostureCheck", "IdP", "MTLSAuth"] - - -class DeviceSessions(BaseModel): - last_authenticated: Optional[float] = None - - -class DevicePostureCheck(BaseModel): - exists: Optional[bool] = None - - path: Optional[str] = None - - -class DevicePosture(BaseModel): - id: Optional[str] = None - - check: Optional[DevicePostureCheck] = None - - data: Optional[object] = None - - description: Optional[str] = None - - error: Optional[str] = None - - rule_name: Optional[str] = None - - success: Optional[bool] = None - - timestamp: Optional[str] = None - - type: Optional[str] = None - - -class IdP(BaseModel): - id: Optional[str] = None - - type: Optional[str] = None - - -class MTLSAuth(BaseModel): - auth_status: Optional[str] = None - - cert_issuer_dn: Optional[str] = None - - cert_issuer_ski: Optional[str] = None - - cert_presented: Optional[bool] = None - - cert_serial: Optional[str] = None - - -class ActiveSessionGetResponse(BaseModel): - account_id: Optional[str] = None - - auth_status: Optional[str] = None - - common_name: Optional[str] = None - - device_id: Optional[str] = None - - device_sessions: Optional[Dict[str, DeviceSessions]] = None - - device_posture: Optional[Dict[str, DevicePosture]] = FieldInfo(alias="devicePosture", default=None) - - email: Optional[str] = None - - geo: Optional[UserPolicyCheckGeo] = None - - iat: Optional[float] = None - - idp: Optional[IdP] = None - - ip: Optional[str] = None - - is_gateway: Optional[bool] = None - - is_warp: Optional[bool] = None - - is_active: Optional[bool] = FieldInfo(alias="isActive", default=None) - - mtls_auth: Optional[MTLSAuth] = None - - service_token_id: Optional[str] = None - - service_token_status: Optional[bool] = None - - user_uuid: Optional[str] = None - - version: Optional[float] = None diff --git a/src/cloudflare/types/zero_trust/access/users/active_session_list_response.py b/src/cloudflare/types/zero_trust/access/users/active_session_list_response.py deleted file mode 100644 index ac0f4059a81..00000000000 --- a/src/cloudflare/types/zero_trust/access/users/active_session_list_response.py +++ /dev/null @@ -1,37 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, Optional - -from ....._models import BaseModel - -__all__ = ["ActiveSessionListResponse", "Metadata", "MetadataApps"] - - -class MetadataApps(BaseModel): - hostname: Optional[str] = None - - name: Optional[str] = None - - type: Optional[str] = None - - uid: Optional[str] = None - - -class Metadata(BaseModel): - apps: Optional[Dict[str, MetadataApps]] = None - - expires: Optional[int] = None - - iat: Optional[int] = None - - nonce: Optional[str] = None - - ttl: Optional[int] = None - - -class ActiveSessionListResponse(BaseModel): - expiration: Optional[int] = None - - metadata: Optional[Metadata] = None - - name: Optional[str] = None diff --git a/src/cloudflare/types/zero_trust/access/users/failed_login_list_response.py b/src/cloudflare/types/zero_trust/access/users/failed_login_list_response.py deleted file mode 100644 index 358f7afc443..00000000000 --- a/src/cloudflare/types/zero_trust/access/users/failed_login_list_response.py +++ /dev/null @@ -1,13 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ....._models import BaseModel - -__all__ = ["FailedLoginListResponse"] - - -class FailedLoginListResponse(BaseModel): - expiration: Optional[int] = None - - metadata: Optional[object] = None diff --git a/src/cloudflare/types/zero_trust/access/users/identity.py b/src/cloudflare/types/zero_trust/access/users/identity.py deleted file mode 100644 index 52f27fee6c2..00000000000 --- a/src/cloudflare/types/zero_trust/access/users/identity.py +++ /dev/null @@ -1,96 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, Optional - -from pydantic import Field as FieldInfo - -from ....._models import BaseModel -from ..applications.user_policy_check_geo import UserPolicyCheckGeo - -__all__ = ["Identity", "DeviceSessions", "DevicePosture", "DevicePostureCheck", "IdP", "MTLSAuth"] - - -class DeviceSessions(BaseModel): - last_authenticated: Optional[float] = None - - -class DevicePostureCheck(BaseModel): - exists: Optional[bool] = None - - path: Optional[str] = None - - -class DevicePosture(BaseModel): - id: Optional[str] = None - - check: Optional[DevicePostureCheck] = None - - data: Optional[object] = None - - description: Optional[str] = None - - error: Optional[str] = None - - rule_name: Optional[str] = None - - success: Optional[bool] = None - - timestamp: Optional[str] = None - - type: Optional[str] = None - - -class IdP(BaseModel): - id: Optional[str] = None - - type: Optional[str] = None - - -class MTLSAuth(BaseModel): - auth_status: Optional[str] = None - - cert_issuer_dn: Optional[str] = None - - cert_issuer_ski: Optional[str] = None - - cert_presented: Optional[bool] = None - - cert_serial: Optional[str] = None - - -class Identity(BaseModel): - account_id: Optional[str] = None - - auth_status: Optional[str] = None - - common_name: Optional[str] = None - - device_id: Optional[str] = None - - device_sessions: Optional[Dict[str, DeviceSessions]] = None - - device_posture: Optional[Dict[str, DevicePosture]] = FieldInfo(alias="devicePosture", default=None) - - email: Optional[str] = None - - geo: Optional[UserPolicyCheckGeo] = None - - iat: Optional[float] = None - - idp: Optional[IdP] = None - - ip: Optional[str] = None - - is_gateway: Optional[bool] = None - - is_warp: Optional[bool] = None - - mtls_auth: Optional[MTLSAuth] = None - - service_token_id: Optional[str] = None - - service_token_status: Optional[bool] = None - - user_uuid: Optional[str] = None - - version: Optional[float] = None diff --git a/src/cloudflare/types/zero_trust/identity_provider_delete_response.py b/src/cloudflare/types/zero_trust/identity_provider_delete_response.py deleted file mode 100644 index 4c84ce5d197..00000000000 --- a/src/cloudflare/types/zero_trust/identity_provider_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ..._models import BaseModel - -__all__ = ["IdentityProviderDeleteResponse"] - - -class IdentityProviderDeleteResponse(BaseModel): - id: Optional[str] = None - """UUID""" diff --git a/src/cloudflare/types/zero_trust/identity_provider_update_params.py b/src/cloudflare/types/zero_trust/identity_provider_update_params.py deleted file mode 100644 index 9667f9f04ba..00000000000 --- a/src/cloudflare/types/zero_trust/identity_provider_update_params.py +++ /dev/null @@ -1,697 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List, Union, Iterable -from typing_extensions import Literal, Required, TypedDict - -from .scim_config_param import ScimConfigParam -from .identity_provider_type import IdentityProviderType -from .generic_oauth_config_param import GenericOAuthConfigParam - -__all__ = [ - "IdentityProviderUpdateParams", - "AzureAD", - "AzureADConfig", - "AccessCentrify", - "AccessCentrifyConfig", - "AccessFacebook", - "AccessGitHub", - "AccessGoogle", - "AccessGoogleConfig", - "AccessGoogleApps", - "AccessGoogleAppsConfig", - "AccessLinkedin", - "AccessOIDC", - "AccessOIDCConfig", - "AccessOkta", - "AccessOktaConfig", - "AccessOnelogin", - "AccessOneloginConfig", - "AccessPingone", - "AccessPingoneConfig", - "AccessSAML", - "AccessSAMLConfig", - "AccessSAMLConfigHeaderAttribute", - "AccessYandex", - "AccessOnetimepin", -] - - -class AzureAD(TypedDict, total=False): - config: Required[AzureADConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AzureADConfig(TypedDict, total=False): - claims: List[str] - """Custom claims""" - - client_id: str - """Your OAuth Client ID""" - - client_secret: str - """Your OAuth Client Secret""" - - conditional_access_enabled: bool - """Should Cloudflare try to load authentication contexts from your account""" - - directory_id: str - """Your Azure directory uuid""" - - email_claim_name: str - """The claim name for email in the id_token response.""" - - prompt: Literal["login", "select_account", "none"] - """Indicates the type of user interaction that is required. - - prompt=login forces the user to enter their credentials on that request, - negating single-sign on. prompt=none is the opposite. It ensures that the user - isn't presented with any interactive prompt. If the request can't be completed - silently by using single-sign on, the Microsoft identity platform returns an - interaction_required error. prompt=select_account interrupts single sign-on - providing account selection experience listing all the accounts either in - session or any remembered account or an option to choose to use a different - account altogether. - """ - - support_groups: bool - """Should Cloudflare try to load groups from your account""" - - -class AccessCentrify(TypedDict, total=False): - config: Required[AccessCentrifyConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessCentrifyConfig(TypedDict, total=False): - centrify_account: str - """Your centrify account url""" - - centrify_app_id: str - """Your centrify app id""" - - claims: List[str] - """Custom claims""" - - client_id: str - """Your OAuth Client ID""" - - client_secret: str - """Your OAuth Client Secret""" - - email_claim_name: str - """The claim name for email in the id_token response.""" - - -class AccessFacebook(TypedDict, total=False): - config: Required[GenericOAuthConfigParam] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessGitHub(TypedDict, total=False): - config: Required[GenericOAuthConfigParam] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessGoogle(TypedDict, total=False): - config: Required[AccessGoogleConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessGoogleConfig(TypedDict, total=False): - claims: List[str] - """Custom claims""" - - client_id: str - """Your OAuth Client ID""" - - client_secret: str - """Your OAuth Client Secret""" - - email_claim_name: str - """The claim name for email in the id_token response.""" - - -class AccessGoogleApps(TypedDict, total=False): - config: Required[AccessGoogleAppsConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessGoogleAppsConfig(TypedDict, total=False): - apps_domain: str - """Your companies TLD""" - - claims: List[str] - """Custom claims""" - - client_id: str - """Your OAuth Client ID""" - - client_secret: str - """Your OAuth Client Secret""" - - email_claim_name: str - """The claim name for email in the id_token response.""" - - -class AccessLinkedin(TypedDict, total=False): - config: Required[GenericOAuthConfigParam] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessOIDC(TypedDict, total=False): - config: Required[AccessOIDCConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessOIDCConfig(TypedDict, total=False): - auth_url: str - """The authorization_endpoint URL of your IdP""" - - certs_url: str - """The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens""" - - claims: List[str] - """Custom claims""" - - client_id: str - """Your OAuth Client ID""" - - client_secret: str - """Your OAuth Client Secret""" - - email_claim_name: str - """The claim name for email in the id_token response.""" - - scopes: List[str] - """OAuth scopes""" - - token_url: str - """The token_endpoint URL of your IdP""" - - -class AccessOkta(TypedDict, total=False): - config: Required[AccessOktaConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessOktaConfig(TypedDict, total=False): - authorization_server_id: str - """Your okta authorization server id""" - - claims: List[str] - """Custom claims""" - - client_id: str - """Your OAuth Client ID""" - - client_secret: str - """Your OAuth Client Secret""" - - email_claim_name: str - """The claim name for email in the id_token response.""" - - okta_account: str - """Your okta account url""" - - -class AccessOnelogin(TypedDict, total=False): - config: Required[AccessOneloginConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessOneloginConfig(TypedDict, total=False): - claims: List[str] - """Custom claims""" - - client_id: str - """Your OAuth Client ID""" - - client_secret: str - """Your OAuth Client Secret""" - - email_claim_name: str - """The claim name for email in the id_token response.""" - - onelogin_account: str - """Your OneLogin account url""" - - -class AccessPingone(TypedDict, total=False): - config: Required[AccessPingoneConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessPingoneConfig(TypedDict, total=False): - claims: List[str] - """Custom claims""" - - client_id: str - """Your OAuth Client ID""" - - client_secret: str - """Your OAuth Client Secret""" - - email_claim_name: str - """The claim name for email in the id_token response.""" - - ping_env_id: str - """Your PingOne environment identifier""" - - -class AccessSAML(TypedDict, total=False): - config: Required[AccessSAMLConfig] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessSAMLConfigHeaderAttribute(TypedDict, total=False): - attribute_name: str - """attribute name from the IDP""" - - header_name: str - """header that will be added on the request to the origin""" - - -class AccessSAMLConfig(TypedDict, total=False): - attributes: List[str] - """ - A list of SAML attribute names that will be added to your signed JWT token and - can be used in SAML policy rules. - """ - - email_attribute_name: str - """The attribute name for email in the SAML response.""" - - header_attributes: Iterable[AccessSAMLConfigHeaderAttribute] - """ - Add a list of attribute names that will be returned in the response header from - the Access callback. - """ - - idp_public_certs: List[str] - """X509 certificate to verify the signature in the SAML authentication response""" - - issuer_url: str - """IdP Entity ID or Issuer URL""" - - sign_request: bool - """Sign the SAML authentication request with Access credentials. - - To verify the signature, use the public key from the Access certs endpoints. - """ - - sso_target_url: str - """URL to send the SAML authentication requests to""" - - -class AccessYandex(TypedDict, total=False): - config: Required[GenericOAuthConfigParam] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -class AccessOnetimepin(TypedDict, total=False): - config: Required[object] - """The configuration parameters for the identity provider. - - To view the required parameters for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - name: Required[str] - """The name of the identity provider, shown to users on the login page.""" - - type: Required[IdentityProviderType] - """The type of identity provider. - - To determine the value for a specific provider, refer to our - [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - """ - - account_id: str - """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - - zone_id: str - """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - - scim_config: ScimConfigParam - """ - The configuration settings for enabling a System for Cross-Domain Identity - Management (SCIM) with the identity provider. - """ - - -IdentityProviderUpdateParams = Union[ - AzureAD, - AccessCentrify, - AccessFacebook, - AccessGitHub, - AccessGoogle, - AccessGoogleApps, - AccessLinkedin, - AccessOIDC, - AccessOkta, - AccessOnelogin, - AccessPingone, - AccessSAML, - AccessYandex, - AccessOnetimepin, -] diff --git a/src/cloudflare/types/zero_trust/seat.py b/src/cloudflare/types/zero_trust/seat.py deleted file mode 100644 index bf56403a543..00000000000 --- a/src/cloudflare/types/zero_trust/seat.py +++ /dev/null @@ -1,23 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime - -from ..._models import BaseModel - -__all__ = ["Seat"] - - -class Seat(BaseModel): - access_seat: Optional[bool] = None - """True if the seat is part of Access.""" - - created_at: Optional[datetime] = None - - gateway_seat: Optional[bool] = None - """True if the seat is part of Gateway.""" - - seat_uid: Optional[str] = None - """Identifier""" - - updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/seat_edit_params.py b/src/cloudflare/types/zero_trust/seat_edit_params.py deleted file mode 100644 index e385a5e44d9..00000000000 --- a/src/cloudflare/types/zero_trust/seat_edit_params.py +++ /dev/null @@ -1,20 +0,0 @@ -# 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 - -__all__ = ["SeatEditParams", "Body"] - - -class SeatEditParams(TypedDict, total=False): - body: Required[Iterable[Body]] - - -class Body(TypedDict, total=False): - access_seat: Required[bool] - """True if the seat is part of Access.""" - - gateway_seat: Required[bool] - """True if the seat is part of Gateway.""" diff --git a/src/cloudflare/types/zero_trust/seat_edit_response.py b/src/cloudflare/types/zero_trust/seat_edit_response.py deleted file mode 100644 index a29d3feb33b..00000000000 --- a/src/cloudflare/types/zero_trust/seat_edit_response.py +++ /dev/null @@ -1,9 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List - -from .seat import Seat - -__all__ = ["SeatEditResponse"] - -SeatEditResponse = List[Seat] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py index b457e152f24..1496d433303 100644 --- a/tests/api_resources/rulesets/test_rules.py +++ b/tests/api_resources/rulesets/test_rules.py @@ -1394,156 +1394,6 @@ def test_path_params_create_overload_16(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_overload_17(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="ddos_dynamic", - action_parameters={}, - description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create_overload_17(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_overload_18(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="force_connection_close", - action_parameters={}, - description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create_overload_18(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_delete(self, client: Cloudflare) -> None: @@ -3222,184 +3072,6 @@ def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_overload_17(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="ddos_dynamic", - action_parameters={}, - description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_overload_18(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="force_connection_close", - action_parameters={}, - description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_edit_overload_18(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - class TestAsyncRules: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -4637,165 +4309,11 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy }, "origin_cache_control": True, "origin_error_page_passthru": True, - "read_timeout": 900, - "respect_strong_etags": True, - "serve_stale": {"disable_stale_while_updating": True}, - }, - description="Set cache settings when the hostname address is not example.com", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="log_custom_field", - action_parameters={ - "cookie_fields": [{"name": "cookie_name_1"}], - "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], - "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, }, - description="Log custom field when the IP address is not 1.1.1.1", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="ddos_dynamic", - action_parameters={}, - description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + description="Set cache settings when the hostname address is not example.com", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4805,7 +4323,7 @@ async def test_method_create_with_all_params_overload_17(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4818,7 +4336,7 @@ async def test_raw_response_create_overload_17(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4833,7 +4351,7 @@ async def test_streaming_response_create_overload_17(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -4854,7 +4372,7 @@ async def test_path_params_create_overload_17(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4863,14 +4381,18 @@ async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="force_connection_close", - action_parameters={}, - description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4880,7 +4402,7 @@ async def test_method_create_with_all_params_overload_18(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4893,7 +4415,7 @@ async def test_raw_response_create_overload_18(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4908,7 +4430,7 @@ async def test_streaming_response_create_overload_18(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -6604,181 +6126,3 @@ async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="ddos_dynamic", - action_parameters={}, - description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - id="3a03d665bac047339bb530ecb439a90d", - action="force_connection_close", - action_parameters={}, - description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", - enabled=True, - expression="ip.src ne 1.1.1.1", - logging={"enabled": True}, - ref="my_ref", - ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(RuleEditResponse, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_edit_overload_18(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", - account_id="string", - ) diff --git a/tests/api_resources/zero_trust/access/applications/test_cas.py b/tests/api_resources/zero_trust/access/applications/test_cas.py index 745e334fc35..e80d89059db 100644 --- a/tests/api_resources/zero_trust/access/applications/test_cas.py +++ b/tests/api_resources/zero_trust/access/applications/test_cas.py @@ -3,14 +3,14 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access.applications import CA, CAGetResponse, CACreateResponse, CADeleteResponse +from cloudflare.types.zero_trust.access.applications import CA base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -18,73 +18,6 @@ class TestCAs: 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: - ca = client.zero_trust.access.applications.cas.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - ca = client.zero_trust.access.applications.cas.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.cas.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ca = response.parse() - assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.cas.with_streaming_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ca = response.parse() - assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -140,211 +73,10 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - ca = client.zero_trust.access.applications.cas.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete_with_all_params(self, client: Cloudflare) -> None: - ca = client.zero_trust.access.applications.cas.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.cas.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ca = response.parse() - assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.cas.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ca = response.parse() - assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - ca = client.zero_trust.access.applications.cas.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - ca = client.zero_trust.access.applications.cas.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.cas.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ca = response.parse() - assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.cas.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ca = response.parse() - assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.cas.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - class TestAsyncCAs: 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: - ca = await async_client.zero_trust.access.applications.cas.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - ca = await async_client.zero_trust.access.applications.cas.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CACreateResponse], ca, 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.access.applications.cas.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ca = await response.parse() - assert_matches_type(Optional[CACreateResponse], ca, 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.access.applications.cas.with_streaming_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ca = await response.parse() - assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.create( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -399,137 +131,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.applications.cas.with_raw_response.list( account_id="string", ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - ca = await async_client.zero_trust.access.applications.cas.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: - ca = await async_client.zero_trust.access.applications.cas.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.applications.cas.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ca = await response.parse() - assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.applications.cas.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ca = await response.parse() - assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - ca = await async_client.zero_trust.access.applications.cas.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - ca = await async_client.zero_trust.access.applications.cas.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CAGetResponse], ca, 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.access.applications.cas.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ca = await response.parse() - assert_matches_type(Optional[CAGetResponse], ca, 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.access.applications.cas.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ca = await response.parse() - assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.cas.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) diff --git a/tests/api_resources/zero_trust/access/applications/test_policies.py b/tests/api_resources/zero_trust/access/applications/test_policies.py deleted file mode 100644 index b00514954fd..00000000000 --- a/tests/api_resources/zero_trust/access/applications/test_policies.py +++ /dev/null @@ -1,1105 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access.applications import ( - PolicyGetResponse, - PolicyListResponse, - PolicyCreateResponse, - PolicyDeleteResponse, - PolicyUpdateResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestPolicies: - 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.access.applications.policies.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - assert_matches_type(Optional[PolicyCreateResponse], policy, 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.access.applications.policies.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - approval_groups=[ - { - "approvals_needed": 1, - "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "string", - }, - { - "approvals_needed": 3, - "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", - }, - ], - approval_required=True, - exclude=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - isolation_required=False, - precedence=0, - purpose_justification_prompt="Please enter a justification for entering this protected domain.", - purpose_justification_required=True, - require=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - session_duration="24h", - ) - assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.policies.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.policies.with_streaming_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - policy = response.parse() - assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.create( - "", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - approval_groups=[ - { - "approvals_needed": 1, - "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "string", - }, - { - "approvals_needed": 3, - "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", - }, - ], - approval_required=True, - exclude=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - isolation_required=False, - precedence=0, - purpose_justification_prompt="Please enter a justification for entering this protected domain.", - purpose_justification_required=True, - require=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - session_duration="24h", - ) - assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.policies.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.policies.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - policy = response.parse() - assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid1` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.update( - "", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.policies.with_streaming_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - policy = response.parse() - assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.list( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete_with_all_params(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.policies.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - 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"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.policies.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) 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"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid1` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.delete( - "", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - policy = client.zero_trust.access.applications.policies.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.applications.policies.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.applications.policies.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - policy = response.parse() - assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid1` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.get( - "", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.applications.policies.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - -class TestAsyncPolicies: - 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.access.applications.policies.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - assert_matches_type(Optional[PolicyCreateResponse], policy, 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.access.applications.policies.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - approval_groups=[ - { - "approvals_needed": 1, - "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "string", - }, - { - "approvals_needed": 3, - "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", - }, - ], - approval_required=True, - exclude=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - isolation_required=False, - precedence=0, - purpose_justification_prompt="Please enter a justification for entering this protected domain.", - purpose_justification_required=True, - require=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - session_duration="24h", - ) - assert_matches_type(Optional[PolicyCreateResponse], policy, 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.access.applications.policies.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[PolicyCreateResponse], policy, 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.access.applications.policies.with_streaming_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) 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[PolicyCreateResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.create( - "", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - approval_groups=[ - { - "approvals_needed": 1, - "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "string", - }, - { - "approvals_needed": 3, - "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], - "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", - }, - ], - approval_required=True, - exclude=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - isolation_required=False, - precedence=0, - purpose_justification_prompt="Please enter a justification for entering this protected domain.", - purpose_justification_required=True, - require=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - session_duration="24h", - ) - assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.applications.policies.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.applications.policies.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) 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[PolicyUpdateResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid1` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.update( - "", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - decision="allow", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.applications.policies.with_streaming_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) 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[PolicyListResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.list( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.applications.policies.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - 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"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.applications.policies.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) 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"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid1` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.delete( - "", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @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.access.applications.policies.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.access.applications.policies.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[PolicyGetResponse], policy, 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.access.applications.policies.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[PolicyGetResponse], policy, 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.access.applications.policies.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) 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[PolicyGetResponse], policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid1` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.get( - "", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.applications.policies.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - uuid1="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) diff --git a/tests/api_resources/zero_trust/access/logs/__init__.py b/tests/api_resources/zero_trust/access/logs/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/zero_trust/access/logs/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/zero_trust/access/logs/test_access_requests.py b/tests/api_resources/zero_trust/access/logs/test_access_requests.py deleted file mode 100644 index 6e0b18db5a3..00000000000 --- a/tests/api_resources/zero_trust/access/logs/test_access_requests.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.access.logs import AccessRequestListResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestAccessRequests: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - access_request = client.zero_trust.access.logs.access_requests.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.logs.access_requests.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - access_request = response.parse() - assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.logs.access_requests.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - access_request = response.parse() - assert_matches_type(Optional[AccessRequestListResponse], access_request, 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 `identifier` but received ''"): - client.zero_trust.access.logs.access_requests.with_raw_response.list( - "", - ) - - -class TestAsyncAccessRequests: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - access_request = await async_client.zero_trust.access.logs.access_requests.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.logs.access_requests.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - access_request = await response.parse() - assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.logs.access_requests.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - access_request = await response.parse() - assert_matches_type(Optional[AccessRequestListResponse], access_request, 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 `identifier` but received ''"): - await async_client.zero_trust.access.logs.access_requests.with_raw_response.list( - "", - ) diff --git a/tests/api_resources/zero_trust/access/test_bookmarks.py b/tests/api_resources/zero_trust/access/test_bookmarks.py deleted file mode 100644 index f063d8abf85..00000000000 --- a/tests/api_resources/zero_trust/access/test_bookmarks.py +++ /dev/null @@ -1,506 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import ( - Bookmark, - BookmarkDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestBookmarks: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - bookmark = client.zero_trust.access.bookmarks.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.zero_trust.access.bookmarks.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = response.parse() - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.zero_trust.access.bookmarks.with_streaming_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = response.parse() - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.create( - "", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - bookmark = client.zero_trust.access.bookmarks.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.access.bookmarks.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = response.parse() - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.access.bookmarks.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = response.parse() - assert_matches_type(Optional[Bookmark], bookmark, 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 `identifier` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.update( - "", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - bookmark = client.zero_trust.access.bookmarks.list( - "699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(SyncSinglePage[Bookmark], bookmark, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.bookmarks.with_raw_response.list( - "699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = response.parse() - assert_matches_type(SyncSinglePage[Bookmark], bookmark, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.bookmarks.with_streaming_response.list( - "699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = response.parse() - assert_matches_type(SyncSinglePage[Bookmark], bookmark, 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 `identifier` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.list( - "", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - bookmark = client.zero_trust.access.bookmarks.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.access.bookmarks.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = response.parse() - assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.access.bookmarks.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = response.parse() - assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, 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 `identifier` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.delete( - "", - identifier="699d98642c564d2e855e9661899b7252", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - bookmark = client.zero_trust.access.bookmarks.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.bookmarks.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = response.parse() - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.bookmarks.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = response.parse() - assert_matches_type(Optional[Bookmark], bookmark, 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 `identifier` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.bookmarks.with_raw_response.get( - "", - identifier="699d98642c564d2e855e9661899b7252", - ) - - -class TestAsyncBookmarks: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - bookmark = await async_client.zero_trust.access.bookmarks.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.bookmarks.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = await response.parse() - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.bookmarks.with_streaming_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = await response.parse() - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.create( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.create( - "", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - bookmark = await async_client.zero_trust.access.bookmarks.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.bookmarks.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = await response.parse() - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.bookmarks.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = await response.parse() - assert_matches_type(Optional[Bookmark], bookmark, 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 `identifier` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.update( - "", - identifier="699d98642c564d2e855e9661899b7252", - body={}, - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - bookmark = await async_client.zero_trust.access.bookmarks.list( - "699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(AsyncSinglePage[Bookmark], bookmark, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.bookmarks.with_raw_response.list( - "699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = await response.parse() - assert_matches_type(AsyncSinglePage[Bookmark], bookmark, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.bookmarks.with_streaming_response.list( - "699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = await response.parse() - assert_matches_type(AsyncSinglePage[Bookmark], bookmark, 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 `identifier` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.list( - "", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - bookmark = await async_client.zero_trust.access.bookmarks.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.bookmarks.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = await response.parse() - assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.bookmarks.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = await response.parse() - assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, 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 `identifier` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.delete( - "", - identifier="699d98642c564d2e855e9661899b7252", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - bookmark = await async_client.zero_trust.access.bookmarks.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.bookmarks.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - bookmark = await response.parse() - assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.bookmarks.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - bookmark = await response.parse() - assert_matches_type(Optional[Bookmark], bookmark, 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 `identifier` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.bookmarks.with_raw_response.get( - "", - identifier="699d98642c564d2e855e9661899b7252", - ) diff --git a/tests/api_resources/zero_trust/access/test_certificates.py b/tests/api_resources/zero_trust/access/test_certificates.py index 14d5566332c..feb21df3ea5 100644 --- a/tests/api_resources/zero_trust/access/test_certificates.py +++ b/tests/api_resources/zero_trust/access/test_certificates.py @@ -10,10 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import ( - Certificate, - CertificateDeleteResponse, -) +from cloudflare.types.zero_trust.access import Certificate base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -89,81 +86,6 @@ def test_path_params_create(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - certificate = client.zero_trust.access.certificates.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - certificate = client.zero_trust.access.certificates.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - name="Allow devs", - ) - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.access.certificates.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - certificate = response.parse() - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.access.certificates.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - certificate = response.parse() - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.certificates.with_raw_response.update( - "", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.certificates.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.certificates.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -219,140 +141,6 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - certificate = client.zero_trust.access.certificates.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete_with_all_params(self, client: Cloudflare) -> None: - certificate = client.zero_trust.access.certificates.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.access.certificates.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - certificate = response.parse() - assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.access.certificates.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - certificate = response.parse() - assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.certificates.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.certificates.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.certificates.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - certificate = client.zero_trust.access.certificates.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - certificate = client.zero_trust.access.certificates.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.certificates.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - certificate = response.parse() - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.certificates.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - certificate = response.parse() - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.certificates.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.certificates.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.certificates.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - class TestAsyncCertificates: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -425,81 +213,6 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - certificate = await async_client.zero_trust.access.certificates.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - certificate = await async_client.zero_trust.access.certificates.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - name="Allow devs", - ) - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.certificates.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - certificate = await response.parse() - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.certificates.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - certificate = await response.parse() - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.update( - "", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -554,137 +267,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.certificates.with_raw_response.list( account_id="string", ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - certificate = await async_client.zero_trust.access.certificates.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: - certificate = await async_client.zero_trust.access.certificates.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.certificates.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - certificate = await response.parse() - assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.certificates.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - certificate = await response.parse() - assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - certificate = await async_client.zero_trust.access.certificates.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - certificate = await async_client.zero_trust.access.certificates.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[Certificate], certificate, 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.access.certificates.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - certificate = await response.parse() - assert_matches_type(Optional[Certificate], certificate, 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.access.certificates.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - certificate = await response.parse() - assert_matches_type(Optional[Certificate], certificate, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.certificates.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) diff --git a/tests/api_resources/zero_trust/access/test_custom_pages.py b/tests/api_resources/zero_trust/access/test_custom_pages.py deleted file mode 100644 index 7c84edab1bc..00000000000 --- a/tests/api_resources/zero_trust/access/test_custom_pages.py +++ /dev/null @@ -1,567 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import ( - CustomPage, - CustomPageWithoutHTML, - CustomPageDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestCustomPages: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - app_count=0, - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.zero_trust.access.custom_pages.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.zero_trust.access.custom_pages.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.create( - "", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - app_count=0, - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.access.custom_pages.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.access.custom_pages.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, 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 `identifier` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.update( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncSinglePage[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.custom_pages.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = response.parse() - assert_matches_type(SyncSinglePage[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.custom_pages.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = response.parse() - assert_matches_type(SyncSinglePage[CustomPageWithoutHTML], custom_page, 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 `identifier` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.list( - "", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.access.custom_pages.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = response.parse() - assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.access.custom_pages.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = response.parse() - assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, 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 `identifier` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.delete( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - custom_page = client.zero_trust.access.custom_pages.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[CustomPage], custom_page, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.custom_pages.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = response.parse() - assert_matches_type(Optional[CustomPage], custom_page, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.custom_pages.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = response.parse() - assert_matches_type(Optional[CustomPage], custom_page, 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 `identifier` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.custom_pages.with_raw_response.get( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncCustomPages: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - app_count=0, - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.custom_pages.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = await response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.custom_pages.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = await response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.create( - "", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - app_count=0, - ) - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.custom_pages.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = await response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.custom_pages.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = await response.parse() - assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, 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 `identifier` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.update( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - custom_html="

Access Denied

", - name="string", - type="identity_denied", - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncSinglePage[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.custom_pages.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = await response.parse() - assert_matches_type(AsyncSinglePage[CustomPageWithoutHTML], custom_page, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.custom_pages.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = await response.parse() - assert_matches_type(AsyncSinglePage[CustomPageWithoutHTML], custom_page, 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 `identifier` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.list( - "", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.custom_pages.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = await response.parse() - assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.custom_pages.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = await response.parse() - assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, 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 `identifier` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.delete( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - custom_page = await async_client.zero_trust.access.custom_pages.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[CustomPage], custom_page, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.custom_pages.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - custom_page = await response.parse() - assert_matches_type(Optional[CustomPage], custom_page, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.custom_pages.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - custom_page = await response.parse() - assert_matches_type(Optional[CustomPage], custom_page, 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 `identifier` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.custom_pages.with_raw_response.get( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/zero_trust/access/test_groups.py b/tests/api_resources/zero_trust/access/test_groups.py index f7be2db9428..757c6dd633a 100644 --- a/tests/api_resources/zero_trust/access/test_groups.py +++ b/tests/api_resources/zero_trust/access/test_groups.py @@ -10,10 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import ( - ZeroTrustGroup, - GroupDeleteResponse, -) +from cloudflare.types.zero_trust.access import ZeroTrustGroup base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -123,126 +120,6 @@ def test_path_params_create(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - group = client.zero_trust.access.groups.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - group = client.zero_trust.access.groups.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - exclude=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - is_default=True, - require=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - ) - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.access.groups.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - group = response.parse() - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.access.groups.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - group = response.parse() - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.groups.with_raw_response.update( - "", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.groups.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.groups.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -298,140 +175,6 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - group = client.zero_trust.access.groups.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete_with_all_params(self, client: Cloudflare) -> None: - group = client.zero_trust.access.groups.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.access.groups.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - group = response.parse() - assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.access.groups.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - group = response.parse() - assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.groups.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.groups.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.groups.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - group = client.zero_trust.access.groups.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - group = client.zero_trust.access.groups.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.groups.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - group = response.parse() - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.groups.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - group = response.parse() - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.groups.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.groups.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.groups.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - class TestAsyncGroups: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -538,126 +281,6 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - group = await async_client.zero_trust.access.groups.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - group = await async_client.zero_trust.access.groups.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - exclude=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - is_default=True, - require=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - ) - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.groups.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - group = await response.parse() - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.groups.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - group = await response.parse() - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.update( - "", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - include=[ - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - {"email": {"email": "test@example.com"}}, - ], - name="Allow devs", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -712,137 +335,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.groups.with_raw_response.list( account_id="string", ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - group = await async_client.zero_trust.access.groups.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: - group = await async_client.zero_trust.access.groups.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.groups.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - group = await response.parse() - assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.groups.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - group = await response.parse() - assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - group = await async_client.zero_trust.access.groups.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - group = await async_client.zero_trust.access.groups.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ZeroTrustGroup], group, 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.access.groups.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - group = await response.parse() - assert_matches_type(Optional[ZeroTrustGroup], group, 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.access.groups.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - group = await response.parse() - assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.groups.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) diff --git a/tests/api_resources/zero_trust/access/test_keys.py b/tests/api_resources/zero_trust/access/test_keys.py deleted file mode 100644 index ccb5129562c..00000000000 --- a/tests/api_resources/zero_trust/access/test_keys.py +++ /dev/null @@ -1,258 +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.access import KeyGetResponse, KeyRotateResponse, KeyUpdateResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestKeys: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - key = client.zero_trust.access.keys.update( - "023e105f4ecef8ad9ca31a8372d0c353", - key_rotation_interval_days=30, - ) - assert_matches_type(Optional[KeyUpdateResponse], key, path=["response"]) - - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.access.keys.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - key_rotation_interval_days=30, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - key = response.parse() - assert_matches_type(Optional[KeyUpdateResponse], key, path=["response"]) - - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.access.keys.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - key_rotation_interval_days=30, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - key = response.parse() - assert_matches_type(Optional[KeyUpdateResponse], key, 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 `identifier` but received ''"): - client.zero_trust.access.keys.with_raw_response.update( - "", - key_rotation_interval_days=30, - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - key = client.zero_trust.access.keys.get( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[KeyGetResponse], key, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.keys.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - key = response.parse() - assert_matches_type(Optional[KeyGetResponse], key, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.keys.with_streaming_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - key = response.parse() - assert_matches_type(Optional[KeyGetResponse], key, 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 `identifier` but received ''"): - client.zero_trust.access.keys.with_raw_response.get( - "", - ) - - @parametrize - def test_method_rotate(self, client: Cloudflare) -> None: - key = client.zero_trust.access.keys.rotate( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) - - @parametrize - def test_raw_response_rotate(self, client: Cloudflare) -> None: - response = client.zero_trust.access.keys.with_raw_response.rotate( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - key = response.parse() - assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) - - @parametrize - def test_streaming_response_rotate(self, client: Cloudflare) -> None: - with client.zero_trust.access.keys.with_streaming_response.rotate( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - key = response.parse() - assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_rotate(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.zero_trust.access.keys.with_raw_response.rotate( - "", - ) - - -class TestAsyncKeys: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - key = await async_client.zero_trust.access.keys.update( - "023e105f4ecef8ad9ca31a8372d0c353", - key_rotation_interval_days=30, - ) - assert_matches_type(Optional[KeyUpdateResponse], key, path=["response"]) - - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.keys.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - key_rotation_interval_days=30, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - key = await response.parse() - assert_matches_type(Optional[KeyUpdateResponse], key, path=["response"]) - - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.keys.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - key_rotation_interval_days=30, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - key = await response.parse() - assert_matches_type(Optional[KeyUpdateResponse], key, 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 `identifier` but received ''"): - await async_client.zero_trust.access.keys.with_raw_response.update( - "", - key_rotation_interval_days=30, - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - key = await async_client.zero_trust.access.keys.get( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[KeyGetResponse], key, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.keys.with_raw_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - key = await response.parse() - assert_matches_type(Optional[KeyGetResponse], key, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.keys.with_streaming_response.get( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - key = await response.parse() - assert_matches_type(Optional[KeyGetResponse], key, 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 `identifier` but received ''"): - await async_client.zero_trust.access.keys.with_raw_response.get( - "", - ) - - @parametrize - async def test_method_rotate(self, async_client: AsyncCloudflare) -> None: - key = await async_client.zero_trust.access.keys.rotate( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) - - @parametrize - async def test_raw_response_rotate(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.keys.with_raw_response.rotate( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - key = await response.parse() - assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) - - @parametrize - async def test_streaming_response_rotate(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.keys.with_streaming_response.rotate( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - key = await response.parse() - assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_rotate(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.zero_trust.access.keys.with_raw_response.rotate( - "", - ) diff --git a/tests/api_resources/zero_trust/access/test_service_tokens.py b/tests/api_resources/zero_trust/access/test_service_tokens.py index 61c913a70aa..dd32841ccab 100644 --- a/tests/api_resources/zero_trust/access/test_service_tokens.py +++ b/tests/api_resources/zero_trust/access/test_service_tokens.py @@ -10,11 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import ( - ServiceToken, - ServiceTokenCreateResponse, - ServiceTokenRotateResponse, -) +from cloudflare.types.zero_trust.access import ServiceToken, ServiceTokenCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -84,75 +80,6 @@ def test_path_params_create(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - service_token = client.zero_trust.access.service_tokens.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - service_token = client.zero_trust.access.service_tokens.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - duration="60m", - name="CI/CD token", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.access.service_tokens.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.access.service_tokens.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.update( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -208,236 +135,6 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - service_token = client.zero_trust.access.service_tokens.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete_with_all_params(self, client: Cloudflare) -> None: - service_token = client.zero_trust.access.service_tokens.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.access.service_tokens.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.access.service_tokens.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - service_token = client.zero_trust.access.service_tokens.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - service_token = client.zero_trust.access.service_tokens.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.service_tokens.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.service_tokens.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @parametrize - def test_method_refresh(self, client: Cloudflare) -> None: - service_token = client.zero_trust.access.service_tokens.refresh( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @parametrize - def test_raw_response_refresh(self, client: Cloudflare) -> None: - response = client.zero_trust.access.service_tokens.with_raw_response.refresh( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @parametrize - def test_streaming_response_refresh(self, client: Cloudflare) -> None: - with client.zero_trust.access.service_tokens.with_streaming_response.refresh( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_refresh(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.refresh( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.refresh( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_rotate(self, client: Cloudflare) -> None: - service_token = client.zero_trust.access.service_tokens.rotate( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) - - @parametrize - def test_raw_response_rotate(self, client: Cloudflare) -> None: - response = client.zero_trust.access.service_tokens.with_raw_response.rotate( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = response.parse() - assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) - - @parametrize - def test_streaming_response_rotate(self, client: Cloudflare) -> None: - with client.zero_trust.access.service_tokens.with_streaming_response.rotate( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = response.parse() - assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_rotate(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.rotate( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.access.service_tokens.with_raw_response.rotate( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - class TestAsyncServiceTokens: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -504,75 +201,6 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - service_token = await async_client.zero_trust.access.service_tokens.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - service_token = await async_client.zero_trust.access.service_tokens.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - duration="60m", - name="CI/CD token", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.service_tokens.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = await response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.service_tokens.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = await response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.update( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -627,233 +255,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.service_tokens.with_raw_response.list( account_id="string", ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - service_token = await async_client.zero_trust.access.service_tokens.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: - service_token = await async_client.zero_trust.access.service_tokens.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.service_tokens.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = await response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.service_tokens.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = await response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - service_token = await async_client.zero_trust.access.service_tokens.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - service_token = await async_client.zero_trust.access.service_tokens.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[ServiceToken], service_token, 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.access.service_tokens.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = await response.parse() - assert_matches_type(Optional[ServiceToken], service_token, 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.access.service_tokens.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = await response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @parametrize - async def test_method_refresh(self, async_client: AsyncCloudflare) -> None: - service_token = await async_client.zero_trust.access.service_tokens.refresh( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @parametrize - async def test_raw_response_refresh(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.service_tokens.with_raw_response.refresh( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = await response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - @parametrize - async def test_streaming_response_refresh(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.service_tokens.with_streaming_response.refresh( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = await response.parse() - assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_refresh(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.refresh( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.refresh( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_rotate(self, async_client: AsyncCloudflare) -> None: - service_token = await async_client.zero_trust.access.service_tokens.rotate( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) - - @parametrize - async def test_raw_response_rotate(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.service_tokens.with_raw_response.rotate( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - service_token = await response.parse() - assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) - - @parametrize - async def test_streaming_response_rotate(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.service_tokens.with_streaming_response.rotate( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - service_token = await response.parse() - assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_rotate(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.rotate( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.access.service_tokens.with_raw_response.rotate( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/zero_trust/access/test_tags.py b/tests/api_resources/zero_trust/access/test_tags.py deleted file mode 100644 index c81e4b77bcb..00000000000 --- a/tests/api_resources/zero_trust/access/test_tags.py +++ /dev/null @@ -1,481 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import Tag, TagDeleteResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestTags: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - tag = client.zero_trust.access.tags.create( - "023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.zero_trust.access.tags.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = response.parse() - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.zero_trust.access.tags.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = response.parse() - assert_matches_type(Optional[Tag], tag, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.zero_trust.access.tags.with_raw_response.create( - "", - name="engineers", - ) - - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - tag = client.zero_trust.access.tags.update( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.access.tags.with_raw_response.update( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = response.parse() - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.access.tags.with_streaming_response.update( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = response.parse() - assert_matches_type(Optional[Tag], tag, 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 `identifier` but received ''"): - client.zero_trust.access.tags.with_raw_response.update( - "engineers", - identifier="", - name="engineers", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_name` but received ''"): - client.zero_trust.access.tags.with_raw_response.update( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - name="", - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - tag = client.zero_trust.access.tags.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncSinglePage[Tag], tag, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.tags.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = response.parse() - assert_matches_type(SyncSinglePage[Tag], tag, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.tags.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = response.parse() - assert_matches_type(SyncSinglePage[Tag], tag, 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 `identifier` but received ''"): - client.zero_trust.access.tags.with_raw_response.list( - "", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - tag = client.zero_trust.access.tags.delete( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[TagDeleteResponse], tag, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.access.tags.with_raw_response.delete( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = response.parse() - assert_matches_type(Optional[TagDeleteResponse], tag, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.access.tags.with_streaming_response.delete( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = response.parse() - assert_matches_type(Optional[TagDeleteResponse], tag, 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 `identifier` but received ''"): - client.zero_trust.access.tags.with_raw_response.delete( - "engineers", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): - client.zero_trust.access.tags.with_raw_response.delete( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - tag = client.zero_trust.access.tags.get( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.tags.with_raw_response.get( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = response.parse() - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.tags.with_streaming_response.get( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = response.parse() - assert_matches_type(Optional[Tag], tag, 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 `identifier` but received ''"): - client.zero_trust.access.tags.with_raw_response.get( - "engineers", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): - client.zero_trust.access.tags.with_raw_response.get( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncTags: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - tag = await async_client.zero_trust.access.tags.create( - "023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.tags.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = await response.parse() - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.tags.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = await response.parse() - assert_matches_type(Optional[Tag], tag, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.zero_trust.access.tags.with_raw_response.create( - "", - name="engineers", - ) - - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - tag = await async_client.zero_trust.access.tags.update( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.tags.with_raw_response.update( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = await response.parse() - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.tags.with_streaming_response.update( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - name="engineers", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = await response.parse() - assert_matches_type(Optional[Tag], tag, 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 `identifier` but received ''"): - await async_client.zero_trust.access.tags.with_raw_response.update( - "engineers", - identifier="", - name="engineers", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_name` but received ''"): - await async_client.zero_trust.access.tags.with_raw_response.update( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - name="", - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - tag = await async_client.zero_trust.access.tags.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncSinglePage[Tag], tag, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.tags.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = await response.parse() - assert_matches_type(AsyncSinglePage[Tag], tag, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.tags.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = await response.parse() - assert_matches_type(AsyncSinglePage[Tag], tag, 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 `identifier` but received ''"): - await async_client.zero_trust.access.tags.with_raw_response.list( - "", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - tag = await async_client.zero_trust.access.tags.delete( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[TagDeleteResponse], tag, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.tags.with_raw_response.delete( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = await response.parse() - assert_matches_type(Optional[TagDeleteResponse], tag, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.tags.with_streaming_response.delete( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = await response.parse() - assert_matches_type(Optional[TagDeleteResponse], tag, 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 `identifier` but received ''"): - await async_client.zero_trust.access.tags.with_raw_response.delete( - "engineers", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): - await async_client.zero_trust.access.tags.with_raw_response.delete( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - tag = await async_client.zero_trust.access.tags.get( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.tags.with_raw_response.get( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - tag = await response.parse() - assert_matches_type(Optional[Tag], tag, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.tags.with_streaming_response.get( - "engineers", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - tag = await response.parse() - assert_matches_type(Optional[Tag], tag, 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 `identifier` but received ''"): - await async_client.zero_trust.access.tags.with_raw_response.get( - "engineers", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): - await async_client.zero_trust.access.tags.with_raw_response.get( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/zero_trust/access/test_users.py b/tests/api_resources/zero_trust/access/test_users.py deleted file mode 100644 index 502300c4919..00000000000 --- a/tests/api_resources/zero_trust/access/test_users.py +++ /dev/null @@ -1,99 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import AccessUser - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestUsers: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - user = client.zero_trust.access.users.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncSinglePage[AccessUser], user, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.users.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - user = response.parse() - assert_matches_type(SyncSinglePage[AccessUser], user, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.users.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - user = response.parse() - assert_matches_type(SyncSinglePage[AccessUser], user, 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 `identifier` but received ''"): - client.zero_trust.access.users.with_raw_response.list( - "", - ) - - -class TestAsyncUsers: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - user = await async_client.zero_trust.access.users.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncSinglePage[AccessUser], user, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.users.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - user = await response.parse() - assert_matches_type(AsyncSinglePage[AccessUser], user, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.users.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - user = await response.parse() - assert_matches_type(AsyncSinglePage[AccessUser], user, 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 `identifier` but received ''"): - await async_client.zero_trust.access.users.with_raw_response.list( - "", - ) diff --git a/tests/api_resources/zero_trust/access/users/__init__.py b/tests/api_resources/zero_trust/access/users/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/zero_trust/access/users/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/zero_trust/access/users/test_active_sessions.py b/tests/api_resources/zero_trust/access/users/test_active_sessions.py deleted file mode 100644 index 257192ec0de..00000000000 --- a/tests/api_resources/zero_trust/access/users/test_active_sessions.py +++ /dev/null @@ -1,239 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access.users import ActiveSessionGetResponse, ActiveSessionListResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestActiveSessions: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - active_session = client.zero_trust.access.users.active_sessions.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncSinglePage[ActiveSessionListResponse], active_session, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.users.active_sessions.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - active_session = response.parse() - assert_matches_type(SyncSinglePage[ActiveSessionListResponse], active_session, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.users.active_sessions.with_streaming_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - active_session = response.parse() - assert_matches_type(SyncSinglePage[ActiveSessionListResponse], active_session, 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 `identifier` but received ''"): - client.zero_trust.access.users.active_sessions.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.zero_trust.access.users.active_sessions.with_raw_response.list( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - active_session = client.zero_trust.access.users.active_sessions.get( - "X1aXj1lFVcqqyoXF", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - assert_matches_type(Optional[ActiveSessionGetResponse], active_session, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.users.active_sessions.with_raw_response.get( - "X1aXj1lFVcqqyoXF", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - active_session = response.parse() - assert_matches_type(Optional[ActiveSessionGetResponse], active_session, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.users.active_sessions.with_streaming_response.get( - "X1aXj1lFVcqqyoXF", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - active_session = response.parse() - assert_matches_type(Optional[ActiveSessionGetResponse], active_session, 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 `identifier` but received ''"): - client.zero_trust.access.users.active_sessions.with_raw_response.get( - "X1aXj1lFVcqqyoXF", - identifier="", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.zero_trust.access.users.active_sessions.with_raw_response.get( - "X1aXj1lFVcqqyoXF", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `nonce` but received ''"): - client.zero_trust.access.users.active_sessions.with_raw_response.get( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - - -class TestAsyncActiveSessions: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - active_session = await async_client.zero_trust.access.users.active_sessions.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncSinglePage[ActiveSessionListResponse], active_session, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.users.active_sessions.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - active_session = await response.parse() - assert_matches_type(AsyncSinglePage[ActiveSessionListResponse], active_session, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.users.active_sessions.with_streaming_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - active_session = await response.parse() - assert_matches_type(AsyncSinglePage[ActiveSessionListResponse], active_session, 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 `identifier` but received ''"): - await async_client.zero_trust.access.users.active_sessions.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.zero_trust.access.users.active_sessions.with_raw_response.list( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - active_session = await async_client.zero_trust.access.users.active_sessions.get( - "X1aXj1lFVcqqyoXF", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - assert_matches_type(Optional[ActiveSessionGetResponse], active_session, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.users.active_sessions.with_raw_response.get( - "X1aXj1lFVcqqyoXF", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - active_session = await response.parse() - assert_matches_type(Optional[ActiveSessionGetResponse], active_session, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.users.active_sessions.with_streaming_response.get( - "X1aXj1lFVcqqyoXF", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - active_session = await response.parse() - assert_matches_type(Optional[ActiveSessionGetResponse], active_session, 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 `identifier` but received ''"): - await async_client.zero_trust.access.users.active_sessions.with_raw_response.get( - "X1aXj1lFVcqqyoXF", - identifier="", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.zero_trust.access.users.active_sessions.with_raw_response.get( - "X1aXj1lFVcqqyoXF", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `nonce` but received ''"): - await async_client.zero_trust.access.users.active_sessions.with_raw_response.get( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) diff --git a/tests/api_resources/zero_trust/access/users/test_failed_logins.py b/tests/api_resources/zero_trust/access/users/test_failed_logins.py deleted file mode 100644 index 466bb95ca07..00000000000 --- a/tests/api_resources/zero_trust/access/users/test_failed_logins.py +++ /dev/null @@ -1,119 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access.users import FailedLoginListResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestFailedLogins: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - failed_login = client.zero_trust.access.users.failed_logins.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncSinglePage[FailedLoginListResponse], failed_login, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.access.users.failed_logins.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - failed_login = response.parse() - assert_matches_type(SyncSinglePage[FailedLoginListResponse], failed_login, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.access.users.failed_logins.with_streaming_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - failed_login = response.parse() - assert_matches_type(SyncSinglePage[FailedLoginListResponse], failed_login, 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 `identifier` but received ''"): - client.zero_trust.access.users.failed_logins.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.zero_trust.access.users.failed_logins.with_raw_response.list( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncFailedLogins: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - failed_login = await async_client.zero_trust.access.users.failed_logins.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncSinglePage[FailedLoginListResponse], failed_login, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.users.failed_logins.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - failed_login = await response.parse() - assert_matches_type(AsyncSinglePage[FailedLoginListResponse], failed_login, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.users.failed_logins.with_streaming_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - failed_login = await response.parse() - assert_matches_type(AsyncSinglePage[FailedLoginListResponse], failed_login, 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 `identifier` but received ''"): - await async_client.zero_trust.access.users.failed_logins.with_raw_response.list( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.zero_trust.access.users.failed_logins.with_raw_response.list( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/zero_trust/access/users/test_last_seen_identity.py b/tests/api_resources/zero_trust/access/users/test_last_seen_identity.py deleted file mode 100644 index e23146df8d6..00000000000 --- a/tests/api_resources/zero_trust/access/users/test_last_seen_identity.py +++ /dev/null @@ -1,118 +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.access.users import Identity - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestLastSeenIdentity: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - last_seen_identity = client.zero_trust.access.users.last_seen_identity.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[Identity], last_seen_identity, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.access.users.last_seen_identity.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - last_seen_identity = response.parse() - assert_matches_type(Optional[Identity], last_seen_identity, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.access.users.last_seen_identity.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - last_seen_identity = response.parse() - assert_matches_type(Optional[Identity], last_seen_identity, 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 `identifier` but received ''"): - client.zero_trust.access.users.last_seen_identity.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.zero_trust.access.users.last_seen_identity.with_raw_response.get( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncLastSeenIdentity: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - last_seen_identity = await async_client.zero_trust.access.users.last_seen_identity.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[Identity], last_seen_identity, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.access.users.last_seen_identity.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - last_seen_identity = await response.parse() - assert_matches_type(Optional[Identity], last_seen_identity, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.access.users.last_seen_identity.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - last_seen_identity = await response.parse() - assert_matches_type(Optional[Identity], last_seen_identity, 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 `identifier` but received ''"): - await async_client.zero_trust.access.users.last_seen_identity.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - identifier="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.zero_trust.access.users.last_seen_identity.with_raw_response.get( - "", - identifier="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/zero_trust/test_identity_providers.py b/tests/api_resources/zero_trust/test_identity_providers.py index 7204c198113..b78e5843fd8 100644 --- a/tests/api_resources/zero_trust/test_identity_providers.py +++ b/tests/api_resources/zero_trust/test_identity_providers.py @@ -13,7 +13,6 @@ from cloudflare.types.zero_trust import ( IdentityProvider, IdentityProviderListResponse, - IdentityProviderDeleteResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -1232,2828 +1231,67 @@ def test_path_params_create_overload_14(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_update_overload_1(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "conditional_access_enabled": True, - "directory_id": "", - "prompt": "login", - "support_groups": True, - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_1(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_2(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "centrify_account": "https://abc123.my.centrify.com/", - "centrify_app_id": "exampleapp", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_2(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_3(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_3(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_4(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_4(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_5(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_5(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_5(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_6(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_6(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "apps_domain": "mycompany.com", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_6(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_7(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_7(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_7(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_7(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_7(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_8(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_8(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "auth_url": "https://accounts.google.com/o/oauth2/auth", - "certs_url": "https://www.googleapis.com/oauth2/v3/certs", - "scopes": ["openid", "email", "profile"], - "token_url": "https://accounts.google.com/o/oauth2/token", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_8(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_8(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_8(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_9(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_9(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "authorization_server_id": "aus9o8wzkhckw9TLa0h7z", - "okta_account": "https://dev-abc123.oktapreview.com", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_9(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_9(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_9(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_10(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_10(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "onelogin_account": "https://mycompany.onelogin.com", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_10(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_10(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_10(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_11(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_11(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "ping_env_id": "342b5660-0c32-4936-a5a4-ce21fae57b0a", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_11(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_11(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_11(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_12(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_12(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "attributes": ["group", "department_code", "divison"], - "email_attribute_name": "Email", - "header_attributes": [ - { - "attribute_name": "string", - "header_name": "string", - }, - { - "attribute_name": "string", - "header_name": "string", - }, - { - "attribute_name": "string", - "header_name": "string", - }, - ], - "idp_public_certs": ["string", "string", "string"], - "issuer_url": "https://whoami.com", - "sign_request": True, - "sso_target_url": "https://edgeaccess.org/idp/saml/login", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_12(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_12(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_12(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_13(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_13(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={ - "client_id": "", - "client_secret": "", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_13(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_13(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_13(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_14(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params_overload_14(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_14(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_14(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_14(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.list( - account_id="string", - ) - assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.list( - account_id="string", - ) - assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.list( - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.list( - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.list( - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.list( - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete_with_all_params(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - client.zero_trust.identity_providers.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - -class TestAsyncIdentityProviders: - 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_overload_1(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "conditional_access_enabled": True, - "directory_id": "", - "prompt": "login", - "support_groups": True, - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_1(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "centrify_account": "https://abc123.my.centrify.com/", - "centrify_app_id": "exampleapp", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_2(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_3(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_4(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_5(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_5(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_6(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "apps_domain": "mycompany.com", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_6(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_7(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_7(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_8(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "auth_url": "https://accounts.google.com/o/oauth2/auth", - "certs_url": "https://www.googleapis.com/oauth2/v3/certs", - "scopes": ["openid", "email", "profile"], - "token_url": "https://accounts.google.com/o/oauth2/token", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_8(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_9(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "authorization_server_id": "aus9o8wzkhckw9TLa0h7z", - "okta_account": "https://dev-abc123.oktapreview.com", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_9(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_10(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "onelogin_account": "https://mycompany.onelogin.com", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_10(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_11(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - "claims": ["email_verified", "preferred_username", "custom_claim_name"], - "email_claim_name": "custom_claim_name", - "ping_env_id": "342b5660-0c32-4936-a5a4-ce21fae57b0a", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_11(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_12(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "attributes": ["group", "department_code", "divison"], - "email_attribute_name": "Email", - "header_attributes": [ - { - "attribute_name": "string", - "header_name": "string", - }, - { - "attribute_name": "string", - "header_name": "string", - }, - { - "attribute_name": "string", - "header_name": "string", - }, - ], - "idp_public_certs": ["string", "string", "string"], - "issuer_url": "https://whoami.com", - "sign_request": True, - "sso_target_url": "https://edgeaccess.org/idp/saml/login", - }, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_12(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_13(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", + def test_method_list(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.list( account_id="string", ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={ - "client_id": "", - "client_secret": "", - }, - name="Widget Corps IDP", - type="onetimepin", + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.list( account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.list( account_id="string", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + identity_provider = response.parse() + assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.list( account_id="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + identity_provider = response.parse() + assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_13(self, async_client: AsyncCloudflare) -> None: + 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 ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", + client.zero_trust.identity_providers.with_raw_response.list( account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", + client.zero_trust.identity_providers.with_raw_response.list( account_id="string", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_overload_14(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - scim_config={ - "enabled": True, - "group_member_deprovision": True, - "seat_deprovision": True, - "secret": "string", - "user_deprovision": True, - }, - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_create_overload_14(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.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="", - ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) +class TestAsyncIdentityProviders: + 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_update_overload_1(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4063,9 +1301,8 @@ async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4091,9 +1328,8 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4107,9 +1343,8 @@ async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4125,19 +1360,9 @@ async def test_streaming_response_update_overload_1(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_1(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4145,8 +1370,7 @@ async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4155,9 +1379,8 @@ async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4167,9 +1390,8 @@ async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4193,9 +1415,8 @@ async def test_method_update_with_all_params_overload_2(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4209,9 +1430,8 @@ async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4227,19 +1447,9 @@ async def test_streaming_response_update_overload_2(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_2(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4247,8 +1457,7 @@ async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4257,9 +1466,8 @@ async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4269,9 +1477,8 @@ async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4291,9 +1498,8 @@ async def test_method_update_with_all_params_overload_3(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4307,9 +1513,8 @@ async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4325,19 +1530,9 @@ async def test_streaming_response_update_overload_3(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_3(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4345,8 +1540,7 @@ async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4355,9 +1549,8 @@ async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4367,9 +1560,8 @@ async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4389,9 +1581,8 @@ async def test_method_update_with_all_params_overload_4(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4405,9 +1596,8 @@ async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4423,19 +1613,9 @@ async def test_streaming_response_update_overload_4(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_4(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4443,8 +1623,7 @@ async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4453,9 +1632,8 @@ async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_5(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4465,9 +1643,8 @@ async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4489,9 +1666,8 @@ async def test_method_update_with_all_params_overload_5(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4505,9 +1681,8 @@ async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4523,19 +1698,9 @@ async def test_streaming_response_update_overload_5(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_5(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4543,8 +1708,7 @@ async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4553,9 +1717,8 @@ async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_6(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4565,9 +1728,8 @@ async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4590,9 +1752,8 @@ async def test_method_update_with_all_params_overload_6(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4606,9 +1767,8 @@ async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4624,19 +1784,9 @@ async def test_streaming_response_update_overload_6(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_6(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4644,8 +1794,7 @@ async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4654,9 +1803,8 @@ async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_7(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_7(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4666,9 +1814,8 @@ async def test_method_update_overload_7(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4688,9 +1835,8 @@ async def test_method_update_with_all_params_overload_7(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_7(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4704,9 +1850,8 @@ async def test_raw_response_update_overload_7(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_7(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4722,19 +1867,9 @@ async def test_streaming_response_update_overload_7(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_7(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_7(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4742,8 +1877,7 @@ async def test_path_params_update_overload_7(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4752,9 +1886,8 @@ async def test_path_params_update_overload_7(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_8(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_8(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4764,9 +1897,8 @@ async def test_method_update_overload_8(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4792,9 +1924,8 @@ async def test_method_update_with_all_params_overload_8(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_8(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4808,9 +1939,8 @@ async def test_raw_response_update_overload_8(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_8(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4826,19 +1956,9 @@ async def test_streaming_response_update_overload_8(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_8(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_8(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4846,8 +1966,7 @@ async def test_path_params_update_overload_8(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4856,9 +1975,8 @@ async def test_path_params_update_overload_8(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_9(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_9(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4868,9 +1986,8 @@ async def test_method_update_overload_9(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4894,9 +2011,8 @@ async def test_method_update_with_all_params_overload_9(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_9(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4910,9 +2026,8 @@ async def test_raw_response_update_overload_9(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_9(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4928,19 +2043,9 @@ async def test_streaming_response_update_overload_9(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_9(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_9(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4948,8 +2053,7 @@ async def test_path_params_update_overload_9(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4958,9 +2062,8 @@ async def test_path_params_update_overload_9(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_10(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_10(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -4970,9 +2073,8 @@ async def test_method_update_overload_10(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -4995,9 +2097,8 @@ async def test_method_update_with_all_params_overload_10(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_10(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5011,9 +2112,8 @@ async def test_raw_response_update_overload_10(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_10(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5029,19 +2129,9 @@ async def test_streaming_response_update_overload_10(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_10(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_10(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5049,8 +2139,7 @@ async def test_path_params_update_overload_10(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5059,9 +2148,8 @@ async def test_path_params_update_overload_10(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_11(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_11(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5071,9 +2159,8 @@ async def test_method_update_overload_11(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -5096,9 +2183,8 @@ async def test_method_update_with_all_params_overload_11(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_11(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5112,9 +2198,8 @@ async def test_raw_response_update_overload_11(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_11(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5130,19 +2215,9 @@ async def test_streaming_response_update_overload_11(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_11(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_11(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5150,8 +2225,7 @@ async def test_path_params_update_overload_11(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5160,9 +2234,8 @@ async def test_path_params_update_overload_11(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_12(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_12(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5172,9 +2245,8 @@ async def test_method_update_overload_12(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "attributes": ["group", "department_code", "divison"], "email_attribute_name": "Email", @@ -5212,9 +2284,8 @@ async def test_method_update_with_all_params_overload_12(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_12(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5228,9 +2299,8 @@ async def test_raw_response_update_overload_12(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_12(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5246,19 +2316,9 @@ async def test_streaming_response_update_overload_12(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_12(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_12(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5266,8 +2326,7 @@ async def test_path_params_update_overload_12(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5276,9 +2335,8 @@ async def test_path_params_update_overload_12(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_13(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_13(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5288,9 +2346,8 @@ async def test_method_update_overload_13(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={ "client_id": "", "client_secret": "", @@ -5310,9 +2367,8 @@ async def test_method_update_with_all_params_overload_13(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_13(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5326,9 +2382,8 @@ async def test_raw_response_update_overload_13(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_13(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5344,19 +2399,9 @@ async def test_streaming_response_update_overload_13(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_13(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_13(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5364,8 +2409,7 @@ async def test_path_params_update_overload_13(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5374,9 +2418,8 @@ async def test_path_params_update_overload_13(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_14(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_overload_14(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5386,9 +2429,8 @@ async def test_method_update_overload_14(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_method_create_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5405,9 +2447,8 @@ async def test_method_update_with_all_params_overload_14(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_14(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_raw_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5421,9 +2462,8 @@ async def test_raw_response_update_overload_14(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_14(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + async def test_streaming_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5439,19 +2479,9 @@ async def test_streaming_response_update_overload_14(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_14(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "", - config={}, - name="Widget Corps IDP", - type="onetimepin", - account_id="string", - ) - + async def test_path_params_create_overload_14(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.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5459,8 +2489,7 @@ async def test_path_params_update_overload_14(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.update( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + await async_client.zero_trust.identity_providers.with_raw_response.create( config={}, name="Widget Corps IDP", type="onetimepin", @@ -5521,137 +2550,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.identity_providers.with_raw_response.list( account_id="string", ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.delete( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.delete( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - assert_matches_type(Optional[IdentityProvider], identity_provider, 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.identity_providers.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, 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.identity_providers.with_streaming_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - identity_provider = await response.parse() - assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `uuid` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.get( - "", - account_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.get( - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - account_id="string", - ) diff --git a/tests/api_resources/zero_trust/test_seats.py b/tests/api_resources/zero_trust/test_seats.py deleted file mode 100644 index c609d0ab5a2..00000000000 --- a/tests/api_resources/zero_trust/test_seats.py +++ /dev/null @@ -1,218 +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 import SeatEditResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestSeats: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit(self, client: Cloudflare) -> None: - seat = client.zero_trust.seats.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - ], - ) - assert_matches_type(Optional[SeatEditResponse], seat, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.zero_trust.seats.with_raw_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - seat = response.parse() - assert_matches_type(Optional[SeatEditResponse], seat, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.zero_trust.seats.with_streaming_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - seat = response.parse() - assert_matches_type(Optional[SeatEditResponse], seat, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_edit(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.zero_trust.seats.with_raw_response.edit( - "", - body=[ - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - ], - ) - - -class TestAsyncSeats: - 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_edit(self, async_client: AsyncCloudflare) -> None: - seat = await async_client.zero_trust.seats.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - ], - ) - assert_matches_type(Optional[SeatEditResponse], seat, 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.seats.with_raw_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - seat = await response.parse() - assert_matches_type(Optional[SeatEditResponse], seat, 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.seats.with_streaming_response.edit( - "023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - seat = await response.parse() - assert_matches_type(Optional[SeatEditResponse], seat, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.zero_trust.seats.with_raw_response.edit( - "", - body=[ - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - { - "access_seat": False, - "gateway_seat": False, - }, - ], - ) From 5745d99e6178305eb9e32825bb1a4658a702e33a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 01:28:21 +0000 Subject: [PATCH 246/532] feat(api): OpenAPI spec update via Stainless API (#727) --- .stats.yml | 4 +- api.md | 153 +- src/cloudflare/resources/rulesets/rules.py | 492 +++ .../resources/zero_trust/__init__.py | 14 + .../resources/zero_trust/access/__init__.py | 84 + .../resources/zero_trust/access/access.py | 194 + .../access/applications/__init__.py | 14 + .../access/applications/applications.py | 32 + .../zero_trust/access/applications/cas.py | 404 ++ .../access/applications/policies.py | 1007 +++++ .../resources/zero_trust/access/bookmarks.py | 548 +++ .../access/certificates/certificates.py | 407 +- .../zero_trust/access/custom_pages.py | 636 +++ .../resources/zero_trust/access/groups.py | 437 ++- .../resources/zero_trust/access/keys.py | 387 ++ .../zero_trust/access/logs/__init__.py | 33 + .../zero_trust/access/logs/access_requests.py | 158 + .../resources/zero_trust/access/logs/logs.py | 80 + .../zero_trust/access/service_tokens.py | 611 ++- .../resources/zero_trust/access/tags.py | 566 +++ .../zero_trust/access/users/__init__.py | 61 + .../access/users/active_sessions.py | 271 ++ .../zero_trust/access/users/failed_logins.py | 161 + .../access/users/last_seen_identity.py | 168 + .../zero_trust/access/users/users.py | 247 ++ .../zero_trust/identity_providers.py | 2153 +++++++++- src/cloudflare/resources/zero_trust/seats.py | 169 + .../resources/zero_trust/zero_trust.py | 32 + .../types/rulesets/phase_get_response.py | 74 + .../types/rulesets/phase_update_params.py | 56 + .../types/rulesets/phase_update_response.py | 74 + .../rulesets/phases/version_get_response.py | 74 + .../types/rulesets/rule_create_params.py | 68 + .../types/rulesets/rule_create_response.py | 74 + .../types/rulesets/rule_delete_response.py | 74 + .../types/rulesets/rule_edit_params.py | 74 + .../types/rulesets/rule_edit_response.py | 74 + .../types/rulesets/ruleset_create_params.py | 56 + .../types/rulesets/ruleset_create_response.py | 74 + .../types/rulesets/ruleset_get_response.py | 74 + .../types/rulesets/ruleset_update_params.py | 56 + .../types/rulesets/ruleset_update_response.py | 74 + .../types/rulesets/version_get_response.py | 74 + .../rulesets/versions/by_tag_get_response.py | 74 + src/cloudflare/types/zero_trust/__init__.py | 5 + .../types/zero_trust/access/__init__.py | 24 + .../types/zero_trust/access/access_user.py | 41 + .../access/application_create_params.py | 42 + .../access/application_create_response.py | 14 +- .../access/application_get_response.py | 14 +- .../access/application_list_response.py | 14 +- .../access/application_update_params.py | 42 + .../access/application_update_response.py | 14 +- .../access/applications/__init__.py | 10 + .../access/applications/ca_create_response.py | 7 + .../access/applications/ca_delete_response.py | 12 + .../access/applications/ca_get_response.py | 7 + .../applications/policy_create_params.py | 79 + .../applications/policy_create_response.py | 73 + .../applications/policy_delete_response.py | 12 + .../applications/policy_get_response.py | 73 + .../applications/policy_list_response.py | 73 + .../applications/policy_update_params.py | 82 + .../applications/policy_update_response.py | 73 + .../types/zero_trust/access/bookmark.py | 29 + .../access/bookmark_create_params.py | 13 + .../access/bookmark_delete_response.py | 12 + .../access/bookmark_update_params.py | 13 + .../access/certificate_delete_response.py | 12 + .../access/certificate_update_params.py | 24 + .../types/zero_trust/access/custom_page.py | 30 + .../access/custom_page_create_params.py | 24 + .../access/custom_page_delete_response.py | 12 + .../access/custom_page_update_params.py | 24 + .../access/custom_page_without_html.py | 27 + .../access/group_delete_response.py | 12 + .../zero_trust/access/group_update_params.py | 42 + .../zero_trust/access/key_get_response.py | 7 + .../zero_trust/access/key_rotate_response.py | 7 + .../zero_trust/access/key_update_params.py | 15 + .../zero_trust/access/key_update_response.py | 7 + .../types/zero_trust/access/logs/__init__.py | 3 + .../logs/access_request_list_response.py | 9 + .../access/service_token_rotate_response.py | 40 + .../access/service_token_update_params.py | 25 + src/cloudflare/types/zero_trust/access/tag.py | 20 + .../zero_trust/access/tag_create_params.py | 15 + .../zero_trust/access/tag_delete_response.py | 12 + .../zero_trust/access/tag_update_params.py | 15 + .../types/zero_trust/access/users/__init__.py | 5 + .../users/active_session_get_response.py | 98 + .../users/active_session_list_response.py | 37 + .../users/failed_login_list_response.py | 13 + .../types/zero_trust/access/users/identity.py | 96 + .../identity_provider_delete_response.py | 12 + .../identity_provider_update_params.py | 697 ++++ src/cloudflare/types/zero_trust/seat.py | 23 + .../types/zero_trust/seat_edit_params.py | 23 + .../types/zero_trust/seat_edit_response.py | 9 + tests/api_resources/rulesets/test_rules.py | 688 +++- .../access/applications/test_cas.py | 406 +- .../access/applications/test_policies.py | 1105 ++++++ .../zero_trust/access/logs/__init__.py | 1 + .../access/logs/test_access_requests.py | 98 + .../zero_trust/access/test_applications.py | 420 +- .../zero_trust/access/test_bookmarks.py | 506 +++ .../zero_trust/access/test_certificates.py | 423 +- .../zero_trust/access/test_custom_pages.py | 567 +++ .../zero_trust/access/test_groups.py | 513 ++- .../zero_trust/access/test_keys.py | 258 ++ .../zero_trust/access/test_service_tokens.py | 604 ++- .../zero_trust/access/test_tags.py | 481 +++ .../zero_trust/access/test_users.py | 99 + .../zero_trust/access/users/__init__.py | 1 + .../access/users/test_active_sessions.py | 239 ++ .../access/users/test_failed_logins.py | 119 + .../access/users/test_last_seen_identity.py | 118 + .../zero_trust/test_identity_providers.py | 3447 ++++++++++++++++- tests/api_resources/zero_trust/test_seats.py | 218 ++ 119 files changed, 22719 insertions(+), 412 deletions(-) create mode 100644 src/cloudflare/resources/zero_trust/access/applications/policies.py create mode 100644 src/cloudflare/resources/zero_trust/access/bookmarks.py create mode 100644 src/cloudflare/resources/zero_trust/access/custom_pages.py create mode 100644 src/cloudflare/resources/zero_trust/access/keys.py create mode 100644 src/cloudflare/resources/zero_trust/access/logs/__init__.py create mode 100644 src/cloudflare/resources/zero_trust/access/logs/access_requests.py create mode 100644 src/cloudflare/resources/zero_trust/access/logs/logs.py create mode 100644 src/cloudflare/resources/zero_trust/access/tags.py create mode 100644 src/cloudflare/resources/zero_trust/access/users/__init__.py create mode 100644 src/cloudflare/resources/zero_trust/access/users/active_sessions.py create mode 100644 src/cloudflare/resources/zero_trust/access/users/failed_logins.py create mode 100644 src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py create mode 100644 src/cloudflare/resources/zero_trust/access/users/users.py create mode 100644 src/cloudflare/resources/zero_trust/seats.py create mode 100644 src/cloudflare/types/zero_trust/access/access_user.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/ca_create_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/ca_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/ca_get_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_create_params.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_create_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_get_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_list_response.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/applications/policy_update_response.py create mode 100644 src/cloudflare/types/zero_trust/access/bookmark.py create mode 100644 src/cloudflare/types/zero_trust/access/bookmark_create_params.py create mode 100644 src/cloudflare/types/zero_trust/access/bookmark_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/access/bookmark_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/certificate_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/access/certificate_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/custom_page.py create mode 100644 src/cloudflare/types/zero_trust/access/custom_page_create_params.py create mode 100644 src/cloudflare/types/zero_trust/access/custom_page_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/access/custom_page_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/custom_page_without_html.py create mode 100644 src/cloudflare/types/zero_trust/access/group_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/access/group_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/key_get_response.py create mode 100644 src/cloudflare/types/zero_trust/access/key_rotate_response.py create mode 100644 src/cloudflare/types/zero_trust/access/key_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/key_update_response.py create mode 100644 src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py create mode 100644 src/cloudflare/types/zero_trust/access/service_token_rotate_response.py create mode 100644 src/cloudflare/types/zero_trust/access/service_token_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/tag.py create mode 100644 src/cloudflare/types/zero_trust/access/tag_create_params.py create mode 100644 src/cloudflare/types/zero_trust/access/tag_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/access/tag_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/users/active_session_get_response.py create mode 100644 src/cloudflare/types/zero_trust/access/users/active_session_list_response.py create mode 100644 src/cloudflare/types/zero_trust/access/users/failed_login_list_response.py create mode 100644 src/cloudflare/types/zero_trust/access/users/identity.py create mode 100644 src/cloudflare/types/zero_trust/identity_provider_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/identity_provider_update_params.py create mode 100644 src/cloudflare/types/zero_trust/seat.py create mode 100644 src/cloudflare/types/zero_trust/seat_edit_params.py create mode 100644 src/cloudflare/types/zero_trust/seat_edit_response.py create mode 100644 tests/api_resources/zero_trust/access/applications/test_policies.py create mode 100644 tests/api_resources/zero_trust/access/logs/__init__.py create mode 100644 tests/api_resources/zero_trust/access/logs/test_access_requests.py create mode 100644 tests/api_resources/zero_trust/access/test_bookmarks.py create mode 100644 tests/api_resources/zero_trust/access/test_custom_pages.py create mode 100644 tests/api_resources/zero_trust/access/test_keys.py create mode 100644 tests/api_resources/zero_trust/access/test_tags.py create mode 100644 tests/api_resources/zero_trust/access/test_users.py create mode 100644 tests/api_resources/zero_trust/access/users/__init__.py create mode 100644 tests/api_resources/zero_trust/access/users/test_active_sessions.py create mode 100644 tests/api_resources/zero_trust/access/users/test_failed_logins.py create mode 100644 tests/api_resources/zero_trust/access/users/test_last_seen_identity.py create mode 100644 tests/api_resources/zero_trust/test_seats.py diff --git a/.stats.yml b/.stats.yml index 30e67c9adb7..a157cc5cf6b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1274 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-14c9c9adbd65eee546c4f54d95b7627f10b02185348e334a68cbebbe3442733e.yml +configured_endpoints: 1321 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml diff --git a/api.md b/api.md index 0a50bcdb16f..bcf2f8086e2 100644 --- a/api.md +++ b/api.md @@ -5178,13 +5178,17 @@ from cloudflare.types.zero_trust import ( IdentityProviderType, ScimConfig, IdentityProviderListResponse, + IdentityProviderDeleteResponse, ) ``` Methods: - client.zero_trust.identity_providers.create(\*, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.identity_providers.update(identity_provider_id, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.identity_providers.list(\*, account_id, zone_id) -> SyncSinglePage[IdentityProviderListResponse] +- client.zero_trust.identity_providers.delete(identity_provider_id, \*, account_id, zone_id) -> Optional +- client.zero_trust.identity_providers.get(identity_provider_id, \*, account_id, zone_id) -> Optional ## Organizations @@ -5206,9 +5210,13 @@ Methods: Types: ```python -from cloudflare.types.zero_trust import Seat +from cloudflare.types.zero_trust import Seat, SeatEditResponse ``` +Methods: + +- client.zero_trust.seats.edit(\*, account_id, \*\*params) -> Optional + ## Access Types: @@ -5281,12 +5289,20 @@ Methods: Types: ```python -from cloudflare.types.zero_trust.access.applications import CA +from cloudflare.types.zero_trust.access.applications import ( + CA, + CACreateResponse, + CADeleteResponse, + CAGetResponse, +) ``` Methods: +- client.zero_trust.access.applications.cas.create(app_id, \*, account_id, zone_id) -> Optional - client.zero_trust.access.applications.cas.list(\*, account_id, zone_id) -> SyncSinglePage[CA] +- client.zero_trust.access.applications.cas.delete(app_id, \*, account_id, zone_id) -> Optional +- client.zero_trust.access.applications.cas.get(app_id, \*, account_id, zone_id) -> Optional #### UserPolicyChecks @@ -5308,21 +5324,44 @@ Methods: Types: ```python -from cloudflare.types.zero_trust.access.applications import ApprovalGroup, Policy +from cloudflare.types.zero_trust.access.applications import ( + ApprovalGroup, + Policy, + PolicyCreateResponse, + PolicyUpdateResponse, + PolicyListResponse, + PolicyDeleteResponse, + PolicyGetResponse, +) ``` +Methods: + +- client.zero_trust.access.applications.policies.create(app_id, \*, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.applications.policies.update(policy_id, \*, app_id, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.applications.policies.list(app_id, \*, account_id, zone_id) -> SyncSinglePage[PolicyListResponse] +- client.zero_trust.access.applications.policies.delete(policy_id, \*, app_id, account_id, zone_id) -> Optional +- client.zero_trust.access.applications.policies.get(policy_id, \*, app_id, account_id, zone_id) -> Optional + ### Certificates Types: ```python -from cloudflare.types.zero_trust.access import AssociatedHostnames, Certificate +from cloudflare.types.zero_trust.access import ( + AssociatedHostnames, + Certificate, + CertificateDeleteResponse, +) ``` Methods: - client.zero_trust.access.certificates.create(\*, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.certificates.update(certificate_id, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.certificates.list(\*, account_id, zone_id) -> SyncSinglePage[Certificate] +- client.zero_trust.access.certificates.delete(certificate_id, \*, account_id, zone_id) -> Optional +- client.zero_trust.access.certificates.get(certificate_id, \*, account_id, zone_id) -> Optional #### Settings @@ -5346,35 +5385,69 @@ Methods: Types: ```python -from cloudflare.types.zero_trust.access import ZeroTrustGroup +from cloudflare.types.zero_trust.access import ZeroTrustGroup, GroupDeleteResponse ``` Methods: - client.zero_trust.access.groups.create(\*, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.groups.update(group_id, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.groups.list(\*, account_id, zone_id) -> SyncSinglePage[ZeroTrustGroup] +- client.zero_trust.access.groups.delete(group_id, \*, account_id, zone_id) -> Optional +- client.zero_trust.access.groups.get(group_id, \*, account_id, zone_id) -> Optional ### ServiceTokens Types: ```python -from cloudflare.types.zero_trust.access import ServiceToken, ServiceTokenCreateResponse +from cloudflare.types.zero_trust.access import ( + ServiceToken, + ServiceTokenCreateResponse, + ServiceTokenRotateResponse, +) ``` Methods: - client.zero_trust.access.service_tokens.create(\*, account_id, zone_id, \*\*params) -> Optional +- client.zero_trust.access.service_tokens.update(service_token_id, \*, account_id, zone_id, \*\*params) -> Optional - client.zero_trust.access.service_tokens.list(\*, account_id, zone_id) -> SyncSinglePage[ServiceToken] +- client.zero_trust.access.service_tokens.delete(service_token_id, \*, account_id, zone_id) -> Optional +- client.zero_trust.access.service_tokens.get(service_token_id, \*, account_id, zone_id) -> Optional +- client.zero_trust.access.service_tokens.refresh(service_token_id, \*, account_id) -> Optional +- client.zero_trust.access.service_tokens.rotate(service_token_id, \*, account_id) -> Optional ### Bookmarks Types: ```python -from cloudflare.types.zero_trust.access import Bookmark +from cloudflare.types.zero_trust.access import Bookmark, BookmarkDeleteResponse ``` +Methods: + +- client.zero_trust.access.bookmarks.create(bookmark_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.access.bookmarks.update(bookmark_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.access.bookmarks.list(\*, account_id) -> SyncSinglePage[Bookmark] +- client.zero_trust.access.bookmarks.delete(bookmark_id, \*, account_id) -> Optional +- client.zero_trust.access.bookmarks.get(bookmark_id, \*, account_id) -> Optional + +### Keys + +Types: + +```python +from cloudflare.types.zero_trust.access import KeyUpdateResponse, KeyGetResponse, KeyRotateResponse +``` + +Methods: + +- client.zero_trust.access.keys.update(\*, account_id, \*\*params) -> Optional +- client.zero_trust.access.keys.get(\*, account_id) -> Optional +- client.zero_trust.access.keys.rotate(\*, account_id) -> Optional + ### Logs #### AccessRequests @@ -5382,9 +5455,13 @@ from cloudflare.types.zero_trust.access import Bookmark Types: ```python -from cloudflare.types.zero_trust.access.logs import AccessRequests +from cloudflare.types.zero_trust.access.logs import AccessRequests, AccessRequestListResponse ``` +Methods: + +- client.zero_trust.access.logs.access_requests.list(\*, account_id) -> Optional + ### Users Types: @@ -5393,6 +5470,26 @@ Types: from cloudflare.types.zero_trust.access import AccessUser ``` +Methods: + +- client.zero_trust.access.users.list(\*, account_id) -> SyncSinglePage[AccessUser] + +#### ActiveSessions + +Types: + +```python +from cloudflare.types.zero_trust.access.users import ( + ActiveSessionListResponse, + ActiveSessionGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.users.active_sessions.list(user_id, \*, account_id) -> SyncSinglePage[ActiveSessionListResponse] +- client.zero_trust.access.users.active_sessions.get(nonce, \*, account_id, user_id) -> Optional + #### LastSeenIdentity Types: @@ -5401,22 +5498,58 @@ Types: from cloudflare.types.zero_trust.access.users import Identity ``` +Methods: + +- client.zero_trust.access.users.last_seen_identity.get(user_id, \*, account_id) -> Optional + +#### FailedLogins + +Types: + +```python +from cloudflare.types.zero_trust.access.users import FailedLoginListResponse +``` + +Methods: + +- client.zero_trust.access.users.failed_logins.list(user_id, \*, account_id) -> SyncSinglePage[FailedLoginListResponse] + ### CustomPages Types: ```python -from cloudflare.types.zero_trust.access import CustomPage, CustomPageWithoutHTML +from cloudflare.types.zero_trust.access import ( + CustomPage, + CustomPageWithoutHTML, + CustomPageDeleteResponse, +) ``` +Methods: + +- client.zero_trust.access.custom_pages.create(\*, account_id, \*\*params) -> Optional +- client.zero_trust.access.custom_pages.update(custom_page_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.access.custom_pages.list(\*, account_id) -> SyncSinglePage[CustomPageWithoutHTML] +- client.zero_trust.access.custom_pages.delete(custom_page_id, \*, account_id) -> Optional +- client.zero_trust.access.custom_pages.get(custom_page_id, \*, account_id) -> Optional + ### Tags Types: ```python -from cloudflare.types.zero_trust.access import Tag +from cloudflare.types.zero_trust.access import Tag, TagDeleteResponse ``` +Methods: + +- client.zero_trust.access.tags.create(\*, account_id, \*\*params) -> Optional +- client.zero_trust.access.tags.update(tag_name, \*, account_id, \*\*params) -> Optional +- client.zero_trust.access.tags.list(\*, account_id) -> SyncSinglePage[Tag] +- client.zero_trust.access.tags.delete(tag_name, \*, account_id) -> Optional +- client.zero_trust.access.tags.get(tag_name, \*, account_id) -> Optional + ## DEX Types: diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index bd7c415a47b..ecf569b9efa 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -1003,6 +1003,126 @@ def create( """ ... + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + def create( self, ruleset_id: str, @@ -1026,6 +1146,8 @@ def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -2130,6 +2252,128 @@ def edit( """ ... + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + @required_args(["ruleset_id"]) def edit( self, @@ -2155,6 +2399,8 @@ def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object @@ -3193,6 +3439,126 @@ async def create( """ ... + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + async def create( self, ruleset_id: str, @@ -3216,6 +3582,8 @@ async def create( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters | object @@ -4320,6 +4688,128 @@ async def edit( """ ... + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["ddos_dynamic"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["force_connection_close"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + 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 + """ + ... + @required_args(["ruleset_id"]) async def edit( self, @@ -4345,6 +4835,8 @@ async def edit( | Literal["skip"] | Literal["set_cache_settings"] | Literal["log_custom_field"] + | Literal["ddos_dynamic"] + | Literal["force_connection_close"] | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters | object diff --git a/src/cloudflare/resources/zero_trust/__init__.py b/src/cloudflare/resources/zero_trust/__init__.py index 0eac27aeedb..7703df18c9b 100644 --- a/src/cloudflare/resources/zero_trust/__init__.py +++ b/src/cloudflare/resources/zero_trust/__init__.py @@ -16,6 +16,14 @@ DLPResourceWithStreamingResponse, AsyncDLPResourceWithStreamingResponse, ) +from .seats import ( + SeatsResource, + AsyncSeatsResource, + SeatsResourceWithRawResponse, + AsyncSeatsResourceWithRawResponse, + SeatsResourceWithStreamingResponse, + AsyncSeatsResourceWithStreamingResponse, +) from .access import ( AccessResource, AsyncAccessResource, @@ -116,6 +124,12 @@ "AsyncOrganizationsResourceWithRawResponse", "OrganizationsResourceWithStreamingResponse", "AsyncOrganizationsResourceWithStreamingResponse", + "SeatsResource", + "AsyncSeatsResource", + "SeatsResourceWithRawResponse", + "AsyncSeatsResourceWithRawResponse", + "SeatsResourceWithStreamingResponse", + "AsyncSeatsResourceWithStreamingResponse", "AccessResource", "AsyncAccessResource", "AccessResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/access/__init__.py b/src/cloudflare/resources/zero_trust/access/__init__.py index 7f6771c4683..b34af407a86 100644 --- a/src/cloudflare/resources/zero_trust/access/__init__.py +++ b/src/cloudflare/resources/zero_trust/access/__init__.py @@ -1,5 +1,37 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .keys import ( + KeysResource, + AsyncKeysResource, + KeysResourceWithRawResponse, + AsyncKeysResourceWithRawResponse, + KeysResourceWithStreamingResponse, + AsyncKeysResourceWithStreamingResponse, +) +from .logs import ( + LogsResource, + AsyncLogsResource, + LogsResourceWithRawResponse, + AsyncLogsResourceWithRawResponse, + LogsResourceWithStreamingResponse, + AsyncLogsResourceWithStreamingResponse, +) +from .tags import ( + TagsResource, + AsyncTagsResource, + TagsResourceWithRawResponse, + AsyncTagsResourceWithRawResponse, + TagsResourceWithStreamingResponse, + AsyncTagsResourceWithStreamingResponse, +) +from .users import ( + UsersResource, + AsyncUsersResource, + UsersResourceWithRawResponse, + AsyncUsersResourceWithRawResponse, + UsersResourceWithStreamingResponse, + AsyncUsersResourceWithStreamingResponse, +) from .access import ( AccessResource, AsyncAccessResource, @@ -16,6 +48,14 @@ GroupsResourceWithStreamingResponse, AsyncGroupsResourceWithStreamingResponse, ) +from .bookmarks import ( + BookmarksResource, + AsyncBookmarksResource, + BookmarksResourceWithRawResponse, + AsyncBookmarksResourceWithRawResponse, + BookmarksResourceWithStreamingResponse, + AsyncBookmarksResourceWithStreamingResponse, +) from .applications import ( ApplicationsResource, AsyncApplicationsResource, @@ -32,6 +72,14 @@ CertificatesResourceWithStreamingResponse, AsyncCertificatesResourceWithStreamingResponse, ) +from .custom_pages import ( + CustomPagesResource, + AsyncCustomPagesResource, + CustomPagesResourceWithRawResponse, + AsyncCustomPagesResourceWithRawResponse, + CustomPagesResourceWithStreamingResponse, + AsyncCustomPagesResourceWithStreamingResponse, +) from .service_tokens import ( ServiceTokensResource, AsyncServiceTokensResource, @@ -66,6 +114,42 @@ "AsyncServiceTokensResourceWithRawResponse", "ServiceTokensResourceWithStreamingResponse", "AsyncServiceTokensResourceWithStreamingResponse", + "BookmarksResource", + "AsyncBookmarksResource", + "BookmarksResourceWithRawResponse", + "AsyncBookmarksResourceWithRawResponse", + "BookmarksResourceWithStreamingResponse", + "AsyncBookmarksResourceWithStreamingResponse", + "KeysResource", + "AsyncKeysResource", + "KeysResourceWithRawResponse", + "AsyncKeysResourceWithRawResponse", + "KeysResourceWithStreamingResponse", + "AsyncKeysResourceWithStreamingResponse", + "LogsResource", + "AsyncLogsResource", + "LogsResourceWithRawResponse", + "AsyncLogsResourceWithRawResponse", + "LogsResourceWithStreamingResponse", + "AsyncLogsResourceWithStreamingResponse", + "UsersResource", + "AsyncUsersResource", + "UsersResourceWithRawResponse", + "AsyncUsersResourceWithRawResponse", + "UsersResourceWithStreamingResponse", + "AsyncUsersResourceWithStreamingResponse", + "CustomPagesResource", + "AsyncCustomPagesResource", + "CustomPagesResourceWithRawResponse", + "AsyncCustomPagesResourceWithRawResponse", + "CustomPagesResourceWithStreamingResponse", + "AsyncCustomPagesResourceWithStreamingResponse", + "TagsResource", + "AsyncTagsResource", + "TagsResourceWithRawResponse", + "AsyncTagsResourceWithRawResponse", + "TagsResourceWithStreamingResponse", + "AsyncTagsResourceWithStreamingResponse", "AccessResource", "AsyncAccessResource", "AccessResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/access/access.py b/src/cloudflare/resources/zero_trust/access/access.py index f9f03534570..6707c0f7745 100644 --- a/src/cloudflare/resources/zero_trust/access/access.py +++ b/src/cloudflare/resources/zero_trust/access/access.py @@ -2,6 +2,38 @@ from __future__ import annotations +from .keys import ( + KeysResource, + AsyncKeysResource, + KeysResourceWithRawResponse, + AsyncKeysResourceWithRawResponse, + KeysResourceWithStreamingResponse, + AsyncKeysResourceWithStreamingResponse, +) +from .logs import ( + LogsResource, + AsyncLogsResource, + LogsResourceWithRawResponse, + AsyncLogsResourceWithRawResponse, + LogsResourceWithStreamingResponse, + AsyncLogsResourceWithStreamingResponse, +) +from .tags import ( + TagsResource, + AsyncTagsResource, + TagsResourceWithRawResponse, + AsyncTagsResourceWithRawResponse, + TagsResourceWithStreamingResponse, + AsyncTagsResourceWithStreamingResponse, +) +from .users import ( + UsersResource, + AsyncUsersResource, + UsersResourceWithRawResponse, + AsyncUsersResourceWithRawResponse, + UsersResourceWithStreamingResponse, + AsyncUsersResourceWithStreamingResponse, +) from .groups import ( GroupsResource, AsyncGroupsResource, @@ -10,7 +42,17 @@ GroupsResourceWithStreamingResponse, AsyncGroupsResourceWithStreamingResponse, ) +from .bookmarks import ( + BookmarksResource, + AsyncBookmarksResource, + BookmarksResourceWithRawResponse, + AsyncBookmarksResourceWithRawResponse, + BookmarksResourceWithStreamingResponse, + AsyncBookmarksResourceWithStreamingResponse, +) +from .logs.logs import LogsResource, AsyncLogsResource from ...._compat import cached_property +from .users.users import UsersResource, AsyncUsersResource from ...._resource import SyncAPIResource, AsyncAPIResource from .applications import ( ApplicationsResource, @@ -28,6 +70,14 @@ CertificatesResourceWithStreamingResponse, AsyncCertificatesResourceWithStreamingResponse, ) +from .custom_pages import ( + CustomPagesResource, + AsyncCustomPagesResource, + CustomPagesResourceWithRawResponse, + AsyncCustomPagesResourceWithRawResponse, + CustomPagesResourceWithStreamingResponse, + AsyncCustomPagesResourceWithStreamingResponse, +) from .service_tokens import ( ServiceTokensResource, AsyncServiceTokensResource, @@ -59,6 +109,30 @@ def groups(self) -> GroupsResource: def service_tokens(self) -> ServiceTokensResource: return ServiceTokensResource(self._client) + @cached_property + def bookmarks(self) -> BookmarksResource: + return BookmarksResource(self._client) + + @cached_property + def keys(self) -> KeysResource: + return KeysResource(self._client) + + @cached_property + def logs(self) -> LogsResource: + return LogsResource(self._client) + + @cached_property + def users(self) -> UsersResource: + return UsersResource(self._client) + + @cached_property + def custom_pages(self) -> CustomPagesResource: + return CustomPagesResource(self._client) + + @cached_property + def tags(self) -> TagsResource: + return TagsResource(self._client) + @cached_property def with_raw_response(self) -> AccessResourceWithRawResponse: return AccessResourceWithRawResponse(self) @@ -85,6 +159,30 @@ def groups(self) -> AsyncGroupsResource: def service_tokens(self) -> AsyncServiceTokensResource: return AsyncServiceTokensResource(self._client) + @cached_property + def bookmarks(self) -> AsyncBookmarksResource: + return AsyncBookmarksResource(self._client) + + @cached_property + def keys(self) -> AsyncKeysResource: + return AsyncKeysResource(self._client) + + @cached_property + def logs(self) -> AsyncLogsResource: + return AsyncLogsResource(self._client) + + @cached_property + def users(self) -> AsyncUsersResource: + return AsyncUsersResource(self._client) + + @cached_property + def custom_pages(self) -> AsyncCustomPagesResource: + return AsyncCustomPagesResource(self._client) + + @cached_property + def tags(self) -> AsyncTagsResource: + return AsyncTagsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAccessResourceWithRawResponse: return AsyncAccessResourceWithRawResponse(self) @@ -114,6 +212,30 @@ def groups(self) -> GroupsResourceWithRawResponse: def service_tokens(self) -> ServiceTokensResourceWithRawResponse: return ServiceTokensResourceWithRawResponse(self._access.service_tokens) + @cached_property + def bookmarks(self) -> BookmarksResourceWithRawResponse: + return BookmarksResourceWithRawResponse(self._access.bookmarks) + + @cached_property + def keys(self) -> KeysResourceWithRawResponse: + return KeysResourceWithRawResponse(self._access.keys) + + @cached_property + def logs(self) -> LogsResourceWithRawResponse: + return LogsResourceWithRawResponse(self._access.logs) + + @cached_property + def users(self) -> UsersResourceWithRawResponse: + return UsersResourceWithRawResponse(self._access.users) + + @cached_property + def custom_pages(self) -> CustomPagesResourceWithRawResponse: + return CustomPagesResourceWithRawResponse(self._access.custom_pages) + + @cached_property + def tags(self) -> TagsResourceWithRawResponse: + return TagsResourceWithRawResponse(self._access.tags) + class AsyncAccessResourceWithRawResponse: def __init__(self, access: AsyncAccessResource) -> None: @@ -135,6 +257,30 @@ def groups(self) -> AsyncGroupsResourceWithRawResponse: def service_tokens(self) -> AsyncServiceTokensResourceWithRawResponse: return AsyncServiceTokensResourceWithRawResponse(self._access.service_tokens) + @cached_property + def bookmarks(self) -> AsyncBookmarksResourceWithRawResponse: + return AsyncBookmarksResourceWithRawResponse(self._access.bookmarks) + + @cached_property + def keys(self) -> AsyncKeysResourceWithRawResponse: + return AsyncKeysResourceWithRawResponse(self._access.keys) + + @cached_property + def logs(self) -> AsyncLogsResourceWithRawResponse: + return AsyncLogsResourceWithRawResponse(self._access.logs) + + @cached_property + def users(self) -> AsyncUsersResourceWithRawResponse: + return AsyncUsersResourceWithRawResponse(self._access.users) + + @cached_property + def custom_pages(self) -> AsyncCustomPagesResourceWithRawResponse: + return AsyncCustomPagesResourceWithRawResponse(self._access.custom_pages) + + @cached_property + def tags(self) -> AsyncTagsResourceWithRawResponse: + return AsyncTagsResourceWithRawResponse(self._access.tags) + class AccessResourceWithStreamingResponse: def __init__(self, access: AccessResource) -> None: @@ -156,6 +302,30 @@ def groups(self) -> GroupsResourceWithStreamingResponse: def service_tokens(self) -> ServiceTokensResourceWithStreamingResponse: return ServiceTokensResourceWithStreamingResponse(self._access.service_tokens) + @cached_property + def bookmarks(self) -> BookmarksResourceWithStreamingResponse: + return BookmarksResourceWithStreamingResponse(self._access.bookmarks) + + @cached_property + def keys(self) -> KeysResourceWithStreamingResponse: + return KeysResourceWithStreamingResponse(self._access.keys) + + @cached_property + def logs(self) -> LogsResourceWithStreamingResponse: + return LogsResourceWithStreamingResponse(self._access.logs) + + @cached_property + def users(self) -> UsersResourceWithStreamingResponse: + return UsersResourceWithStreamingResponse(self._access.users) + + @cached_property + def custom_pages(self) -> CustomPagesResourceWithStreamingResponse: + return CustomPagesResourceWithStreamingResponse(self._access.custom_pages) + + @cached_property + def tags(self) -> TagsResourceWithStreamingResponse: + return TagsResourceWithStreamingResponse(self._access.tags) + class AsyncAccessResourceWithStreamingResponse: def __init__(self, access: AsyncAccessResource) -> None: @@ -176,3 +346,27 @@ def groups(self) -> AsyncGroupsResourceWithStreamingResponse: @cached_property def service_tokens(self) -> AsyncServiceTokensResourceWithStreamingResponse: return AsyncServiceTokensResourceWithStreamingResponse(self._access.service_tokens) + + @cached_property + def bookmarks(self) -> AsyncBookmarksResourceWithStreamingResponse: + return AsyncBookmarksResourceWithStreamingResponse(self._access.bookmarks) + + @cached_property + def keys(self) -> AsyncKeysResourceWithStreamingResponse: + return AsyncKeysResourceWithStreamingResponse(self._access.keys) + + @cached_property + def logs(self) -> AsyncLogsResourceWithStreamingResponse: + return AsyncLogsResourceWithStreamingResponse(self._access.logs) + + @cached_property + def users(self) -> AsyncUsersResourceWithStreamingResponse: + return AsyncUsersResourceWithStreamingResponse(self._access.users) + + @cached_property + def custom_pages(self) -> AsyncCustomPagesResourceWithStreamingResponse: + return AsyncCustomPagesResourceWithStreamingResponse(self._access.custom_pages) + + @cached_property + def tags(self) -> AsyncTagsResourceWithStreamingResponse: + return AsyncTagsResourceWithStreamingResponse(self._access.tags) diff --git a/src/cloudflare/resources/zero_trust/access/applications/__init__.py b/src/cloudflare/resources/zero_trust/access/applications/__init__.py index f4d00c67e8c..8b6f39c4dd8 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/__init__.py +++ b/src/cloudflare/resources/zero_trust/access/applications/__init__.py @@ -8,6 +8,14 @@ CAsResourceWithStreamingResponse, AsyncCAsResourceWithStreamingResponse, ) +from .policies import ( + PoliciesResource, + AsyncPoliciesResource, + PoliciesResourceWithRawResponse, + AsyncPoliciesResourceWithRawResponse, + PoliciesResourceWithStreamingResponse, + AsyncPoliciesResourceWithStreamingResponse, +) from .applications import ( ApplicationsResource, AsyncApplicationsResource, @@ -38,6 +46,12 @@ "AsyncUserPolicyChecksResourceWithRawResponse", "UserPolicyChecksResourceWithStreamingResponse", "AsyncUserPolicyChecksResourceWithStreamingResponse", + "PoliciesResource", + "AsyncPoliciesResource", + "PoliciesResourceWithRawResponse", + "AsyncPoliciesResourceWithRawResponse", + "PoliciesResourceWithStreamingResponse", + "AsyncPoliciesResourceWithStreamingResponse", "ApplicationsResource", "AsyncApplicationsResource", "ApplicationsResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/access/applications/applications.py b/src/cloudflare/resources/zero_trust/access/applications/applications.py index 7cb75fe8ecc..cb837d07265 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/applications.py +++ b/src/cloudflare/resources/zero_trust/access/applications/applications.py @@ -14,6 +14,14 @@ CAsResourceWithStreamingResponse, AsyncCAsResourceWithStreamingResponse, ) +from .policies import ( + PoliciesResource, + AsyncPoliciesResource, + PoliciesResourceWithRawResponse, + AsyncPoliciesResourceWithRawResponse, + PoliciesResourceWithStreamingResponse, + AsyncPoliciesResourceWithStreamingResponse, +) from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ....._utils import ( maybe_transform, @@ -69,6 +77,10 @@ def cas(self) -> CAsResource: def user_policy_checks(self) -> UserPolicyChecksResource: return UserPolicyChecksResource(self._client) + @cached_property + def policies(self) -> PoliciesResource: + return PoliciesResource(self._client) + @cached_property def with_raw_response(self) -> ApplicationsResourceWithRawResponse: return ApplicationsResourceWithRawResponse(self) @@ -1851,6 +1863,10 @@ def cas(self) -> AsyncCAsResource: def user_policy_checks(self) -> AsyncUserPolicyChecksResource: return AsyncUserPolicyChecksResource(self._client) + @cached_property + def policies(self) -> AsyncPoliciesResource: + return AsyncPoliciesResource(self._client) + @cached_property def with_raw_response(self) -> AsyncApplicationsResourceWithRawResponse: return AsyncApplicationsResourceWithRawResponse(self) @@ -3655,6 +3671,10 @@ def cas(self) -> CAsResourceWithRawResponse: def user_policy_checks(self) -> UserPolicyChecksResourceWithRawResponse: return UserPolicyChecksResourceWithRawResponse(self._applications.user_policy_checks) + @cached_property + def policies(self) -> PoliciesResourceWithRawResponse: + return PoliciesResourceWithRawResponse(self._applications.policies) + class AsyncApplicationsResourceWithRawResponse: def __init__(self, applications: AsyncApplicationsResource) -> None: @@ -3687,6 +3707,10 @@ def cas(self) -> AsyncCAsResourceWithRawResponse: def user_policy_checks(self) -> AsyncUserPolicyChecksResourceWithRawResponse: return AsyncUserPolicyChecksResourceWithRawResponse(self._applications.user_policy_checks) + @cached_property + def policies(self) -> AsyncPoliciesResourceWithRawResponse: + return AsyncPoliciesResourceWithRawResponse(self._applications.policies) + class ApplicationsResourceWithStreamingResponse: def __init__(self, applications: ApplicationsResource) -> None: @@ -3719,6 +3743,10 @@ def cas(self) -> CAsResourceWithStreamingResponse: def user_policy_checks(self) -> UserPolicyChecksResourceWithStreamingResponse: return UserPolicyChecksResourceWithStreamingResponse(self._applications.user_policy_checks) + @cached_property + def policies(self) -> PoliciesResourceWithStreamingResponse: + return PoliciesResourceWithStreamingResponse(self._applications.policies) + class AsyncApplicationsResourceWithStreamingResponse: def __init__(self, applications: AsyncApplicationsResource) -> None: @@ -3750,3 +3778,7 @@ def cas(self) -> AsyncCAsResourceWithStreamingResponse: @cached_property def user_policy_checks(self) -> AsyncUserPolicyChecksResourceWithStreamingResponse: return AsyncUserPolicyChecksResourceWithStreamingResponse(self._applications.user_policy_checks) + + @cached_property + def policies(self) -> AsyncPoliciesResourceWithStreamingResponse: + return AsyncPoliciesResourceWithStreamingResponse(self._applications.policies) diff --git a/src/cloudflare/resources/zero_trust/access/applications/cas.py b/src/cloudflare/resources/zero_trust/access/applications/cas.py index 29133e3028c..6dcc2e9f3d9 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/cas.py +++ b/src/cloudflare/resources/zero_trust/access/applications/cas.py @@ -2,6 +2,8 @@ from __future__ import annotations +from typing import Any, Type, Optional, cast + import httpx from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven @@ -13,12 +15,16 @@ 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.access.applications.ca import CA +from .....types.zero_trust.access.applications.ca_get_response import CAGetResponse +from .....types.zero_trust.access.applications.ca_create_response import CACreateResponse +from .....types.zero_trust.access.applications.ca_delete_response import CADeleteResponse __all__ = ["CAsResource", "AsyncCAsResource"] @@ -32,6 +38,68 @@ def with_raw_response(self) -> CAsResourceWithRawResponse: def with_streaming_response(self) -> CAsResourceWithStreamingResponse: return CAsResourceWithStreamingResponse(self) + def create( + self, + app_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CACreateResponse]: + """ + Generates a new short-lived certificate CA and public key. + + Args: + app_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return cast( + Optional[CACreateResponse], + self._post( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CACreateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[CACreateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + def list( self, *, @@ -81,6 +149,125 @@ def list( model=CA, ) + def delete( + self, + app_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CADeleteResponse]: + """ + Deletes a short-lived certificate CA. + + Args: + app_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CADeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CADeleteResponse]], ResultWrapper[CADeleteResponse]), + ) + + def get( + self, + app_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CAGetResponse]: + """ + Fetches a short-lived certificate CA and its public key. + + Args: + app_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return cast( + Optional[CAGetResponse], + self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CAGetResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[CAGetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + class AsyncCAsResource(AsyncAPIResource): @cached_property @@ -91,6 +278,68 @@ def with_raw_response(self) -> AsyncCAsResourceWithRawResponse: def with_streaming_response(self) -> AsyncCAsResourceWithStreamingResponse: return AsyncCAsResourceWithStreamingResponse(self) + async def create( + self, + app_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CACreateResponse]: + """ + Generates a new short-lived certificate CA and public key. + + Args: + app_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return cast( + Optional[CACreateResponse], + await self._post( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CACreateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[CACreateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + def list( self, *, @@ -140,38 +389,193 @@ def list( model=CA, ) + async def delete( + self, + app_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CADeleteResponse]: + """ + Deletes a short-lived certificate CA. + + Args: + app_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CADeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CADeleteResponse]], ResultWrapper[CADeleteResponse]), + ) + + async def get( + self, + app_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CAGetResponse]: + """ + Fetches a short-lived certificate CA and its public key. + + Args: + app_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return cast( + Optional[CAGetResponse], + await self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/ca", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CAGetResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[CAGetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + class CAsResourceWithRawResponse: def __init__(self, cas: CAsResource) -> None: self._cas = cas + self.create = to_raw_response_wrapper( + cas.create, + ) self.list = to_raw_response_wrapper( cas.list, ) + self.delete = to_raw_response_wrapper( + cas.delete, + ) + self.get = to_raw_response_wrapper( + cas.get, + ) class AsyncCAsResourceWithRawResponse: def __init__(self, cas: AsyncCAsResource) -> None: self._cas = cas + self.create = async_to_raw_response_wrapper( + cas.create, + ) self.list = async_to_raw_response_wrapper( cas.list, ) + self.delete = async_to_raw_response_wrapper( + cas.delete, + ) + self.get = async_to_raw_response_wrapper( + cas.get, + ) class CAsResourceWithStreamingResponse: def __init__(self, cas: CAsResource) -> None: self._cas = cas + self.create = to_streamed_response_wrapper( + cas.create, + ) self.list = to_streamed_response_wrapper( cas.list, ) + self.delete = to_streamed_response_wrapper( + cas.delete, + ) + self.get = to_streamed_response_wrapper( + cas.get, + ) class AsyncCAsResourceWithStreamingResponse: def __init__(self, cas: AsyncCAsResource) -> None: self._cas = cas + self.create = async_to_streamed_response_wrapper( + cas.create, + ) self.list = async_to_streamed_response_wrapper( cas.list, ) + self.delete = async_to_streamed_response_wrapper( + cas.delete, + ) + self.get = async_to_streamed_response_wrapper( + cas.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/applications/policies.py b/src/cloudflare/resources/zero_trust/access/applications/policies.py new file mode 100644 index 00000000000..bbea31c3736 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/applications/policies.py @@ -0,0 +1,1007 @@ +# 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 .....pagination import SyncSinglePage, AsyncSinglePage +from ....._base_client import ( + AsyncPaginator, + make_request_options, +) +from .....types.zero_trust.access import Decision +from .....types.zero_trust.access.decision import Decision +from .....types.zero_trust.access_rule_param import AccessRuleParam +from .....types.zero_trust.access.applications import policy_create_params, policy_update_params +from .....types.zero_trust.access.applications.policy_get_response import PolicyGetResponse +from .....types.zero_trust.access.applications.approval_group_param import ApprovalGroupParam +from .....types.zero_trust.access.applications.policy_list_response import PolicyListResponse +from .....types.zero_trust.access.applications.policy_create_response import PolicyCreateResponse +from .....types.zero_trust.access.applications.policy_delete_response import PolicyDeleteResponse +from .....types.zero_trust.access.applications.policy_update_response import PolicyUpdateResponse + +__all__ = ["PoliciesResource", "AsyncPoliciesResource"] + + +class PoliciesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PoliciesResourceWithRawResponse: + return PoliciesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: + return PoliciesResourceWithStreamingResponse(self) + + def create( + self, + app_id: str, + *, + decision: Decision, + include: Iterable[AccessRuleParam], + name: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, + approval_required: bool | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + isolation_required: bool | NotGiven = NOT_GIVEN, + precedence: int | NotGiven = NOT_GIVEN, + purpose_justification_prompt: str | NotGiven = NOT_GIVEN, + purpose_justification_required: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + session_duration: 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[PolicyCreateResponse]: + """ + Creates a policy applying exclusive to a single application that defines the + users or groups who can reach it. We recommend creating a reusable policy + instead and subsequently referencing its ID in the application's 'policies' + array. + + Args: + app_id: UUID + + decision: The action Access will take if a user matches this policy. + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access policy. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + approval_groups: Administrators who can approve a temporary authentication request. + + approval_required: Requires the user to request access from an administrator at the start of each + session. + + exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot + meet any of the Exclude rules. + + isolation_required: Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + + precedence: The order of execution for this policy. Must be unique for each policy within an + app. + + purpose_justification_prompt: A custom message that will appear on the purpose justification screen. + + purpose_justification_required: Require users to enter a justification when they log in to the application. + + require: Rules evaluated with an AND logical operator. To match the policy, a user must + meet all of the Require rules. + + session_duration: The amount of time that tokens issued for the application will be valid. Must be + in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + m, h. + + 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 app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._post( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + body=maybe_transform( + { + "decision": decision, + "include": include, + "name": name, + "approval_groups": approval_groups, + "approval_required": approval_required, + "exclude": exclude, + "isolation_required": isolation_required, + "precedence": precedence, + "purpose_justification_prompt": purpose_justification_prompt, + "purpose_justification_required": purpose_justification_required, + "require": require, + "session_duration": session_duration, + }, + 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[PolicyCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), + ) + + def update( + self, + policy_id: str, + *, + app_id: str, + decision: Decision, + include: Iterable[AccessRuleParam], + name: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, + approval_required: bool | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + isolation_required: bool | NotGiven = NOT_GIVEN, + precedence: int | NotGiven = NOT_GIVEN, + purpose_justification_prompt: str | NotGiven = NOT_GIVEN, + purpose_justification_required: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + session_duration: 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[PolicyUpdateResponse]: + """Updates an Access policy specific to an application. + + To update a reusable + policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint. + + Args: + app_id: UUID + + policy_id: UUID + + decision: The action Access will take if a user matches this policy. + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access policy. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + approval_groups: Administrators who can approve a temporary authentication request. + + approval_required: Requires the user to request access from an administrator at the start of each + session. + + exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot + meet any of the Exclude rules. + + isolation_required: Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + + precedence: The order of execution for this policy. Must be unique for each policy within an + app. + + purpose_justification_prompt: A custom message that will appear on the purpose justification screen. + + purpose_justification_required: Require users to enter a justification when they log in to the application. + + require: Rules evaluated with an AND logical operator. To match the policy, a user must + meet all of the Require rules. + + session_duration: The amount of time that tokens issued for the application will be valid. Must be + in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + m, h. + + 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 app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + body=maybe_transform( + { + "decision": decision, + "include": include, + "name": name, + "approval_groups": approval_groups, + "approval_required": approval_required, + "exclude": exclude, + "isolation_required": isolation_required, + "precedence": precedence, + "purpose_justification_prompt": purpose_justification_prompt, + "purpose_justification_required": purpose_justification_required, + "require": require, + "session_duration": session_duration, + }, + policy_update_params.PolicyUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), + ) + + def list( + self, + app_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[PolicyListResponse]: + """Lists Access policies configured for an application. + + Returns both exclusively + scoped and reusable policies used by the application. + + Args: + app_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + page=SyncSinglePage[PolicyListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=PolicyListResponse, + ) + + def delete( + self, + policy_id: str, + *, + app_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[PolicyDeleteResponse]: + """Deletes an Access policy specific to an application. + + To delete a reusable + policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint. + + Args: + app_id: UUID + + policy_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{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 get( + self, + policy_id: str, + *, + app_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[PolicyGetResponse]: + """Fetches a single Access policy configured for an application. + + Returns both + exclusively owned and reusable policies used by the application. + + Args: + app_id: UUID + + policy_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), + ) + + +class AsyncPoliciesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPoliciesResourceWithRawResponse: + return AsyncPoliciesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: + return AsyncPoliciesResourceWithStreamingResponse(self) + + async def create( + self, + app_id: str, + *, + decision: Decision, + include: Iterable[AccessRuleParam], + name: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, + approval_required: bool | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + isolation_required: bool | NotGiven = NOT_GIVEN, + precedence: int | NotGiven = NOT_GIVEN, + purpose_justification_prompt: str | NotGiven = NOT_GIVEN, + purpose_justification_required: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + session_duration: 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[PolicyCreateResponse]: + """ + Creates a policy applying exclusive to a single application that defines the + users or groups who can reach it. We recommend creating a reusable policy + instead and subsequently referencing its ID in the application's 'policies' + array. + + Args: + app_id: UUID + + decision: The action Access will take if a user matches this policy. + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access policy. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + approval_groups: Administrators who can approve a temporary authentication request. + + approval_required: Requires the user to request access from an administrator at the start of each + session. + + exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot + meet any of the Exclude rules. + + isolation_required: Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + + precedence: The order of execution for this policy. Must be unique for each policy within an + app. + + purpose_justification_prompt: A custom message that will appear on the purpose justification screen. + + purpose_justification_required: Require users to enter a justification when they log in to the application. + + require: Rules evaluated with an AND logical operator. To match the policy, a user must + meet all of the Require rules. + + session_duration: The amount of time that tokens issued for the application will be valid. Must be + in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + m, h. + + 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 app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._post( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + body=await async_maybe_transform( + { + "decision": decision, + "include": include, + "name": name, + "approval_groups": approval_groups, + "approval_required": approval_required, + "exclude": exclude, + "isolation_required": isolation_required, + "precedence": precedence, + "purpose_justification_prompt": purpose_justification_prompt, + "purpose_justification_required": purpose_justification_required, + "require": require, + "session_duration": session_duration, + }, + 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[PolicyCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), + ) + + async def update( + self, + policy_id: str, + *, + app_id: str, + decision: Decision, + include: Iterable[AccessRuleParam], + name: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, + approval_required: bool | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + isolation_required: bool | NotGiven = NOT_GIVEN, + precedence: int | NotGiven = NOT_GIVEN, + purpose_justification_prompt: str | NotGiven = NOT_GIVEN, + purpose_justification_required: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + session_duration: 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[PolicyUpdateResponse]: + """Updates an Access policy specific to an application. + + To update a reusable + policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint. + + Args: + app_id: UUID + + policy_id: UUID + + decision: The action Access will take if a user matches this policy. + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access policy. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + approval_groups: Administrators who can approve a temporary authentication request. + + approval_required: Requires the user to request access from an administrator at the start of each + session. + + exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot + meet any of the Exclude rules. + + isolation_required: Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + + precedence: The order of execution for this policy. Must be unique for each policy within an + app. + + purpose_justification_prompt: A custom message that will appear on the purpose justification screen. + + purpose_justification_required: Require users to enter a justification when they log in to the application. + + require: Rules evaluated with an AND logical operator. To match the policy, a user must + meet all of the Require rules. + + session_duration: The amount of time that tokens issued for the application will be valid. Must be + in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + m, h. + + 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 app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + body=await async_maybe_transform( + { + "decision": decision, + "include": include, + "name": name, + "approval_groups": approval_groups, + "approval_required": approval_required, + "exclude": exclude, + "isolation_required": isolation_required, + "precedence": precedence, + "purpose_justification_prompt": purpose_justification_prompt, + "purpose_justification_required": purpose_justification_required, + "require": require, + "session_duration": session_duration, + }, + policy_update_params.PolicyUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), + ) + + def list( + self, + app_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[PolicyListResponse, AsyncSinglePage[PolicyListResponse]]: + """Lists Access policies configured for an application. + + Returns both exclusively + scoped and reusable policies used by the application. + + Args: + app_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies", + page=AsyncSinglePage[PolicyListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=PolicyListResponse, + ) + + async def delete( + self, + policy_id: str, + *, + app_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[PolicyDeleteResponse]: + """Deletes an Access policy specific to an application. + + To delete a reusable + policy, use the /account or zones/{account or zone_id}/policies/{uid} endpoint. + + Args: + app_id: UUID + + policy_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{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 get( + self, + policy_id: str, + *, + app_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[PolicyGetResponse]: + """Fetches a single Access policy configured for an application. + + Returns both + exclusively owned and reusable policies used by the application. + + Args: + app_id: UUID + + policy_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not app_id: + raise ValueError(f"Expected a non-empty value for `app_id` but received {app_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/apps/{app_id}/policies/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), + ) + + +class PoliciesResourceWithRawResponse: + def __init__(self, policies: PoliciesResource) -> None: + self._policies = policies + + self.create = to_raw_response_wrapper( + policies.create, + ) + self.update = to_raw_response_wrapper( + policies.update, + ) + self.list = to_raw_response_wrapper( + policies.list, + ) + self.delete = to_raw_response_wrapper( + policies.delete, + ) + self.get = to_raw_response_wrapper( + policies.get, + ) + + +class AsyncPoliciesResourceWithRawResponse: + def __init__(self, policies: AsyncPoliciesResource) -> None: + self._policies = policies + + self.create = async_to_raw_response_wrapper( + policies.create, + ) + self.update = async_to_raw_response_wrapper( + policies.update, + ) + self.list = async_to_raw_response_wrapper( + policies.list, + ) + self.delete = async_to_raw_response_wrapper( + policies.delete, + ) + self.get = async_to_raw_response_wrapper( + policies.get, + ) + + +class PoliciesResourceWithStreamingResponse: + def __init__(self, policies: PoliciesResource) -> None: + self._policies = policies + + self.create = to_streamed_response_wrapper( + policies.create, + ) + self.update = to_streamed_response_wrapper( + policies.update, + ) + self.list = to_streamed_response_wrapper( + policies.list, + ) + self.delete = to_streamed_response_wrapper( + policies.delete, + ) + self.get = to_streamed_response_wrapper( + policies.get, + ) + + +class AsyncPoliciesResourceWithStreamingResponse: + def __init__(self, policies: AsyncPoliciesResource) -> None: + self._policies = policies + + self.create = async_to_streamed_response_wrapper( + policies.create, + ) + self.update = async_to_streamed_response_wrapper( + policies.update, + ) + self.list = async_to_streamed_response_wrapper( + policies.list, + ) + self.delete = async_to_streamed_response_wrapper( + policies.delete, + ) + self.get = async_to_streamed_response_wrapper( + policies.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/bookmarks.py b/src/cloudflare/resources/zero_trust/access/bookmarks.py new file mode 100644 index 00000000000..f6d07c482c2 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/bookmarks.py @@ -0,0 +1,548 @@ +# 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 ...._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 ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.zero_trust.access import bookmark_create_params, bookmark_update_params +from ....types.zero_trust.access.bookmark import Bookmark +from ....types.zero_trust.access.bookmark_delete_response import BookmarkDeleteResponse + +__all__ = ["BookmarksResource", "AsyncBookmarksResource"] + + +class BookmarksResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> BookmarksResourceWithRawResponse: + return BookmarksResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BookmarksResourceWithStreamingResponse: + return BookmarksResourceWithStreamingResponse(self) + + def create( + self, + bookmark_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Bookmark]: + """ + Create a new Bookmark application. + + Args: + bookmark_id: UUID + + 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 bookmark_id: + raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") + return self._post( + f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + body=maybe_transform(body, bookmark_create_params.BookmarkCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, + ), + cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), + ) + + def update( + self, + bookmark_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Bookmark]: + """ + Updates a configured Bookmark application. + + Args: + bookmark_id: UUID + + 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 bookmark_id: + raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") + return self._put( + f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + body=maybe_transform(body, bookmark_update_params.BookmarkUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, + ), + cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), + ) + + 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[Bookmark]: + """ + Lists Bookmark applications. + + 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}/access/bookmarks", + page=SyncSinglePage[Bookmark], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=Bookmark, + ) + + def delete( + self, + bookmark_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[BookmarkDeleteResponse]: + """ + Deletes a Bookmark application. + + Args: + bookmark_id: UUID + + 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 bookmark_id: + raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") + return self._delete( + f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BookmarkDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[BookmarkDeleteResponse]], ResultWrapper[BookmarkDeleteResponse]), + ) + + def get( + self, + bookmark_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[Bookmark]: + """ + Fetches a single Bookmark application. + + Args: + bookmark_id: UUID + + 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 bookmark_id: + raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") + return self._get( + f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, + ), + cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), + ) + + +class AsyncBookmarksResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncBookmarksResourceWithRawResponse: + return AsyncBookmarksResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBookmarksResourceWithStreamingResponse: + return AsyncBookmarksResourceWithStreamingResponse(self) + + async def create( + self, + bookmark_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Bookmark]: + """ + Create a new Bookmark application. + + Args: + bookmark_id: UUID + + 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 bookmark_id: + raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") + return await self._post( + f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + body=await async_maybe_transform(body, bookmark_create_params.BookmarkCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, + ), + cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), + ) + + async def update( + self, + bookmark_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Bookmark]: + """ + Updates a configured Bookmark application. + + Args: + bookmark_id: UUID + + 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 bookmark_id: + raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") + return await self._put( + f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + body=await async_maybe_transform(body, bookmark_update_params.BookmarkUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, + ), + cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), + ) + + 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[Bookmark, AsyncSinglePage[Bookmark]]: + """ + Lists Bookmark applications. + + 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}/access/bookmarks", + page=AsyncSinglePage[Bookmark], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=Bookmark, + ) + + async def delete( + self, + bookmark_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[BookmarkDeleteResponse]: + """ + Deletes a Bookmark application. + + Args: + bookmark_id: UUID + + 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 bookmark_id: + raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") + return await self._delete( + f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BookmarkDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[BookmarkDeleteResponse]], ResultWrapper[BookmarkDeleteResponse]), + ) + + async def get( + self, + bookmark_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[Bookmark]: + """ + Fetches a single Bookmark application. + + Args: + bookmark_id: UUID + + 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 bookmark_id: + raise ValueError(f"Expected a non-empty value for `bookmark_id` but received {bookmark_id!r}") + return await self._get( + f"/accounts/{account_id}/access/bookmarks/{bookmark_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Bookmark]]._unwrapper, + ), + cast_to=cast(Type[Optional[Bookmark]], ResultWrapper[Bookmark]), + ) + + +class BookmarksResourceWithRawResponse: + def __init__(self, bookmarks: BookmarksResource) -> None: + self._bookmarks = bookmarks + + self.create = to_raw_response_wrapper( + bookmarks.create, + ) + self.update = to_raw_response_wrapper( + bookmarks.update, + ) + self.list = to_raw_response_wrapper( + bookmarks.list, + ) + self.delete = to_raw_response_wrapper( + bookmarks.delete, + ) + self.get = to_raw_response_wrapper( + bookmarks.get, + ) + + +class AsyncBookmarksResourceWithRawResponse: + def __init__(self, bookmarks: AsyncBookmarksResource) -> None: + self._bookmarks = bookmarks + + self.create = async_to_raw_response_wrapper( + bookmarks.create, + ) + self.update = async_to_raw_response_wrapper( + bookmarks.update, + ) + self.list = async_to_raw_response_wrapper( + bookmarks.list, + ) + self.delete = async_to_raw_response_wrapper( + bookmarks.delete, + ) + self.get = async_to_raw_response_wrapper( + bookmarks.get, + ) + + +class BookmarksResourceWithStreamingResponse: + def __init__(self, bookmarks: BookmarksResource) -> None: + self._bookmarks = bookmarks + + self.create = to_streamed_response_wrapper( + bookmarks.create, + ) + self.update = to_streamed_response_wrapper( + bookmarks.update, + ) + self.list = to_streamed_response_wrapper( + bookmarks.list, + ) + self.delete = to_streamed_response_wrapper( + bookmarks.delete, + ) + self.get = to_streamed_response_wrapper( + bookmarks.get, + ) + + +class AsyncBookmarksResourceWithStreamingResponse: + def __init__(self, bookmarks: AsyncBookmarksResource) -> None: + self._bookmarks = bookmarks + + self.create = async_to_streamed_response_wrapper( + bookmarks.create, + ) + self.update = async_to_streamed_response_wrapper( + bookmarks.update, + ) + self.list = async_to_streamed_response_wrapper( + bookmarks.list, + ) + self.delete = async_to_streamed_response_wrapper( + bookmarks.delete, + ) + self.get = async_to_streamed_response_wrapper( + bookmarks.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/certificates/certificates.py b/src/cloudflare/resources/zero_trust/access/certificates/certificates.py index a7e07081133..3bcae016b10 100644 --- a/src/cloudflare/resources/zero_trust/access/certificates/certificates.py +++ b/src/cloudflare/resources/zero_trust/access/certificates/certificates.py @@ -33,9 +33,10 @@ AsyncPaginator, make_request_options, ) -from .....types.zero_trust.access import certificate_create_params +from .....types.zero_trust.access import certificate_create_params, certificate_update_params from .....types.zero_trust.access.certificate import Certificate from .....types.zero_trust.access.associated_hostnames import AssociatedHostnames +from .....types.zero_trust.access.certificate_delete_response import CertificateDeleteResponse __all__ = ["CertificatesResource", "AsyncCertificatesResource"] @@ -122,6 +123,76 @@ def create( cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), ) + def update( + self, + certificate_id: str, + *, + associated_hostnames: List[AssociatedHostnames], + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + name: 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[Certificate]: + """ + Updates a configured mTLS certificate. + + Args: + certificate_id: UUID + + associated_hostnames: The hostnames of the applications that will use this certificate. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + name: The name of the certificate. + + 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 certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + body=maybe_transform( + { + "associated_hostnames": associated_hostnames, + "name": name, + }, + certificate_update_params.CertificateUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Certificate]]._unwrapper, + ), + cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), + ) + def list( self, *, @@ -171,6 +242,120 @@ def list( model=Certificate, ) + def delete( + self, + certificate_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CertificateDeleteResponse]: + """ + Deletes an mTLS certificate. + + Args: + certificate_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CertificateDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CertificateDeleteResponse]], ResultWrapper[CertificateDeleteResponse]), + ) + + def get( + self, + certificate_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Certificate]: + """ + Fetches a single mTLS certificate. + + Args: + certificate_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Certificate]]._unwrapper, + ), + cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), + ) + class AsyncCertificatesResource(AsyncAPIResource): @cached_property @@ -254,6 +439,76 @@ async def create( cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), ) + async def update( + self, + certificate_id: str, + *, + associated_hostnames: List[AssociatedHostnames], + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + name: 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[Certificate]: + """ + Updates a configured mTLS certificate. + + Args: + certificate_id: UUID + + associated_hostnames: The hostnames of the applications that will use this certificate. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + name: The name of the certificate. + + 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 certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + body=await async_maybe_transform( + { + "associated_hostnames": associated_hostnames, + "name": name, + }, + certificate_update_params.CertificateUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Certificate]]._unwrapper, + ), + cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), + ) + def list( self, *, @@ -303,6 +558,120 @@ def list( model=Certificate, ) + async def delete( + self, + certificate_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CertificateDeleteResponse]: + """ + Deletes an mTLS certificate. + + Args: + certificate_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CertificateDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CertificateDeleteResponse]], ResultWrapper[CertificateDeleteResponse]), + ) + + async def get( + self, + certificate_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[Certificate]: + """ + Fetches a single mTLS certificate. + + Args: + certificate_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/certificates/{certificate_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Certificate]]._unwrapper, + ), + cast_to=cast(Type[Optional[Certificate]], ResultWrapper[Certificate]), + ) + class CertificatesResourceWithRawResponse: def __init__(self, certificates: CertificatesResource) -> None: @@ -311,9 +680,18 @@ def __init__(self, certificates: CertificatesResource) -> None: self.create = to_raw_response_wrapper( certificates.create, ) + self.update = to_raw_response_wrapper( + certificates.update, + ) self.list = to_raw_response_wrapper( certificates.list, ) + self.delete = to_raw_response_wrapper( + certificates.delete, + ) + self.get = to_raw_response_wrapper( + certificates.get, + ) @cached_property def settings(self) -> SettingsResourceWithRawResponse: @@ -327,9 +705,18 @@ def __init__(self, certificates: AsyncCertificatesResource) -> None: self.create = async_to_raw_response_wrapper( certificates.create, ) + self.update = async_to_raw_response_wrapper( + certificates.update, + ) self.list = async_to_raw_response_wrapper( certificates.list, ) + self.delete = async_to_raw_response_wrapper( + certificates.delete, + ) + self.get = async_to_raw_response_wrapper( + certificates.get, + ) @cached_property def settings(self) -> AsyncSettingsResourceWithRawResponse: @@ -343,9 +730,18 @@ def __init__(self, certificates: CertificatesResource) -> None: self.create = to_streamed_response_wrapper( certificates.create, ) + self.update = to_streamed_response_wrapper( + certificates.update, + ) self.list = to_streamed_response_wrapper( certificates.list, ) + self.delete = to_streamed_response_wrapper( + certificates.delete, + ) + self.get = to_streamed_response_wrapper( + certificates.get, + ) @cached_property def settings(self) -> SettingsResourceWithStreamingResponse: @@ -359,9 +755,18 @@ def __init__(self, certificates: AsyncCertificatesResource) -> None: self.create = async_to_streamed_response_wrapper( certificates.create, ) + self.update = async_to_streamed_response_wrapper( + certificates.update, + ) self.list = async_to_streamed_response_wrapper( certificates.list, ) + self.delete = async_to_streamed_response_wrapper( + certificates.delete, + ) + self.get = async_to_streamed_response_wrapper( + certificates.get, + ) @cached_property def settings(self) -> AsyncSettingsResourceWithStreamingResponse: diff --git a/src/cloudflare/resources/zero_trust/access/custom_pages.py b/src/cloudflare/resources/zero_trust/access/custom_pages.py new file mode 100644 index 00000000000..d7eae2f7f7d --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/custom_pages.py @@ -0,0 +1,636 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.zero_trust.access import custom_page_create_params, custom_page_update_params +from ....types.zero_trust.access.custom_page import CustomPage +from ....types.zero_trust.access.custom_page_without_html import CustomPageWithoutHTML +from ....types.zero_trust.access.custom_page_delete_response import CustomPageDeleteResponse + +__all__ = ["CustomPagesResource", "AsyncCustomPagesResource"] + + +class CustomPagesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> CustomPagesResourceWithRawResponse: + return CustomPagesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CustomPagesResourceWithStreamingResponse: + return CustomPagesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + custom_html: str, + name: str, + type: Literal["identity_denied", "forbidden"], + app_count: int | 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[CustomPageWithoutHTML]: + """ + Create a custom page + + Args: + account_id: Identifier + + custom_html: Custom page HTML. + + name: Custom page name. + + type: Custom page type. + + app_count: Number of apps the custom page is assigned to. + + 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}/access/custom_pages", + body=maybe_transform( + { + "custom_html": custom_html, + "name": name, + "type": type, + "app_count": app_count, + }, + custom_page_create_params.CustomPageCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), + ) + + def update( + self, + custom_page_id: str, + *, + account_id: str, + custom_html: str, + name: str, + type: Literal["identity_denied", "forbidden"], + app_count: int | 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[CustomPageWithoutHTML]: + """ + Update a custom page + + Args: + account_id: Identifier + + custom_page_id: UUID + + custom_html: Custom page HTML. + + name: Custom page name. + + type: Custom page type. + + app_count: Number of apps the custom page is assigned to. + + 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 custom_page_id: + raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") + return self._put( + f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + body=maybe_transform( + { + "custom_html": custom_html, + "name": name, + "type": type, + "app_count": app_count, + }, + custom_page_update_params.CustomPageUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), + ) + + 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[CustomPageWithoutHTML]: + """ + List custom pages + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/custom_pages", + page=SyncSinglePage[CustomPageWithoutHTML], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=CustomPageWithoutHTML, + ) + + def delete( + self, + custom_page_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[CustomPageDeleteResponse]: + """ + Delete a custom page + + Args: + account_id: Identifier + + custom_page_id: UUID + + 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 custom_page_id: + raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") + return self._delete( + f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPageDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPageDeleteResponse]], ResultWrapper[CustomPageDeleteResponse]), + ) + + def get( + self, + custom_page_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[CustomPage]: + """ + Fetches a custom page and also returns its HTML. + + Args: + account_id: Identifier + + custom_page_id: UUID + + 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 custom_page_id: + raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") + return self._get( + f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPage]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPage]], ResultWrapper[CustomPage]), + ) + + +class AsyncCustomPagesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncCustomPagesResourceWithRawResponse: + return AsyncCustomPagesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCustomPagesResourceWithStreamingResponse: + return AsyncCustomPagesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + custom_html: str, + name: str, + type: Literal["identity_denied", "forbidden"], + app_count: int | 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[CustomPageWithoutHTML]: + """ + Create a custom page + + Args: + account_id: Identifier + + custom_html: Custom page HTML. + + name: Custom page name. + + type: Custom page type. + + app_count: Number of apps the custom page is assigned to. + + 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}/access/custom_pages", + body=await async_maybe_transform( + { + "custom_html": custom_html, + "name": name, + "type": type, + "app_count": app_count, + }, + custom_page_create_params.CustomPageCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), + ) + + async def update( + self, + custom_page_id: str, + *, + account_id: str, + custom_html: str, + name: str, + type: Literal["identity_denied", "forbidden"], + app_count: int | 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[CustomPageWithoutHTML]: + """ + Update a custom page + + Args: + account_id: Identifier + + custom_page_id: UUID + + custom_html: Custom page HTML. + + name: Custom page name. + + type: Custom page type. + + app_count: Number of apps the custom page is assigned to. + + 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 custom_page_id: + raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") + return await self._put( + f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + body=await async_maybe_transform( + { + "custom_html": custom_html, + "name": name, + "type": type, + "app_count": app_count, + }, + custom_page_update_params.CustomPageUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPageWithoutHTML]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPageWithoutHTML]], ResultWrapper[CustomPageWithoutHTML]), + ) + + 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[CustomPageWithoutHTML, AsyncSinglePage[CustomPageWithoutHTML]]: + """ + List custom pages + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/custom_pages", + page=AsyncSinglePage[CustomPageWithoutHTML], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=CustomPageWithoutHTML, + ) + + async def delete( + self, + custom_page_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[CustomPageDeleteResponse]: + """ + Delete a custom page + + Args: + account_id: Identifier + + custom_page_id: UUID + + 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 custom_page_id: + raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") + return await self._delete( + f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPageDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPageDeleteResponse]], ResultWrapper[CustomPageDeleteResponse]), + ) + + async def get( + self, + custom_page_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[CustomPage]: + """ + Fetches a custom page and also returns its HTML. + + Args: + account_id: Identifier + + custom_page_id: UUID + + 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 custom_page_id: + raise ValueError(f"Expected a non-empty value for `custom_page_id` but received {custom_page_id!r}") + return await self._get( + f"/accounts/{account_id}/access/custom_pages/{custom_page_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomPage]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomPage]], ResultWrapper[CustomPage]), + ) + + +class CustomPagesResourceWithRawResponse: + def __init__(self, custom_pages: CustomPagesResource) -> None: + self._custom_pages = custom_pages + + self.create = to_raw_response_wrapper( + custom_pages.create, + ) + self.update = to_raw_response_wrapper( + custom_pages.update, + ) + self.list = to_raw_response_wrapper( + custom_pages.list, + ) + self.delete = to_raw_response_wrapper( + custom_pages.delete, + ) + self.get = to_raw_response_wrapper( + custom_pages.get, + ) + + +class AsyncCustomPagesResourceWithRawResponse: + def __init__(self, custom_pages: AsyncCustomPagesResource) -> None: + self._custom_pages = custom_pages + + self.create = async_to_raw_response_wrapper( + custom_pages.create, + ) + self.update = async_to_raw_response_wrapper( + custom_pages.update, + ) + self.list = async_to_raw_response_wrapper( + custom_pages.list, + ) + self.delete = async_to_raw_response_wrapper( + custom_pages.delete, + ) + self.get = async_to_raw_response_wrapper( + custom_pages.get, + ) + + +class CustomPagesResourceWithStreamingResponse: + def __init__(self, custom_pages: CustomPagesResource) -> None: + self._custom_pages = custom_pages + + self.create = to_streamed_response_wrapper( + custom_pages.create, + ) + self.update = to_streamed_response_wrapper( + custom_pages.update, + ) + self.list = to_streamed_response_wrapper( + custom_pages.list, + ) + self.delete = to_streamed_response_wrapper( + custom_pages.delete, + ) + self.get = to_streamed_response_wrapper( + custom_pages.get, + ) + + +class AsyncCustomPagesResourceWithStreamingResponse: + def __init__(self, custom_pages: AsyncCustomPagesResource) -> None: + self._custom_pages = custom_pages + + self.create = async_to_streamed_response_wrapper( + custom_pages.create, + ) + self.update = async_to_streamed_response_wrapper( + custom_pages.update, + ) + self.list = async_to_streamed_response_wrapper( + custom_pages.list, + ) + self.delete = async_to_streamed_response_wrapper( + custom_pages.delete, + ) + self.get = async_to_streamed_response_wrapper( + custom_pages.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/groups.py b/src/cloudflare/resources/zero_trust/access/groups.py index 74f6f4a066d..8b9ee6bf716 100644 --- a/src/cloudflare/resources/zero_trust/access/groups.py +++ b/src/cloudflare/resources/zero_trust/access/groups.py @@ -25,9 +25,10 @@ AsyncPaginator, make_request_options, ) -from ....types.zero_trust.access import group_create_params +from ....types.zero_trust.access import group_create_params, group_update_params from ....types.zero_trust.access_rule_param import AccessRuleParam from ....types.zero_trust.access.zero_trust_group import ZeroTrustGroup +from ....types.zero_trust.access.group_delete_response import GroupDeleteResponse __all__ = ["GroupsResource", "AsyncGroupsResource"] @@ -121,6 +122,91 @@ def create( cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), ) + def update( + self, + group_id: str, + *, + include: Iterable[AccessRuleParam], + name: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + is_default: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | 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[ZeroTrustGroup]: + """ + Updates a configured Access group. + + Args: + group_id: UUID + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access group. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + exclude: Rules evaluated with a NOT logical operator. To match a policy, a user cannot + meet any of the Exclude rules. + + is_default: Whether this is the default group + + require: Rules evaluated with an AND logical operator. To match a policy, a user must + meet all of the Require rules. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not group_id: + raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + body=maybe_transform( + { + "include": include, + "name": name, + "exclude": exclude, + "is_default": is_default, + "require": require, + }, + group_update_params.GroupUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZeroTrustGroup]]._unwrapper, + ), + cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), + ) + def list( self, *, @@ -170,6 +256,120 @@ def list( model=ZeroTrustGroup, ) + def delete( + self, + group_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[GroupDeleteResponse]: + """ + Deletes an Access group. + + Args: + group_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not group_id: + raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[GroupDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[GroupDeleteResponse]], ResultWrapper[GroupDeleteResponse]), + ) + + def get( + self, + group_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ZeroTrustGroup]: + """ + Fetches a single Access group. + + Args: + group_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not group_id: + raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZeroTrustGroup]]._unwrapper, + ), + cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), + ) + class AsyncGroupsResource(AsyncAPIResource): @cached_property @@ -260,6 +460,91 @@ async def create( cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), ) + async def update( + self, + group_id: str, + *, + include: Iterable[AccessRuleParam], + name: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + is_default: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | 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[ZeroTrustGroup]: + """ + Updates a configured Access group. + + Args: + group_id: UUID + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access group. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + exclude: Rules evaluated with a NOT logical operator. To match a policy, a user cannot + meet any of the Exclude rules. + + is_default: Whether this is the default group + + require: Rules evaluated with an AND logical operator. To match a policy, a user must + meet all of the Require rules. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not group_id: + raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + body=await async_maybe_transform( + { + "include": include, + "name": name, + "exclude": exclude, + "is_default": is_default, + "require": require, + }, + group_update_params.GroupUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZeroTrustGroup]]._unwrapper, + ), + cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), + ) + def list( self, *, @@ -309,6 +594,120 @@ def list( model=ZeroTrustGroup, ) + async def delete( + self, + group_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[GroupDeleteResponse]: + """ + Deletes an Access group. + + Args: + group_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not group_id: + raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[GroupDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[GroupDeleteResponse]], ResultWrapper[GroupDeleteResponse]), + ) + + async def get( + self, + group_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ZeroTrustGroup]: + """ + Fetches a single Access group. + + Args: + group_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not group_id: + raise ValueError(f"Expected a non-empty value for `group_id` but received {group_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/groups/{group_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZeroTrustGroup]]._unwrapper, + ), + cast_to=cast(Type[Optional[ZeroTrustGroup]], ResultWrapper[ZeroTrustGroup]), + ) + class GroupsResourceWithRawResponse: def __init__(self, groups: GroupsResource) -> None: @@ -317,9 +716,18 @@ def __init__(self, groups: GroupsResource) -> None: self.create = to_raw_response_wrapper( groups.create, ) + self.update = to_raw_response_wrapper( + groups.update, + ) self.list = to_raw_response_wrapper( groups.list, ) + self.delete = to_raw_response_wrapper( + groups.delete, + ) + self.get = to_raw_response_wrapper( + groups.get, + ) class AsyncGroupsResourceWithRawResponse: @@ -329,9 +737,18 @@ def __init__(self, groups: AsyncGroupsResource) -> None: self.create = async_to_raw_response_wrapper( groups.create, ) + self.update = async_to_raw_response_wrapper( + groups.update, + ) self.list = async_to_raw_response_wrapper( groups.list, ) + self.delete = async_to_raw_response_wrapper( + groups.delete, + ) + self.get = async_to_raw_response_wrapper( + groups.get, + ) class GroupsResourceWithStreamingResponse: @@ -341,9 +758,18 @@ def __init__(self, groups: GroupsResource) -> None: self.create = to_streamed_response_wrapper( groups.create, ) + self.update = to_streamed_response_wrapper( + groups.update, + ) self.list = to_streamed_response_wrapper( groups.list, ) + self.delete = to_streamed_response_wrapper( + groups.delete, + ) + self.get = to_streamed_response_wrapper( + groups.get, + ) class AsyncGroupsResourceWithStreamingResponse: @@ -353,6 +779,15 @@ def __init__(self, groups: AsyncGroupsResource) -> None: self.create = async_to_streamed_response_wrapper( groups.create, ) + self.update = async_to_streamed_response_wrapper( + groups.update, + ) self.list = async_to_streamed_response_wrapper( groups.list, ) + self.delete = async_to_streamed_response_wrapper( + groups.delete, + ) + self.get = async_to_streamed_response_wrapper( + groups.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/keys.py b/src/cloudflare/resources/zero_trust/access/keys.py new file mode 100644 index 00000000000..ac04e6b775d --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/keys.py @@ -0,0 +1,387 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, 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.access import key_update_params +from ....types.zero_trust.access.key_get_response import KeyGetResponse +from ....types.zero_trust.access.key_rotate_response import KeyRotateResponse +from ....types.zero_trust.access.key_update_response import KeyUpdateResponse + +__all__ = ["KeysResource", "AsyncKeysResource"] + + +class KeysResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> KeysResourceWithRawResponse: + return KeysResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> KeysResourceWithStreamingResponse: + return KeysResourceWithStreamingResponse(self) + + def update( + self, + *, + account_id: str, + key_rotation_interval_days: float, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[KeyUpdateResponse]: + """ + Updates the Access key rotation settings for an account. + + Args: + account_id: Identifier + + key_rotation_interval_days: The number of days between key rotations. + + 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 cast( + Optional[KeyUpdateResponse], + self._put( + f"/accounts/{account_id}/access/keys", + body=maybe_transform( + {"key_rotation_interval_days": key_rotation_interval_days}, key_update_params.KeyUpdateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyUpdateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[KeyUpdateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + 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[KeyGetResponse]: + """ + Gets the Access key rotation settings for an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return cast( + Optional[KeyGetResponse], + self._get( + f"/accounts/{account_id}/access/keys", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyGetResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[KeyGetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + def rotate( + 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[KeyRotateResponse]: + """ + Perfoms a key rotation for an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return cast( + Optional[KeyRotateResponse], + self._post( + f"/accounts/{account_id}/access/keys/rotate", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyRotateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[KeyRotateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AsyncKeysResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncKeysResourceWithRawResponse: + return AsyncKeysResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncKeysResourceWithStreamingResponse: + return AsyncKeysResourceWithStreamingResponse(self) + + async def update( + self, + *, + account_id: str, + key_rotation_interval_days: float, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[KeyUpdateResponse]: + """ + Updates the Access key rotation settings for an account. + + Args: + account_id: Identifier + + key_rotation_interval_days: The number of days between key rotations. + + 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 cast( + Optional[KeyUpdateResponse], + await self._put( + f"/accounts/{account_id}/access/keys", + body=await async_maybe_transform( + {"key_rotation_interval_days": key_rotation_interval_days}, key_update_params.KeyUpdateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyUpdateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[KeyUpdateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + 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[KeyGetResponse]: + """ + Gets the Access key rotation settings for an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return cast( + Optional[KeyGetResponse], + await self._get( + f"/accounts/{account_id}/access/keys", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyGetResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[KeyGetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + async def rotate( + 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[KeyRotateResponse]: + """ + Perfoms a key rotation for an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return cast( + Optional[KeyRotateResponse], + await self._post( + f"/accounts/{account_id}/access/keys/rotate", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[KeyRotateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[KeyRotateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class KeysResourceWithRawResponse: + def __init__(self, keys: KeysResource) -> None: + self._keys = keys + + self.update = to_raw_response_wrapper( + keys.update, + ) + self.get = to_raw_response_wrapper( + keys.get, + ) + self.rotate = to_raw_response_wrapper( + keys.rotate, + ) + + +class AsyncKeysResourceWithRawResponse: + def __init__(self, keys: AsyncKeysResource) -> None: + self._keys = keys + + self.update = async_to_raw_response_wrapper( + keys.update, + ) + self.get = async_to_raw_response_wrapper( + keys.get, + ) + self.rotate = async_to_raw_response_wrapper( + keys.rotate, + ) + + +class KeysResourceWithStreamingResponse: + def __init__(self, keys: KeysResource) -> None: + self._keys = keys + + self.update = to_streamed_response_wrapper( + keys.update, + ) + self.get = to_streamed_response_wrapper( + keys.get, + ) + self.rotate = to_streamed_response_wrapper( + keys.rotate, + ) + + +class AsyncKeysResourceWithStreamingResponse: + def __init__(self, keys: AsyncKeysResource) -> None: + self._keys = keys + + self.update = async_to_streamed_response_wrapper( + keys.update, + ) + self.get = async_to_streamed_response_wrapper( + keys.get, + ) + self.rotate = async_to_streamed_response_wrapper( + keys.rotate, + ) diff --git a/src/cloudflare/resources/zero_trust/access/logs/__init__.py b/src/cloudflare/resources/zero_trust/access/logs/__init__.py new file mode 100644 index 00000000000..7479c1fbef8 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/logs/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .logs import ( + LogsResource, + AsyncLogsResource, + LogsResourceWithRawResponse, + AsyncLogsResourceWithRawResponse, + LogsResourceWithStreamingResponse, + AsyncLogsResourceWithStreamingResponse, +) +from .access_requests import ( + AccessRequestsResource, + AsyncAccessRequestsResource, + AccessRequestsResourceWithRawResponse, + AsyncAccessRequestsResourceWithRawResponse, + AccessRequestsResourceWithStreamingResponse, + AsyncAccessRequestsResourceWithStreamingResponse, +) + +__all__ = [ + "AccessRequestsResource", + "AsyncAccessRequestsResource", + "AccessRequestsResourceWithRawResponse", + "AsyncAccessRequestsResourceWithRawResponse", + "AccessRequestsResourceWithStreamingResponse", + "AsyncAccessRequestsResourceWithStreamingResponse", + "LogsResource", + "AsyncLogsResource", + "LogsResourceWithRawResponse", + "AsyncLogsResourceWithRawResponse", + "LogsResourceWithStreamingResponse", + "AsyncLogsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py new file mode 100644 index 00000000000..9b90990d9cc --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py @@ -0,0 +1,158 @@ +# 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.access.logs.access_request_list_response import AccessRequestListResponse + +__all__ = ["AccessRequestsResource", "AsyncAccessRequestsResource"] + + +class AccessRequestsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AccessRequestsResourceWithRawResponse: + return AccessRequestsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AccessRequestsResourceWithStreamingResponse: + return AccessRequestsResourceWithStreamingResponse(self) + + 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, + ) -> Optional[AccessRequestListResponse]: + """ + Gets a list of Access authentication audit logs for an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/logs/access_requests", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AccessRequestListResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AccessRequestListResponse]], ResultWrapper[AccessRequestListResponse]), + ) + + +class AsyncAccessRequestsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAccessRequestsResourceWithRawResponse: + return AsyncAccessRequestsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAccessRequestsResourceWithStreamingResponse: + return AsyncAccessRequestsResourceWithStreamingResponse(self) + + async 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, + ) -> Optional[AccessRequestListResponse]: + """ + Gets a list of Access authentication audit logs for an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/logs/access_requests", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AccessRequestListResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AccessRequestListResponse]], ResultWrapper[AccessRequestListResponse]), + ) + + +class AccessRequestsResourceWithRawResponse: + def __init__(self, access_requests: AccessRequestsResource) -> None: + self._access_requests = access_requests + + self.list = to_raw_response_wrapper( + access_requests.list, + ) + + +class AsyncAccessRequestsResourceWithRawResponse: + def __init__(self, access_requests: AsyncAccessRequestsResource) -> None: + self._access_requests = access_requests + + self.list = async_to_raw_response_wrapper( + access_requests.list, + ) + + +class AccessRequestsResourceWithStreamingResponse: + def __init__(self, access_requests: AccessRequestsResource) -> None: + self._access_requests = access_requests + + self.list = to_streamed_response_wrapper( + access_requests.list, + ) + + +class AsyncAccessRequestsResourceWithStreamingResponse: + def __init__(self, access_requests: AsyncAccessRequestsResource) -> None: + self._access_requests = access_requests + + self.list = async_to_streamed_response_wrapper( + access_requests.list, + ) diff --git a/src/cloudflare/resources/zero_trust/access/logs/logs.py b/src/cloudflare/resources/zero_trust/access/logs/logs.py new file mode 100644 index 00000000000..39226d42917 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/logs/logs.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from .access_requests import ( + AccessRequestsResource, + AsyncAccessRequestsResource, + AccessRequestsResourceWithRawResponse, + AsyncAccessRequestsResourceWithRawResponse, + AccessRequestsResourceWithStreamingResponse, + AsyncAccessRequestsResourceWithStreamingResponse, +) + +__all__ = ["LogsResource", "AsyncLogsResource"] + + +class LogsResource(SyncAPIResource): + @cached_property + def access_requests(self) -> AccessRequestsResource: + return AccessRequestsResource(self._client) + + @cached_property + def with_raw_response(self) -> LogsResourceWithRawResponse: + return LogsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LogsResourceWithStreamingResponse: + return LogsResourceWithStreamingResponse(self) + + +class AsyncLogsResource(AsyncAPIResource): + @cached_property + def access_requests(self) -> AsyncAccessRequestsResource: + return AsyncAccessRequestsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncLogsResourceWithRawResponse: + return AsyncLogsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLogsResourceWithStreamingResponse: + return AsyncLogsResourceWithStreamingResponse(self) + + +class LogsResourceWithRawResponse: + def __init__(self, logs: LogsResource) -> None: + self._logs = logs + + @cached_property + def access_requests(self) -> AccessRequestsResourceWithRawResponse: + return AccessRequestsResourceWithRawResponse(self._logs.access_requests) + + +class AsyncLogsResourceWithRawResponse: + def __init__(self, logs: AsyncLogsResource) -> None: + self._logs = logs + + @cached_property + def access_requests(self) -> AsyncAccessRequestsResourceWithRawResponse: + return AsyncAccessRequestsResourceWithRawResponse(self._logs.access_requests) + + +class LogsResourceWithStreamingResponse: + def __init__(self, logs: LogsResource) -> None: + self._logs = logs + + @cached_property + def access_requests(self) -> AccessRequestsResourceWithStreamingResponse: + return AccessRequestsResourceWithStreamingResponse(self._logs.access_requests) + + +class AsyncLogsResourceWithStreamingResponse: + def __init__(self, logs: AsyncLogsResource) -> None: + self._logs = logs + + @cached_property + def access_requests(self) -> AsyncAccessRequestsResourceWithStreamingResponse: + return AsyncAccessRequestsResourceWithStreamingResponse(self._logs.access_requests) diff --git a/src/cloudflare/resources/zero_trust/access/service_tokens.py b/src/cloudflare/resources/zero_trust/access/service_tokens.py index 679b675fdaa..066ae6dc2ac 100644 --- a/src/cloudflare/resources/zero_trust/access/service_tokens.py +++ b/src/cloudflare/resources/zero_trust/access/service_tokens.py @@ -25,9 +25,10 @@ AsyncPaginator, make_request_options, ) -from ....types.zero_trust.access import service_token_create_params +from ....types.zero_trust.access import service_token_create_params, service_token_update_params from ....types.zero_trust.access.service_token import ServiceToken from ....types.zero_trust.access.service_token_create_response import ServiceTokenCreateResponse +from ....types.zero_trust.access.service_token_rotate_response import ServiceTokenRotateResponse __all__ = ["ServiceTokensResource", "AsyncServiceTokensResource"] @@ -111,6 +112,78 @@ def create( cast_to=cast(Type[Optional[ServiceTokenCreateResponse]], ResultWrapper[ServiceTokenCreateResponse]), ) + def update( + self, + service_token_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + duration: str | NotGiven = NOT_GIVEN, + name: 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[ServiceToken]: + """ + Updates a configured service token. + + Args: + service_token_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + duration: The duration for how long the service token will be valid. Must be in the format + `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The + default is 1 year in hours (8760h). + + name: The name of the service token. + + 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 service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + body=maybe_transform( + { + "duration": duration, + "name": name, + }, + service_token_update_params.ServiceTokenUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + def list( self, *, @@ -160,6 +233,208 @@ def list( model=ServiceToken, ) + def delete( + self, + service_token_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ServiceToken]: + """ + Deletes a service token. + + Args: + service_token_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + + def get( + self, + service_token_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ServiceToken]: + """ + Fetches a single service token. + + Args: + service_token_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + + def refresh( + self, + service_token_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[ServiceToken]: + """ + Refreshes the expiration of a service token. + + Args: + account_id: Identifier + + service_token_id: UUID + + 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 service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + return self._post( + f"/accounts/{account_id}/access/service_tokens/{service_token_id}/refresh", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + + def rotate( + self, + service_token_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[ServiceTokenRotateResponse]: + """ + Generates a new Client Secret for a service token and revokes the old one. + + Args: + account_id: Identifier + + service_token_id: UUID + + 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 service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + return self._post( + f"/accounts/{account_id}/access/service_tokens/{service_token_id}/rotate", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceTokenRotateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceTokenRotateResponse]], ResultWrapper[ServiceTokenRotateResponse]), + ) + class AsyncServiceTokensResource(AsyncAPIResource): @cached_property @@ -240,6 +515,78 @@ async def create( cast_to=cast(Type[Optional[ServiceTokenCreateResponse]], ResultWrapper[ServiceTokenCreateResponse]), ) + async def update( + self, + service_token_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + duration: str | NotGiven = NOT_GIVEN, + name: 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[ServiceToken]: + """ + Updates a configured service token. + + Args: + service_token_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + duration: The duration for how long the service token will be valid. Must be in the format + `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The + default is 1 year in hours (8760h). + + name: The name of the service token. + + 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 service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + body=await async_maybe_transform( + { + "duration": duration, + "name": name, + }, + service_token_update_params.ServiceTokenUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + def list( self, *, @@ -289,6 +636,208 @@ def list( model=ServiceToken, ) + async def delete( + self, + service_token_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ServiceToken]: + """ + Deletes a service token. + + Args: + service_token_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + + async def get( + self, + service_token_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ServiceToken]: + """ + Fetches a single service token. + + Args: + service_token_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/service_tokens/{service_token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + + async def refresh( + self, + service_token_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[ServiceToken]: + """ + Refreshes the expiration of a service token. + + Args: + account_id: Identifier + + service_token_id: UUID + + 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 service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + return await self._post( + f"/accounts/{account_id}/access/service_tokens/{service_token_id}/refresh", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceToken]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceToken]], ResultWrapper[ServiceToken]), + ) + + async def rotate( + self, + service_token_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[ServiceTokenRotateResponse]: + """ + Generates a new Client Secret for a service token and revokes the old one. + + Args: + account_id: Identifier + + service_token_id: UUID + + 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 service_token_id: + raise ValueError(f"Expected a non-empty value for `service_token_id` but received {service_token_id!r}") + return await self._post( + f"/accounts/{account_id}/access/service_tokens/{service_token_id}/rotate", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ServiceTokenRotateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ServiceTokenRotateResponse]], ResultWrapper[ServiceTokenRotateResponse]), + ) + class ServiceTokensResourceWithRawResponse: def __init__(self, service_tokens: ServiceTokensResource) -> None: @@ -297,9 +846,24 @@ def __init__(self, service_tokens: ServiceTokensResource) -> None: self.create = to_raw_response_wrapper( service_tokens.create, ) + self.update = to_raw_response_wrapper( + service_tokens.update, + ) self.list = to_raw_response_wrapper( service_tokens.list, ) + self.delete = to_raw_response_wrapper( + service_tokens.delete, + ) + self.get = to_raw_response_wrapper( + service_tokens.get, + ) + self.refresh = to_raw_response_wrapper( + service_tokens.refresh, + ) + self.rotate = to_raw_response_wrapper( + service_tokens.rotate, + ) class AsyncServiceTokensResourceWithRawResponse: @@ -309,9 +873,24 @@ def __init__(self, service_tokens: AsyncServiceTokensResource) -> None: self.create = async_to_raw_response_wrapper( service_tokens.create, ) + self.update = async_to_raw_response_wrapper( + service_tokens.update, + ) self.list = async_to_raw_response_wrapper( service_tokens.list, ) + self.delete = async_to_raw_response_wrapper( + service_tokens.delete, + ) + self.get = async_to_raw_response_wrapper( + service_tokens.get, + ) + self.refresh = async_to_raw_response_wrapper( + service_tokens.refresh, + ) + self.rotate = async_to_raw_response_wrapper( + service_tokens.rotate, + ) class ServiceTokensResourceWithStreamingResponse: @@ -321,9 +900,24 @@ def __init__(self, service_tokens: ServiceTokensResource) -> None: self.create = to_streamed_response_wrapper( service_tokens.create, ) + self.update = to_streamed_response_wrapper( + service_tokens.update, + ) self.list = to_streamed_response_wrapper( service_tokens.list, ) + self.delete = to_streamed_response_wrapper( + service_tokens.delete, + ) + self.get = to_streamed_response_wrapper( + service_tokens.get, + ) + self.refresh = to_streamed_response_wrapper( + service_tokens.refresh, + ) + self.rotate = to_streamed_response_wrapper( + service_tokens.rotate, + ) class AsyncServiceTokensResourceWithStreamingResponse: @@ -333,6 +927,21 @@ def __init__(self, service_tokens: AsyncServiceTokensResource) -> None: self.create = async_to_streamed_response_wrapper( service_tokens.create, ) + self.update = async_to_streamed_response_wrapper( + service_tokens.update, + ) self.list = async_to_streamed_response_wrapper( service_tokens.list, ) + self.delete = async_to_streamed_response_wrapper( + service_tokens.delete, + ) + self.get = async_to_streamed_response_wrapper( + service_tokens.get, + ) + self.refresh = async_to_streamed_response_wrapper( + service_tokens.refresh, + ) + self.rotate = async_to_streamed_response_wrapper( + service_tokens.rotate, + ) diff --git a/src/cloudflare/resources/zero_trust/access/tags.py b/src/cloudflare/resources/zero_trust/access/tags.py new file mode 100644 index 00000000000..70cc924d5c3 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/tags.py @@ -0,0 +1,566 @@ +# 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 ...._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 ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.zero_trust.access import tag_create_params, tag_update_params +from ....types.zero_trust.access.tag import Tag +from ....types.zero_trust.access.tag_delete_response import TagDeleteResponse + +__all__ = ["TagsResource", "AsyncTagsResource"] + + +class TagsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> TagsResourceWithRawResponse: + return TagsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TagsResourceWithStreamingResponse: + return TagsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + name: 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[Tag]: + """ + Create a tag + + Args: + account_id: Identifier + + name: The name of the tag + + 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}/access/tags", + body=maybe_transform({"name": name}, tag_create_params.TagCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Tag]]._unwrapper, + ), + cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), + ) + + def update( + self, + tag_name: str, + *, + account_id: str, + name: 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[Tag]: + """ + Update a tag + + Args: + account_id: Identifier + + tag_name: The name of the tag + + name: The name of the tag + + 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 tag_name: + raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") + return self._put( + f"/accounts/{account_id}/access/tags/{tag_name}", + body=maybe_transform({"name": name}, tag_update_params.TagUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Tag]]._unwrapper, + ), + cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), + ) + + 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[Tag]: + """ + List tags + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/tags", + page=SyncSinglePage[Tag], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=Tag, + ) + + def delete( + self, + tag_name: 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[TagDeleteResponse]: + """ + Delete a tag + + Args: + account_id: Identifier + + tag_name: The name of the tag + + 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 tag_name: + raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") + return self._delete( + f"/accounts/{account_id}/access/tags/{tag_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TagDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TagDeleteResponse]], ResultWrapper[TagDeleteResponse]), + ) + + def get( + self, + tag_name: 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[Tag]: + """ + Get a tag + + Args: + account_id: Identifier + + tag_name: The name of the tag + + 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 tag_name: + raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") + return self._get( + f"/accounts/{account_id}/access/tags/{tag_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Tag]]._unwrapper, + ), + cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), + ) + + +class AsyncTagsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncTagsResourceWithRawResponse: + return AsyncTagsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTagsResourceWithStreamingResponse: + return AsyncTagsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + name: 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[Tag]: + """ + Create a tag + + Args: + account_id: Identifier + + name: The name of the tag + + 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}/access/tags", + body=await async_maybe_transform({"name": name}, tag_create_params.TagCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Tag]]._unwrapper, + ), + cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), + ) + + async def update( + self, + tag_name: str, + *, + account_id: str, + name: 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[Tag]: + """ + Update a tag + + Args: + account_id: Identifier + + tag_name: The name of the tag + + name: The name of the tag + + 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 tag_name: + raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") + return await self._put( + f"/accounts/{account_id}/access/tags/{tag_name}", + body=await async_maybe_transform({"name": name}, tag_update_params.TagUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Tag]]._unwrapper, + ), + cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), + ) + + 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[Tag, AsyncSinglePage[Tag]]: + """ + List tags + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/tags", + page=AsyncSinglePage[Tag], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=Tag, + ) + + async def delete( + self, + tag_name: 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[TagDeleteResponse]: + """ + Delete a tag + + Args: + account_id: Identifier + + tag_name: The name of the tag + + 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 tag_name: + raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") + return await self._delete( + f"/accounts/{account_id}/access/tags/{tag_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[TagDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[TagDeleteResponse]], ResultWrapper[TagDeleteResponse]), + ) + + async def get( + self, + tag_name: 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[Tag]: + """ + Get a tag + + Args: + account_id: Identifier + + tag_name: The name of the tag + + 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 tag_name: + raise ValueError(f"Expected a non-empty value for `tag_name` but received {tag_name!r}") + return await self._get( + f"/accounts/{account_id}/access/tags/{tag_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Tag]]._unwrapper, + ), + cast_to=cast(Type[Optional[Tag]], ResultWrapper[Tag]), + ) + + +class TagsResourceWithRawResponse: + def __init__(self, tags: TagsResource) -> None: + self._tags = tags + + self.create = to_raw_response_wrapper( + tags.create, + ) + self.update = to_raw_response_wrapper( + tags.update, + ) + self.list = to_raw_response_wrapper( + tags.list, + ) + self.delete = to_raw_response_wrapper( + tags.delete, + ) + self.get = to_raw_response_wrapper( + tags.get, + ) + + +class AsyncTagsResourceWithRawResponse: + def __init__(self, tags: AsyncTagsResource) -> None: + self._tags = tags + + self.create = async_to_raw_response_wrapper( + tags.create, + ) + self.update = async_to_raw_response_wrapper( + tags.update, + ) + self.list = async_to_raw_response_wrapper( + tags.list, + ) + self.delete = async_to_raw_response_wrapper( + tags.delete, + ) + self.get = async_to_raw_response_wrapper( + tags.get, + ) + + +class TagsResourceWithStreamingResponse: + def __init__(self, tags: TagsResource) -> None: + self._tags = tags + + self.create = to_streamed_response_wrapper( + tags.create, + ) + self.update = to_streamed_response_wrapper( + tags.update, + ) + self.list = to_streamed_response_wrapper( + tags.list, + ) + self.delete = to_streamed_response_wrapper( + tags.delete, + ) + self.get = to_streamed_response_wrapper( + tags.get, + ) + + +class AsyncTagsResourceWithStreamingResponse: + def __init__(self, tags: AsyncTagsResource) -> None: + self._tags = tags + + self.create = async_to_streamed_response_wrapper( + tags.create, + ) + self.update = async_to_streamed_response_wrapper( + tags.update, + ) + self.list = async_to_streamed_response_wrapper( + tags.list, + ) + self.delete = async_to_streamed_response_wrapper( + tags.delete, + ) + self.get = async_to_streamed_response_wrapper( + tags.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/users/__init__.py b/src/cloudflare/resources/zero_trust/access/users/__init__.py new file mode 100644 index 00000000000..c5766c1427a --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/users/__init__.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .users import ( + UsersResource, + AsyncUsersResource, + UsersResourceWithRawResponse, + AsyncUsersResourceWithRawResponse, + UsersResourceWithStreamingResponse, + AsyncUsersResourceWithStreamingResponse, +) +from .failed_logins import ( + FailedLoginsResource, + AsyncFailedLoginsResource, + FailedLoginsResourceWithRawResponse, + AsyncFailedLoginsResourceWithRawResponse, + FailedLoginsResourceWithStreamingResponse, + AsyncFailedLoginsResourceWithStreamingResponse, +) +from .active_sessions import ( + ActiveSessionsResource, + AsyncActiveSessionsResource, + ActiveSessionsResourceWithRawResponse, + AsyncActiveSessionsResourceWithRawResponse, + ActiveSessionsResourceWithStreamingResponse, + AsyncActiveSessionsResourceWithStreamingResponse, +) +from .last_seen_identity import ( + LastSeenIdentityResource, + AsyncLastSeenIdentityResource, + LastSeenIdentityResourceWithRawResponse, + AsyncLastSeenIdentityResourceWithRawResponse, + LastSeenIdentityResourceWithStreamingResponse, + AsyncLastSeenIdentityResourceWithStreamingResponse, +) + +__all__ = [ + "ActiveSessionsResource", + "AsyncActiveSessionsResource", + "ActiveSessionsResourceWithRawResponse", + "AsyncActiveSessionsResourceWithRawResponse", + "ActiveSessionsResourceWithStreamingResponse", + "AsyncActiveSessionsResourceWithStreamingResponse", + "LastSeenIdentityResource", + "AsyncLastSeenIdentityResource", + "LastSeenIdentityResourceWithRawResponse", + "AsyncLastSeenIdentityResourceWithRawResponse", + "LastSeenIdentityResourceWithStreamingResponse", + "AsyncLastSeenIdentityResourceWithStreamingResponse", + "FailedLoginsResource", + "AsyncFailedLoginsResource", + "FailedLoginsResourceWithRawResponse", + "AsyncFailedLoginsResourceWithRawResponse", + "FailedLoginsResourceWithStreamingResponse", + "AsyncFailedLoginsResourceWithStreamingResponse", + "UsersResource", + "AsyncUsersResource", + "UsersResourceWithRawResponse", + "AsyncUsersResourceWithRawResponse", + "UsersResourceWithStreamingResponse", + "AsyncUsersResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/zero_trust/access/users/active_sessions.py b/src/cloudflare/resources/zero_trust/access/users/active_sessions.py new file mode 100644 index 00000000000..766bec75c17 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/users/active_sessions.py @@ -0,0 +1,271 @@ +# 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 .....pagination import SyncSinglePage, AsyncSinglePage +from ....._base_client import ( + AsyncPaginator, + make_request_options, +) +from .....types.zero_trust.access.users.active_session_get_response import ActiveSessionGetResponse +from .....types.zero_trust.access.users.active_session_list_response import ActiveSessionListResponse + +__all__ = ["ActiveSessionsResource", "AsyncActiveSessionsResource"] + + +class ActiveSessionsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ActiveSessionsResourceWithRawResponse: + return ActiveSessionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ActiveSessionsResourceWithStreamingResponse: + return ActiveSessionsResourceWithStreamingResponse(self) + + def list( + self, + user_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, + ) -> SyncSinglePage[ActiveSessionListResponse]: + """ + Get active sessions for a single user. + + Args: + account_id: Identifier + + user_id: UUID + + 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 user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/access/users/{user_id}/active_sessions", + page=SyncSinglePage[ActiveSessionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ActiveSessionListResponse, + ) + + def get( + self, + nonce: str, + *, + account_id: str, + user_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[ActiveSessionGetResponse]: + """ + Get an active session for a single user. + + Args: + account_id: Identifier + + user_id: UUID + + 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 user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + if not nonce: + raise ValueError(f"Expected a non-empty value for `nonce` but received {nonce!r}") + return self._get( + f"/accounts/{account_id}/access/users/{user_id}/active_sessions/{nonce}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ActiveSessionGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ActiveSessionGetResponse]], ResultWrapper[ActiveSessionGetResponse]), + ) + + +class AsyncActiveSessionsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncActiveSessionsResourceWithRawResponse: + return AsyncActiveSessionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncActiveSessionsResourceWithStreamingResponse: + return AsyncActiveSessionsResourceWithStreamingResponse(self) + + def list( + self, + user_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, + ) -> AsyncPaginator[ActiveSessionListResponse, AsyncSinglePage[ActiveSessionListResponse]]: + """ + Get active sessions for a single user. + + Args: + account_id: Identifier + + user_id: UUID + + 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 user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/access/users/{user_id}/active_sessions", + page=AsyncSinglePage[ActiveSessionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=ActiveSessionListResponse, + ) + + async def get( + self, + nonce: str, + *, + account_id: str, + user_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[ActiveSessionGetResponse]: + """ + Get an active session for a single user. + + Args: + account_id: Identifier + + user_id: UUID + + 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 user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + if not nonce: + raise ValueError(f"Expected a non-empty value for `nonce` but received {nonce!r}") + return await self._get( + f"/accounts/{account_id}/access/users/{user_id}/active_sessions/{nonce}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ActiveSessionGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ActiveSessionGetResponse]], ResultWrapper[ActiveSessionGetResponse]), + ) + + +class ActiveSessionsResourceWithRawResponse: + def __init__(self, active_sessions: ActiveSessionsResource) -> None: + self._active_sessions = active_sessions + + self.list = to_raw_response_wrapper( + active_sessions.list, + ) + self.get = to_raw_response_wrapper( + active_sessions.get, + ) + + +class AsyncActiveSessionsResourceWithRawResponse: + def __init__(self, active_sessions: AsyncActiveSessionsResource) -> None: + self._active_sessions = active_sessions + + self.list = async_to_raw_response_wrapper( + active_sessions.list, + ) + self.get = async_to_raw_response_wrapper( + active_sessions.get, + ) + + +class ActiveSessionsResourceWithStreamingResponse: + def __init__(self, active_sessions: ActiveSessionsResource) -> None: + self._active_sessions = active_sessions + + self.list = to_streamed_response_wrapper( + active_sessions.list, + ) + self.get = to_streamed_response_wrapper( + active_sessions.get, + ) + + +class AsyncActiveSessionsResourceWithStreamingResponse: + def __init__(self, active_sessions: AsyncActiveSessionsResource) -> None: + self._active_sessions = active_sessions + + self.list = async_to_streamed_response_wrapper( + active_sessions.list, + ) + self.get = async_to_streamed_response_wrapper( + active_sessions.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/users/failed_logins.py b/src/cloudflare/resources/zero_trust/access/users/failed_logins.py new file mode 100644 index 00000000000..30e2b404147 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/users/failed_logins.py @@ -0,0 +1,161 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +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 .....pagination import SyncSinglePage, AsyncSinglePage +from ....._base_client import ( + AsyncPaginator, + make_request_options, +) +from .....types.zero_trust.access.users.failed_login_list_response import FailedLoginListResponse + +__all__ = ["FailedLoginsResource", "AsyncFailedLoginsResource"] + + +class FailedLoginsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> FailedLoginsResourceWithRawResponse: + return FailedLoginsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FailedLoginsResourceWithStreamingResponse: + return FailedLoginsResourceWithStreamingResponse(self) + + def list( + self, + user_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, + ) -> SyncSinglePage[FailedLoginListResponse]: + """ + Get all failed login attempts for a single user. + + Args: + account_id: Identifier + + user_id: UUID + + 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 user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/access/users/{user_id}/failed_logins", + page=SyncSinglePage[FailedLoginListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=FailedLoginListResponse, + ) + + +class AsyncFailedLoginsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncFailedLoginsResourceWithRawResponse: + return AsyncFailedLoginsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFailedLoginsResourceWithStreamingResponse: + return AsyncFailedLoginsResourceWithStreamingResponse(self) + + def list( + self, + user_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, + ) -> AsyncPaginator[FailedLoginListResponse, AsyncSinglePage[FailedLoginListResponse]]: + """ + Get all failed login attempts for a single user. + + Args: + account_id: Identifier + + user_id: UUID + + 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 user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/access/users/{user_id}/failed_logins", + page=AsyncSinglePage[FailedLoginListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=FailedLoginListResponse, + ) + + +class FailedLoginsResourceWithRawResponse: + def __init__(self, failed_logins: FailedLoginsResource) -> None: + self._failed_logins = failed_logins + + self.list = to_raw_response_wrapper( + failed_logins.list, + ) + + +class AsyncFailedLoginsResourceWithRawResponse: + def __init__(self, failed_logins: AsyncFailedLoginsResource) -> None: + self._failed_logins = failed_logins + + self.list = async_to_raw_response_wrapper( + failed_logins.list, + ) + + +class FailedLoginsResourceWithStreamingResponse: + def __init__(self, failed_logins: FailedLoginsResource) -> None: + self._failed_logins = failed_logins + + self.list = to_streamed_response_wrapper( + failed_logins.list, + ) + + +class AsyncFailedLoginsResourceWithStreamingResponse: + def __init__(self, failed_logins: AsyncFailedLoginsResource) -> None: + self._failed_logins = failed_logins + + self.list = async_to_streamed_response_wrapper( + failed_logins.list, + ) diff --git a/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py b/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py new file mode 100644 index 00000000000..e1ac12e3aed --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/users/last_seen_identity.py @@ -0,0 +1,168 @@ +# 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.access.users.identity import Identity + +__all__ = ["LastSeenIdentityResource", "AsyncLastSeenIdentityResource"] + + +class LastSeenIdentityResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> LastSeenIdentityResourceWithRawResponse: + return LastSeenIdentityResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LastSeenIdentityResourceWithStreamingResponse: + return LastSeenIdentityResourceWithStreamingResponse(self) + + def get( + self, + user_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[Identity]: + """ + Get last seen identity for a single user. + + Args: + account_id: Identifier + + user_id: UUID + + 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 user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return self._get( + f"/accounts/{account_id}/access/users/{user_id}/last_seen_identity", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Identity]]._unwrapper, + ), + cast_to=cast(Type[Optional[Identity]], ResultWrapper[Identity]), + ) + + +class AsyncLastSeenIdentityResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncLastSeenIdentityResourceWithRawResponse: + return AsyncLastSeenIdentityResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncLastSeenIdentityResourceWithStreamingResponse: + return AsyncLastSeenIdentityResourceWithStreamingResponse(self) + + async def get( + self, + user_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[Identity]: + """ + Get last seen identity for a single user. + + Args: + account_id: Identifier + + user_id: UUID + + 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 user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return await self._get( + f"/accounts/{account_id}/access/users/{user_id}/last_seen_identity", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Identity]]._unwrapper, + ), + cast_to=cast(Type[Optional[Identity]], ResultWrapper[Identity]), + ) + + +class LastSeenIdentityResourceWithRawResponse: + def __init__(self, last_seen_identity: LastSeenIdentityResource) -> None: + self._last_seen_identity = last_seen_identity + + self.get = to_raw_response_wrapper( + last_seen_identity.get, + ) + + +class AsyncLastSeenIdentityResourceWithRawResponse: + def __init__(self, last_seen_identity: AsyncLastSeenIdentityResource) -> None: + self._last_seen_identity = last_seen_identity + + self.get = async_to_raw_response_wrapper( + last_seen_identity.get, + ) + + +class LastSeenIdentityResourceWithStreamingResponse: + def __init__(self, last_seen_identity: LastSeenIdentityResource) -> None: + self._last_seen_identity = last_seen_identity + + self.get = to_streamed_response_wrapper( + last_seen_identity.get, + ) + + +class AsyncLastSeenIdentityResourceWithStreamingResponse: + def __init__(self, last_seen_identity: AsyncLastSeenIdentityResource) -> None: + self._last_seen_identity = last_seen_identity + + self.get = async_to_streamed_response_wrapper( + last_seen_identity.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/users/users.py b/src/cloudflare/resources/zero_trust/access/users/users.py new file mode 100644 index 00000000000..9021838eaff --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/users/users.py @@ -0,0 +1,247 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +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 .failed_logins import ( + FailedLoginsResource, + AsyncFailedLoginsResource, + FailedLoginsResourceWithRawResponse, + AsyncFailedLoginsResourceWithRawResponse, + FailedLoginsResourceWithStreamingResponse, + AsyncFailedLoginsResourceWithStreamingResponse, +) +from .....pagination import SyncSinglePage, AsyncSinglePage +from .active_sessions import ( + ActiveSessionsResource, + AsyncActiveSessionsResource, + ActiveSessionsResourceWithRawResponse, + AsyncActiveSessionsResourceWithRawResponse, + ActiveSessionsResourceWithStreamingResponse, + AsyncActiveSessionsResourceWithStreamingResponse, +) +from ....._base_client import ( + AsyncPaginator, + make_request_options, +) +from .last_seen_identity import ( + LastSeenIdentityResource, + AsyncLastSeenIdentityResource, + LastSeenIdentityResourceWithRawResponse, + AsyncLastSeenIdentityResourceWithRawResponse, + LastSeenIdentityResourceWithStreamingResponse, + AsyncLastSeenIdentityResourceWithStreamingResponse, +) +from .....types.zero_trust.access.access_user import AccessUser + +__all__ = ["UsersResource", "AsyncUsersResource"] + + +class UsersResource(SyncAPIResource): + @cached_property + def active_sessions(self) -> ActiveSessionsResource: + return ActiveSessionsResource(self._client) + + @cached_property + def last_seen_identity(self) -> LastSeenIdentityResource: + return LastSeenIdentityResource(self._client) + + @cached_property + def failed_logins(self) -> FailedLoginsResource: + return FailedLoginsResource(self._client) + + @cached_property + def with_raw_response(self) -> UsersResourceWithRawResponse: + return UsersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> UsersResourceWithStreamingResponse: + return UsersResourceWithStreamingResponse(self) + + 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[AccessUser]: + """ + Gets a list of users for an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/users", + page=SyncSinglePage[AccessUser], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=AccessUser, + ) + + +class AsyncUsersResource(AsyncAPIResource): + @cached_property + def active_sessions(self) -> AsyncActiveSessionsResource: + return AsyncActiveSessionsResource(self._client) + + @cached_property + def last_seen_identity(self) -> AsyncLastSeenIdentityResource: + return AsyncLastSeenIdentityResource(self._client) + + @cached_property + def failed_logins(self) -> AsyncFailedLoginsResource: + return AsyncFailedLoginsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncUsersResourceWithRawResponse: + return AsyncUsersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncUsersResourceWithStreamingResponse: + return AsyncUsersResourceWithStreamingResponse(self) + + 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[AccessUser, AsyncSinglePage[AccessUser]]: + """ + Gets a list of users for an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/users", + page=AsyncSinglePage[AccessUser], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=AccessUser, + ) + + +class UsersResourceWithRawResponse: + def __init__(self, users: UsersResource) -> None: + self._users = users + + self.list = to_raw_response_wrapper( + users.list, + ) + + @cached_property + def active_sessions(self) -> ActiveSessionsResourceWithRawResponse: + return ActiveSessionsResourceWithRawResponse(self._users.active_sessions) + + @cached_property + def last_seen_identity(self) -> LastSeenIdentityResourceWithRawResponse: + return LastSeenIdentityResourceWithRawResponse(self._users.last_seen_identity) + + @cached_property + def failed_logins(self) -> FailedLoginsResourceWithRawResponse: + return FailedLoginsResourceWithRawResponse(self._users.failed_logins) + + +class AsyncUsersResourceWithRawResponse: + def __init__(self, users: AsyncUsersResource) -> None: + self._users = users + + self.list = async_to_raw_response_wrapper( + users.list, + ) + + @cached_property + def active_sessions(self) -> AsyncActiveSessionsResourceWithRawResponse: + return AsyncActiveSessionsResourceWithRawResponse(self._users.active_sessions) + + @cached_property + def last_seen_identity(self) -> AsyncLastSeenIdentityResourceWithRawResponse: + return AsyncLastSeenIdentityResourceWithRawResponse(self._users.last_seen_identity) + + @cached_property + def failed_logins(self) -> AsyncFailedLoginsResourceWithRawResponse: + return AsyncFailedLoginsResourceWithRawResponse(self._users.failed_logins) + + +class UsersResourceWithStreamingResponse: + def __init__(self, users: UsersResource) -> None: + self._users = users + + self.list = to_streamed_response_wrapper( + users.list, + ) + + @cached_property + def active_sessions(self) -> ActiveSessionsResourceWithStreamingResponse: + return ActiveSessionsResourceWithStreamingResponse(self._users.active_sessions) + + @cached_property + def last_seen_identity(self) -> LastSeenIdentityResourceWithStreamingResponse: + return LastSeenIdentityResourceWithStreamingResponse(self._users.last_seen_identity) + + @cached_property + def failed_logins(self) -> FailedLoginsResourceWithStreamingResponse: + return FailedLoginsResourceWithStreamingResponse(self._users.failed_logins) + + +class AsyncUsersResourceWithStreamingResponse: + def __init__(self, users: AsyncUsersResource) -> None: + self._users = users + + self.list = async_to_streamed_response_wrapper( + users.list, + ) + + @cached_property + def active_sessions(self) -> AsyncActiveSessionsResourceWithStreamingResponse: + return AsyncActiveSessionsResourceWithStreamingResponse(self._users.active_sessions) + + @cached_property + def last_seen_identity(self) -> AsyncLastSeenIdentityResourceWithStreamingResponse: + return AsyncLastSeenIdentityResourceWithStreamingResponse(self._users.last_seen_identity) + + @cached_property + def failed_logins(self) -> AsyncFailedLoginsResourceWithStreamingResponse: + return AsyncFailedLoginsResourceWithStreamingResponse(self._users.failed_logins) diff --git a/src/cloudflare/resources/zero_trust/identity_providers.py b/src/cloudflare/resources/zero_trust/identity_providers.py index 22a66d860cd..d90f719e232 100644 --- a/src/cloudflare/resources/zero_trust/identity_providers.py +++ b/src/cloudflare/resources/zero_trust/identity_providers.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Optional, cast, overload +from typing import Any, Type, Optional, cast, overload import httpx @@ -26,12 +26,17 @@ AsyncPaginator, make_request_options, ) -from ...types.zero_trust import IdentityProviderType, identity_provider_create_params +from ...types.zero_trust import ( + IdentityProviderType, + identity_provider_create_params, + identity_provider_update_params, +) from ...types.zero_trust.identity_provider import IdentityProvider from ...types.zero_trust.scim_config_param import ScimConfigParam from ...types.zero_trust.identity_provider_type import IdentityProviderType from ...types.zero_trust.generic_oauth_config_param import GenericOAuthConfigParam from ...types.zero_trust.identity_provider_list_response import IdentityProviderListResponse +from ...types.zero_trust.identity_provider_delete_response import IdentityProviderDeleteResponse __all__ = ["IdentityProvidersResource", "AsyncIdentityProvidersResource"] @@ -782,72 +787,12 @@ def create( ), ) - def list( - self, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[IdentityProviderListResponse]: - """ - Lists all configured identity providers. - - Args: - account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - - zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get_api_list( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", - page=SyncSinglePage[IdentityProviderListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=cast( - Any, IdentityProviderListResponse - ), # Union types cannot be passed in as arguments in the type system - ) - - -class AsyncIdentityProvidersResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncIdentityProvidersResourceWithRawResponse: - return AsyncIdentityProvidersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncIdentityProvidersResourceWithStreamingResponse: - return AsyncIdentityProvidersResourceWithStreamingResponse(self) - @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AzureADConfig, + config: identity_provider_update_params.AzureADConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -861,9 +806,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -892,10 +839,11 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AccessCentrifyConfig, + config: identity_provider_update_params.AccessCentrifyConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -909,9 +857,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -940,8 +890,9 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, config: GenericOAuthConfigParam, name: str, @@ -957,9 +908,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -988,8 +941,9 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, config: GenericOAuthConfigParam, name: str, @@ -1005,9 +959,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1036,10 +992,11 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AccessGoogleConfig, + config: identity_provider_update_params.AccessGoogleConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1053,9 +1010,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1084,10 +1043,11 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AccessGoogleAppsConfig, + config: identity_provider_update_params.AccessGoogleAppsConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1101,9 +1061,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1132,8 +1094,9 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, config: GenericOAuthConfigParam, name: str, @@ -1149,9 +1112,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1180,10 +1145,11 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AccessOIDCConfig, + config: identity_provider_update_params.AccessOIDCConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1197,9 +1163,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1228,10 +1196,11 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AccessOktaConfig, + config: identity_provider_update_params.AccessOktaConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1245,9 +1214,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1276,10 +1247,11 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AccessOneloginConfig, + config: identity_provider_update_params.AccessOneloginConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1293,9 +1265,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1324,10 +1298,11 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AccessPingoneConfig, + config: identity_provider_update_params.AccessPingoneConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1341,9 +1316,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1372,10 +1349,11 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AccessSAMLConfig, + config: identity_provider_update_params.AccessSAMLConfig, name: str, type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, @@ -1389,9 +1367,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1420,8 +1400,9 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, config: GenericOAuthConfigParam, name: str, @@ -1437,9 +1418,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1468,8 +1451,9 @@ async def create( ... @overload - async def create( + def update( self, + identity_provider_id: str, *, config: object, name: str, @@ -1485,9 +1469,11 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: """ - Adds a new identity provider to Access. + Updates a configured identity provider. Args: + identity_provider_id: UUID + config: The configuration parameters for the identity provider. To view the required parameters for a specific provider, refer to our [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). @@ -1516,19 +1502,20 @@ async def create( ... @required_args(["config", "name", "type"]) - async def create( + def update( self, + identity_provider_id: str, *, - config: identity_provider_create_params.AzureADConfig - | identity_provider_create_params.AccessCentrifyConfig + config: identity_provider_update_params.AzureADConfig + | identity_provider_update_params.AccessCentrifyConfig | GenericOAuthConfigParam - | identity_provider_create_params.AccessGoogleConfig - | identity_provider_create_params.AccessGoogleAppsConfig - | identity_provider_create_params.AccessOIDCConfig - | identity_provider_create_params.AccessOktaConfig - | identity_provider_create_params.AccessOneloginConfig - | identity_provider_create_params.AccessPingoneConfig - | identity_provider_create_params.AccessSAMLConfig + | identity_provider_update_params.AccessGoogleConfig + | identity_provider_update_params.AccessGoogleAppsConfig + | identity_provider_update_params.AccessOIDCConfig + | identity_provider_update_params.AccessOktaConfig + | identity_provider_update_params.AccessOneloginConfig + | identity_provider_update_params.AccessPingoneConfig + | identity_provider_update_params.AccessSAMLConfig | object, name: str, type: IdentityProviderType, @@ -1542,6 +1529,10 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IdentityProvider]: + if not identity_provider_id: + raise ValueError( + f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" + ) if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1556,16 +1547,16 @@ async def create( account_or_zone_id = zone_id return cast( Optional[IdentityProvider], - await self._post( - f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", - body=await async_maybe_transform( + self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + body=maybe_transform( { "config": config, "name": name, "type": type, "scim_config": scim_config, }, - identity_provider_create_params.IdentityProviderCreateParams, + identity_provider_update_params.IdentityProviderUpdateParams, ), options=make_request_options( extra_headers=extra_headers, @@ -1591,7 +1582,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[IdentityProviderListResponse, AsyncSinglePage[IdentityProviderListResponse]]: + ) -> SyncSinglePage[IdentityProviderListResponse]: """ Lists all configured identity providers. @@ -1622,7 +1613,7 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", - page=AsyncSinglePage[IdentityProviderListResponse], + page=SyncSinglePage[IdentityProviderListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -1631,50 +1622,1914 @@ def list( ), # Union types cannot be passed in as arguments in the type system ) + def delete( + self, + identity_provider_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[IdentityProviderDeleteResponse]: + """ + Deletes an identity provider from Access. -class IdentityProvidersResourceWithRawResponse: - def __init__(self, identity_providers: IdentityProvidersResource) -> None: - self._identity_providers = identity_providers + Args: + identity_provider_id: UUID - self.create = to_raw_response_wrapper( - identity_providers.create, - ) - self.list = to_raw_response_wrapper( - identity_providers.list, - ) + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. -class AsyncIdentityProvidersResourceWithRawResponse: - def __init__(self, identity_providers: AsyncIdentityProvidersResource) -> None: - self._identity_providers = identity_providers + extra_headers: Send extra headers - self.create = async_to_raw_response_wrapper( - identity_providers.create, - ) - self.list = async_to_raw_response_wrapper( - identity_providers.list, - ) + extra_query: Add additional query parameters to the request + extra_body: Add additional JSON properties to the request -class IdentityProvidersResourceWithStreamingResponse: - def __init__(self, identity_providers: IdentityProvidersResource) -> None: - self._identity_providers = identity_providers + timeout: Override the client-level default timeout for this request, in seconds + """ + if not identity_provider_id: + raise ValueError( + f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" + ) + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") - self.create = to_streamed_response_wrapper( - identity_providers.create, - ) - self.list = to_streamed_response_wrapper( - identity_providers.list, + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IdentityProviderDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IdentityProviderDeleteResponse]], ResultWrapper[IdentityProviderDeleteResponse]), ) + def get( + self, + identity_provider_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[IdentityProvider]: + """ + Fetches a configured identity provider. + + Args: + identity_provider_id: UUID -class AsyncIdentityProvidersResourceWithStreamingResponse: - def __init__(self, identity_providers: AsyncIdentityProvidersResource) -> None: - self._identity_providers = identity_providers + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - self.create = async_to_streamed_response_wrapper( - identity_providers.create, + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not identity_provider_id: + raise ValueError( + f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" + ) + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return cast( + Optional[IdentityProvider], + self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IdentityProvider]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[IdentityProvider] + ), # Union types cannot be passed in as arguments in the type system + ), ) - self.list = async_to_streamed_response_wrapper( - identity_providers.list, + + +class AsyncIdentityProvidersResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIdentityProvidersResourceWithRawResponse: + return AsyncIdentityProvidersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIdentityProvidersResourceWithStreamingResponse: + return AsyncIdentityProvidersResourceWithStreamingResponse(self) + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AzureADConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AccessCentrifyConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: GenericOAuthConfigParam, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: GenericOAuthConfigParam, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AccessGoogleConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AccessGoogleAppsConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: GenericOAuthConfigParam, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AccessOIDCConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AccessOktaConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AccessOneloginConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AccessPingoneConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: identity_provider_create_params.AccessSAMLConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: GenericOAuthConfigParam, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def create( + self, + *, + config: object, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Adds a new identity provider to Access. + + Args: + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @required_args(["config", "name", "type"]) + async def create( + self, + *, + config: identity_provider_create_params.AzureADConfig + | identity_provider_create_params.AccessCentrifyConfig + | GenericOAuthConfigParam + | identity_provider_create_params.AccessGoogleConfig + | identity_provider_create_params.AccessGoogleAppsConfig + | identity_provider_create_params.AccessOIDCConfig + | identity_provider_create_params.AccessOktaConfig + | identity_provider_create_params.AccessOneloginConfig + | identity_provider_create_params.AccessPingoneConfig + | identity_provider_create_params.AccessSAMLConfig + | object, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return cast( + Optional[IdentityProvider], + await self._post( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + body=await async_maybe_transform( + { + "config": config, + "name": name, + "type": type, + "scim_config": scim_config, + }, + identity_provider_create_params.IdentityProviderCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IdentityProvider]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[IdentityProvider] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AzureADConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AccessCentrifyConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: GenericOAuthConfigParam, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: GenericOAuthConfigParam, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AccessGoogleConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AccessGoogleAppsConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: GenericOAuthConfigParam, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AccessOIDCConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AccessOktaConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AccessOneloginConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AccessPingoneConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AccessSAMLConfig, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: GenericOAuthConfigParam, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @overload + async def update( + self, + identity_provider_id: str, + *, + config: object, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + """ + Updates a configured identity provider. + + Args: + identity_provider_id: UUID + + config: The configuration parameters for the identity provider. To view the required + parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + name: The name of the identity provider, shown to users on the login page. + + type: The type of identity provider. To determine the value for a specific provider, + refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + scim_config: The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + + 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 + """ + ... + + @required_args(["config", "name", "type"]) + async def update( + self, + identity_provider_id: str, + *, + config: identity_provider_update_params.AzureADConfig + | identity_provider_update_params.AccessCentrifyConfig + | GenericOAuthConfigParam + | identity_provider_update_params.AccessGoogleConfig + | identity_provider_update_params.AccessGoogleAppsConfig + | identity_provider_update_params.AccessOIDCConfig + | identity_provider_update_params.AccessOktaConfig + | identity_provider_update_params.AccessOneloginConfig + | identity_provider_update_params.AccessPingoneConfig + | identity_provider_update_params.AccessSAMLConfig + | object, + name: str, + type: IdentityProviderType, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + scim_config: ScimConfigParam | 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[IdentityProvider]: + if not identity_provider_id: + raise ValueError( + f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" + ) + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return cast( + Optional[IdentityProvider], + await self._put( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + body=await async_maybe_transform( + { + "config": config, + "name": name, + "type": type, + "scim_config": scim_config, + }, + identity_provider_update_params.IdentityProviderUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IdentityProvider]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[IdentityProvider] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + def list( + self, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[IdentityProviderListResponse, AsyncSinglePage[IdentityProviderListResponse]]: + """ + Lists all configured identity providers. + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get_api_list( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers", + page=AsyncSinglePage[IdentityProviderListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=cast( + Any, IdentityProviderListResponse + ), # Union types cannot be passed in as arguments in the type system + ) + + async def delete( + self, + identity_provider_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[IdentityProviderDeleteResponse]: + """ + Deletes an identity provider from Access. + + Args: + identity_provider_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not identity_provider_id: + raise ValueError( + f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" + ) + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._delete( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IdentityProviderDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IdentityProviderDeleteResponse]], ResultWrapper[IdentityProviderDeleteResponse]), + ) + + async def get( + self, + identity_provider_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[IdentityProvider]: + """ + Fetches a configured identity provider. + + Args: + identity_provider_id: UUID + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not identity_provider_id: + raise ValueError( + f"Expected a non-empty value for `identity_provider_id` but received {identity_provider_id!r}" + ) + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return cast( + Optional[IdentityProvider], + await self._get( + f"/{account_or_zone}/{account_or_zone_id}/access/identity_providers/{identity_provider_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IdentityProvider]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[IdentityProvider] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class IdentityProvidersResourceWithRawResponse: + def __init__(self, identity_providers: IdentityProvidersResource) -> None: + self._identity_providers = identity_providers + + self.create = to_raw_response_wrapper( + identity_providers.create, + ) + self.update = to_raw_response_wrapper( + identity_providers.update, + ) + self.list = to_raw_response_wrapper( + identity_providers.list, + ) + self.delete = to_raw_response_wrapper( + identity_providers.delete, + ) + self.get = to_raw_response_wrapper( + identity_providers.get, + ) + + +class AsyncIdentityProvidersResourceWithRawResponse: + def __init__(self, identity_providers: AsyncIdentityProvidersResource) -> None: + self._identity_providers = identity_providers + + self.create = async_to_raw_response_wrapper( + identity_providers.create, + ) + self.update = async_to_raw_response_wrapper( + identity_providers.update, + ) + self.list = async_to_raw_response_wrapper( + identity_providers.list, + ) + self.delete = async_to_raw_response_wrapper( + identity_providers.delete, + ) + self.get = async_to_raw_response_wrapper( + identity_providers.get, + ) + + +class IdentityProvidersResourceWithStreamingResponse: + def __init__(self, identity_providers: IdentityProvidersResource) -> None: + self._identity_providers = identity_providers + + self.create = to_streamed_response_wrapper( + identity_providers.create, + ) + self.update = to_streamed_response_wrapper( + identity_providers.update, + ) + self.list = to_streamed_response_wrapper( + identity_providers.list, + ) + self.delete = to_streamed_response_wrapper( + identity_providers.delete, + ) + self.get = to_streamed_response_wrapper( + identity_providers.get, + ) + + +class AsyncIdentityProvidersResourceWithStreamingResponse: + def __init__(self, identity_providers: AsyncIdentityProvidersResource) -> None: + self._identity_providers = identity_providers + + self.create = async_to_streamed_response_wrapper( + identity_providers.create, + ) + self.update = async_to_streamed_response_wrapper( + identity_providers.update, + ) + self.list = async_to_streamed_response_wrapper( + identity_providers.list, + ) + self.delete = async_to_streamed_response_wrapper( + identity_providers.delete, + ) + self.get = async_to_streamed_response_wrapper( + identity_providers.get, ) diff --git a/src/cloudflare/resources/zero_trust/seats.py b/src/cloudflare/resources/zero_trust/seats.py new file mode 100644 index 00000000000..fa9fbe00220 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/seats.py @@ -0,0 +1,169 @@ +# 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 import seat_edit_params +from ...types.zero_trust.seat_edit_response import SeatEditResponse + +__all__ = ["SeatsResource", "AsyncSeatsResource"] + + +class SeatsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SeatsResourceWithRawResponse: + return SeatsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SeatsResourceWithStreamingResponse: + return SeatsResourceWithStreamingResponse(self) + + def edit( + self, + *, + account_id: str, + body: Iterable[seat_edit_params.Body], + # 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[SeatEditResponse]: + """ + Removes a user from a Zero Trust seat when both `access_seat` and `gateway_seat` + are set to false. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/seats", + body=maybe_transform(body, seat_edit_params.SeatEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SeatEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SeatEditResponse]], ResultWrapper[SeatEditResponse]), + ) + + +class AsyncSeatsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSeatsResourceWithRawResponse: + return AsyncSeatsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSeatsResourceWithStreamingResponse: + return AsyncSeatsResourceWithStreamingResponse(self) + + async def edit( + self, + *, + account_id: str, + body: Iterable[seat_edit_params.Body], + # 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[SeatEditResponse]: + """ + Removes a user from a Zero Trust seat when both `access_seat` and `gateway_seat` + are set to false. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/seats", + body=await async_maybe_transform(body, seat_edit_params.SeatEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SeatEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SeatEditResponse]], ResultWrapper[SeatEditResponse]), + ) + + +class SeatsResourceWithRawResponse: + def __init__(self, seats: SeatsResource) -> None: + self._seats = seats + + self.edit = to_raw_response_wrapper( + seats.edit, + ) + + +class AsyncSeatsResourceWithRawResponse: + def __init__(self, seats: AsyncSeatsResource) -> None: + self._seats = seats + + self.edit = async_to_raw_response_wrapper( + seats.edit, + ) + + +class SeatsResourceWithStreamingResponse: + def __init__(self, seats: SeatsResource) -> None: + self._seats = seats + + self.edit = to_streamed_response_wrapper( + seats.edit, + ) + + +class AsyncSeatsResourceWithStreamingResponse: + def __init__(self, seats: AsyncSeatsResource) -> None: + self._seats = seats + + self.edit = async_to_streamed_response_wrapper( + seats.edit, + ) diff --git a/src/cloudflare/resources/zero_trust/zero_trust.py b/src/cloudflare/resources/zero_trust/zero_trust.py index 880f0f44ea4..63aefc65ac1 100644 --- a/src/cloudflare/resources/zero_trust/zero_trust.py +++ b/src/cloudflare/resources/zero_trust/zero_trust.py @@ -18,6 +18,14 @@ DLPResourceWithStreamingResponse, AsyncDLPResourceWithStreamingResponse, ) +from .seats import ( + SeatsResource, + AsyncSeatsResource, + SeatsResourceWithRawResponse, + AsyncSeatsResourceWithRawResponse, + SeatsResourceWithStreamingResponse, + AsyncSeatsResourceWithStreamingResponse, +) from .access import ( AccessResource, AsyncAccessResource, @@ -117,6 +125,10 @@ def identity_providers(self) -> IdentityProvidersResource: def organizations(self) -> OrganizationsResource: return OrganizationsResource(self._client) + @cached_property + def seats(self) -> SeatsResource: + return SeatsResource(self._client) + @cached_property def access(self) -> AccessResource: return AccessResource(self._client) @@ -171,6 +183,10 @@ def identity_providers(self) -> AsyncIdentityProvidersResource: def organizations(self) -> AsyncOrganizationsResource: return AsyncOrganizationsResource(self._client) + @cached_property + def seats(self) -> AsyncSeatsResource: + return AsyncSeatsResource(self._client) + @cached_property def access(self) -> AsyncAccessResource: return AsyncAccessResource(self._client) @@ -228,6 +244,10 @@ def identity_providers(self) -> IdentityProvidersResourceWithRawResponse: def organizations(self) -> OrganizationsResourceWithRawResponse: return OrganizationsResourceWithRawResponse(self._zero_trust.organizations) + @cached_property + def seats(self) -> SeatsResourceWithRawResponse: + return SeatsResourceWithRawResponse(self._zero_trust.seats) + @cached_property def access(self) -> AccessResourceWithRawResponse: return AccessResourceWithRawResponse(self._zero_trust.access) @@ -277,6 +297,10 @@ def identity_providers(self) -> AsyncIdentityProvidersResourceWithRawResponse: def organizations(self) -> AsyncOrganizationsResourceWithRawResponse: return AsyncOrganizationsResourceWithRawResponse(self._zero_trust.organizations) + @cached_property + def seats(self) -> AsyncSeatsResourceWithRawResponse: + return AsyncSeatsResourceWithRawResponse(self._zero_trust.seats) + @cached_property def access(self) -> AsyncAccessResourceWithRawResponse: return AsyncAccessResourceWithRawResponse(self._zero_trust.access) @@ -326,6 +350,10 @@ def identity_providers(self) -> IdentityProvidersResourceWithStreamingResponse: def organizations(self) -> OrganizationsResourceWithStreamingResponse: return OrganizationsResourceWithStreamingResponse(self._zero_trust.organizations) + @cached_property + def seats(self) -> SeatsResourceWithStreamingResponse: + return SeatsResourceWithStreamingResponse(self._zero_trust.seats) + @cached_property def access(self) -> AccessResourceWithStreamingResponse: return AccessResourceWithStreamingResponse(self._zero_trust.access) @@ -375,6 +403,10 @@ def identity_providers(self) -> AsyncIdentityProvidersResourceWithStreamingRespo def organizations(self) -> AsyncOrganizationsResourceWithStreamingResponse: return AsyncOrganizationsResourceWithStreamingResponse(self._zero_trust.organizations) + @cached_property + def seats(self) -> AsyncSeatsResourceWithStreamingResponse: + return AsyncSeatsResourceWithStreamingResponse(self._zero_trust.seats) + @cached_property def access(self) -> AsyncAccessResourceWithStreamingResponse: return AsyncAccessResourceWithStreamingResponse(self._zero_trust.access) diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index 476a9254497..d88c9679596 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index d1e457901af..27f4398d8c9 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index a92b28cb216..3e00524ec11 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index bf04a129360..3c7d7b05653 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index e08bad9f0e5..f027d1e1dc5 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -76,6 +76,8 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", + "RulesetsDDoSDynamicRule", + "RulesetsForceConnectionCloseRule", ] @@ -1205,6 +1207,70 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" +class RulesetsDDoSDynamicRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsForceConnectionCloseRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + RuleCreateParams = Union[ BlockRule, ChallengeRule, @@ -1222,4 +1288,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, + RulesetsDDoSDynamicRule, + RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 9a729d3fbe1..04e3457f902 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 1b6810d585e..25d801cd5aa 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index 86c8418e7c8..8382c7d8687 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -76,6 +76,8 @@ "RulesetsLogCustomFieldRuleActionParametersCookieField", "RulesetsLogCustomFieldRuleActionParametersRequestField", "RulesetsLogCustomFieldRuleActionParametersResponseField", + "RulesetsDDoSDynamicRule", + "RulesetsForceConnectionCloseRule", ] @@ -1253,6 +1255,76 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): """The response fields to log.""" +class RulesetsDDoSDynamicRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsForceConnectionCloseRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + RuleEditParams = Union[ BlockRule, ChallengeRule, @@ -1270,4 +1342,6 @@ class RulesetsLogCustomFieldRuleActionParameters(TypedDict, total=False): SkipRule, SetCacheSettingsRule, RulesetsLogCustomFieldRule, + RulesetsDDoSDynamicRule, + RulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 3bf0100ef6f..47dd4534324 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py index 6d34a46fac5..4e372271bef 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_params.py +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index f87b58ceec8..bfeacd5afd4 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index d5864df9b91..328ba42b25a 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py index ce723859ed9..e2ff9a9fcb8 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_params.py +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -32,6 +32,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -110,6 +112,58 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["ddos_dynamic"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["force_connection_close"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + Rule = Union[ BlockRuleParam, ChallengeRuleParam, @@ -127,4 +181,6 @@ class RuleRulesetsLogCustomFieldRule(TypedDict, total=False): SkipRuleParam, SetCacheSettingsRuleParam, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index d2aaaa91d6f..9fb84d0d26a 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index 4d61f17e3ec..abb1cfae6c7 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index 62def70b1fd..058c549bc29 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -33,6 +33,8 @@ "RuleRulesetsLogCustomFieldRuleActionParametersCookieField", "RuleRulesetsLogCustomFieldRuleActionParametersRequestField", "RuleRulesetsLogCustomFieldRuleActionParametersResponseField", + "RuleRulesetsDDoSDynamicRule", + "RuleRulesetsForceConnectionCloseRule", ] @@ -97,6 +99,76 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): """The reference of the rule (the rule ID by default).""" +class RuleRulesetsDDoSDynamicRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["ddos_dynamic"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsForceConnectionCloseRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["force_connection_close"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + Rule = Annotated[ Union[ BlockRule, @@ -115,6 +187,8 @@ class RuleRulesetsLogCustomFieldRule(BaseModel): SkipRule, SetCacheSettingsRule, RuleRulesetsLogCustomFieldRule, + RuleRulesetsDDoSDynamicRule, + RuleRulesetsForceConnectionCloseRule, ], PropertyInfo(discriminator="action"), ] diff --git a/src/cloudflare/types/zero_trust/__init__.py b/src/cloudflare/types/zero_trust/__init__.py index 2cd39fd22ee..fe2de93ed13 100644 --- a/src/cloudflare/types/zero_trust/__init__.py +++ b/src/cloudflare/types/zero_trust/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations +from .seat import Seat as Seat from .device import Device as Device from .ip_rule import IPRule as IPRule from .azure_ad import AzureAD as AzureAD @@ -26,6 +27,7 @@ from .certificate_rule import CertificateRule as CertificateRule from .email_rule_param import EmailRuleParam as EmailRuleParam from .group_rule_param import GroupRuleParam as GroupRuleParam +from .seat_edit_params import SeatEditParams as SeatEditParams from .access_rule_param import AccessRuleParam as AccessRuleParam from .domain_rule_param import DomainRuleParam as DomainRuleParam from .gsuite_group_rule import GSuiteGroupRule as GSuiteGroupRule @@ -34,6 +36,7 @@ from .country_rule_param import CountryRuleParam as CountryRuleParam from .ip_list_rule_param import IPListRuleParam as IPListRuleParam from .login_design_param import LoginDesignParam as LoginDesignParam +from .seat_edit_response import SeatEditResponse as SeatEditResponse from .service_token_rule import ServiceTokenRule as ServiceTokenRule from .tunnel_edit_params import TunnelEditParams as TunnelEditParams from .tunnel_list_params import TunnelListParams as TunnelListParams @@ -73,11 +76,13 @@ from .github_organization_rule_param import GitHubOrganizationRuleParam as GitHubOrganizationRuleParam from .identity_provider_create_params import IdentityProviderCreateParams as IdentityProviderCreateParams from .identity_provider_list_response import IdentityProviderListResponse as IdentityProviderListResponse +from .identity_provider_update_params import IdentityProviderUpdateParams as IdentityProviderUpdateParams from .access_device_posture_rule_param import AccessDevicePostureRuleParam as AccessDevicePostureRuleParam from .authentication_method_rule_param import AuthenticationMethodRuleParam as AuthenticationMethodRuleParam from .connectivity_setting_edit_params import ConnectivitySettingEditParams as ConnectivitySettingEditParams from .organization_revoke_users_params import OrganizationRevokeUsersParams as OrganizationRevokeUsersParams from .connectivity_setting_get_response import ConnectivitySettingGetResponse as ConnectivitySettingGetResponse +from .identity_provider_delete_response import IdentityProviderDeleteResponse as IdentityProviderDeleteResponse from .any_valid_service_token_rule_param import AnyValidServiceTokenRuleParam as AnyValidServiceTokenRuleParam from .connectivity_setting_edit_response import ConnectivitySettingEditResponse as ConnectivitySettingEditResponse from .organization_revoke_users_response import OrganizationRevokeUsersResponse as OrganizationRevokeUsersResponse diff --git a/src/cloudflare/types/zero_trust/access/__init__.py b/src/cloudflare/types/zero_trust/access/__init__.py index 2645e488cfc..8b8d5c829cf 100644 --- a/src/cloudflare/types/zero_trust/access/__init__.py +++ b/src/cloudflare/types/zero_trust/access/__init__.py @@ -2,8 +2,12 @@ from __future__ import annotations +from .tag import Tag as Tag +from .bookmark import Bookmark as Bookmark from .decision import Decision as Decision +from .access_user import AccessUser as AccessUser from .certificate import Certificate as Certificate +from .custom_page import CustomPage as CustomPage from .allowed_idps import AllowedIdPs as AllowedIdPs from .app_id_param import AppIDParam as AppIDParam from .cors_headers import CORSHeaders as CORSHeaders @@ -14,22 +18,42 @@ from .allowed_origins import AllowedOrigins as AllowedOrigins from .saas_app_source import SaaSAppSource as SaaSAppSource from .application_type import ApplicationType as ApplicationType +from .key_get_response import KeyGetResponse as KeyGetResponse from .zero_trust_group import ZeroTrustGroup as ZeroTrustGroup +from .key_update_params import KeyUpdateParams as KeyUpdateParams +from .tag_create_params import TagCreateParams as TagCreateParams +from .tag_update_params import TagUpdateParams as TagUpdateParams from .cors_headers_param import CORSHeadersParam as CORSHeadersParam from .group_create_params import GroupCreateParams as GroupCreateParams +from .group_update_params import GroupUpdateParams as GroupUpdateParams +from .key_rotate_response import KeyRotateResponse as KeyRotateResponse +from .key_update_response import KeyUpdateResponse as KeyUpdateResponse from .saml_saas_app_param import SAMLSaaSAppParam as SAMLSaaSAppParam from .self_hosted_domains import SelfHostedDomains as SelfHostedDomains +from .tag_delete_response import TagDeleteResponse as TagDeleteResponse from .associated_hostnames import AssociatedHostnames as AssociatedHostnames from .saas_app_name_format import SaaSAppNameFormat as SaaSAppNameFormat +from .group_delete_response import GroupDeleteResponse as GroupDeleteResponse from .saas_app_source_param import SaaSAppSourceParam as SaaSAppSourceParam +from .bookmark_create_params import BookmarkCreateParams as BookmarkCreateParams +from .bookmark_update_params import BookmarkUpdateParams as BookmarkUpdateParams from .saas_app_name_id_format import SaaSAppNameIDFormat as SaaSAppNameIDFormat from .application_get_response import ApplicationGetResponse as ApplicationGetResponse +from .bookmark_delete_response import BookmarkDeleteResponse as BookmarkDeleteResponse +from .custom_page_without_html import CustomPageWithoutHTML as CustomPageWithoutHTML from .application_create_params import ApplicationCreateParams as ApplicationCreateParams from .application_list_response import ApplicationListResponse as ApplicationListResponse from .application_update_params import ApplicationUpdateParams as ApplicationUpdateParams from .certificate_create_params import CertificateCreateParams as CertificateCreateParams +from .certificate_update_params import CertificateUpdateParams as CertificateUpdateParams +from .custom_page_create_params import CustomPageCreateParams as CustomPageCreateParams +from .custom_page_update_params import CustomPageUpdateParams as CustomPageUpdateParams from .application_create_response import ApplicationCreateResponse as ApplicationCreateResponse from .application_delete_response import ApplicationDeleteResponse as ApplicationDeleteResponse from .application_update_response import ApplicationUpdateResponse as ApplicationUpdateResponse +from .certificate_delete_response import CertificateDeleteResponse as CertificateDeleteResponse +from .custom_page_delete_response import CustomPageDeleteResponse as CustomPageDeleteResponse from .service_token_create_params import ServiceTokenCreateParams as ServiceTokenCreateParams +from .service_token_update_params import ServiceTokenUpdateParams as ServiceTokenUpdateParams from .service_token_create_response import ServiceTokenCreateResponse as ServiceTokenCreateResponse +from .service_token_rotate_response import ServiceTokenRotateResponse as ServiceTokenRotateResponse diff --git a/src/cloudflare/types/zero_trust/access/access_user.py b/src/cloudflare/types/zero_trust/access/access_user.py new file mode 100644 index 00000000000..2430d721cf2 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/access_user.py @@ -0,0 +1,41 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["AccessUser"] + + +class AccessUser(BaseModel): + id: Optional[str] = None + """UUID""" + + access_seat: Optional[bool] = None + """True if the user has authenticated with Cloudflare Access.""" + + active_device_count: Optional[float] = None + """The number of active devices registered to the user.""" + + created_at: Optional[datetime] = None + + email: Optional[str] = None + """The email of the user.""" + + gateway_seat: Optional[bool] = None + """True if the user has logged into the WARP client.""" + + last_successful_login: Optional[datetime] = None + """The time at which the user last successfully logged in.""" + + name: Optional[str] = None + """The name of the user.""" + + seat_uid: Optional[str] = None + """The unique API identifier for the Zero Trust seat.""" + + uid: Optional[str] = None + """The unique API identifier for the user.""" + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/application_create_params.py b/src/cloudflare/types/zero_trust/access/application_create_params.py index ceefef639fc..8db6908028c 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_params.py +++ b/src/cloudflare/types/zero_trust/access/application_create_params.py @@ -248,6 +248,9 @@ class SelfHostedApplication(TypedDict, total=False): class SelfHostedApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -268,6 +271,9 @@ class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -508,6 +514,9 @@ class SaaSApplication(TypedDict, total=False): class SaaSApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -528,6 +537,9 @@ class SaaSApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -935,6 +947,9 @@ class BrowserSSHApplication(TypedDict, total=False): class BrowserSSHApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -955,6 +970,9 @@ class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1274,6 +1292,9 @@ class BrowserVncApplication(TypedDict, total=False): class BrowserVncApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -1294,6 +1315,9 @@ class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1521,6 +1545,9 @@ class AppLauncherApplication(TypedDict, total=False): class AppLauncherApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -1541,6 +1568,9 @@ class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1768,6 +1798,9 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): class DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -1788,6 +1821,9 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total= name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -2021,6 +2057,9 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): class BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -2041,6 +2080,9 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total= name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/application_create_response.py b/src/cloudflare/types/zero_trust/access/application_create_response.py index 982ec9f5012..5723338d66f 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_response.py +++ b/src/cloudflare/types/zero_trust/access/application_create_response.py @@ -100,7 +100,7 @@ class SelfHostedApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -424,7 +424,7 @@ class SelfHostedApplication(BaseModel): class SaaSApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -765,7 +765,7 @@ class SaaSApplication(BaseModel): class BrowserSSHApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1089,7 +1089,7 @@ class BrowserSSHApplication(BaseModel): class BrowserVncApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1413,7 +1413,7 @@ class BrowserVncApplication(BaseModel): class AppLauncherApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1655,7 +1655,7 @@ class AppLauncherApplication(BaseModel): class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1899,7 +1899,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): class BrowserIsolationPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/application_get_response.py b/src/cloudflare/types/zero_trust/access/application_get_response.py index 002c59d38ba..5fd2d5a2925 100644 --- a/src/cloudflare/types/zero_trust/access/application_get_response.py +++ b/src/cloudflare/types/zero_trust/access/application_get_response.py @@ -100,7 +100,7 @@ class SelfHostedApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -424,7 +424,7 @@ class SelfHostedApplication(BaseModel): class SaaSApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -765,7 +765,7 @@ class SaaSApplication(BaseModel): class BrowserSSHApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1089,7 +1089,7 @@ class BrowserSSHApplication(BaseModel): class BrowserVncApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1413,7 +1413,7 @@ class BrowserVncApplication(BaseModel): class AppLauncherApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1655,7 +1655,7 @@ class AppLauncherApplication(BaseModel): class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1899,7 +1899,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): class BrowserIsolationPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/application_list_response.py b/src/cloudflare/types/zero_trust/access/application_list_response.py index 5cde098ccba..9cbe550e5ac 100644 --- a/src/cloudflare/types/zero_trust/access/application_list_response.py +++ b/src/cloudflare/types/zero_trust/access/application_list_response.py @@ -100,7 +100,7 @@ class SelfHostedApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -424,7 +424,7 @@ class SelfHostedApplication(BaseModel): class SaaSApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -765,7 +765,7 @@ class SaaSApplication(BaseModel): class BrowserSSHApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1089,7 +1089,7 @@ class BrowserSSHApplication(BaseModel): class BrowserVncApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1413,7 +1413,7 @@ class BrowserVncApplication(BaseModel): class AppLauncherApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1655,7 +1655,7 @@ class AppLauncherApplication(BaseModel): class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1899,7 +1899,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): class BrowserIsolationPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/application_update_params.py b/src/cloudflare/types/zero_trust/access/application_update_params.py index 89f3c200849..0f45c59a354 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_params.py +++ b/src/cloudflare/types/zero_trust/access/application_update_params.py @@ -248,6 +248,9 @@ class SelfHostedApplication(TypedDict, total=False): class SelfHostedApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -268,6 +271,9 @@ class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -508,6 +514,9 @@ class SaaSApplication(TypedDict, total=False): class SaaSApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -528,6 +537,9 @@ class SaaSApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -935,6 +947,9 @@ class BrowserSSHApplication(TypedDict, total=False): class BrowserSSHApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -955,6 +970,9 @@ class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1274,6 +1292,9 @@ class BrowserVncApplication(TypedDict, total=False): class BrowserVncApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -1294,6 +1315,9 @@ class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1521,6 +1545,9 @@ class AppLauncherApplication(TypedDict, total=False): class AppLauncherApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -1541,6 +1568,9 @@ class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -1768,6 +1798,9 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): class DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -1788,6 +1821,9 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total= name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" @@ -2021,6 +2057,9 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): class BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink(TypedDict, total=False): + id: str + """The UUID of the policy""" + precedence: int """The order of execution for this policy. @@ -2041,6 +2080,9 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total= name: Required[str] """The name of the Access policy.""" + id: str + """The UUID of the policy""" + approval_groups: Iterable[ApprovalGroupParam] """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/application_update_response.py b/src/cloudflare/types/zero_trust/access/application_update_response.py index e4d7f457b89..b0a4b129ca1 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_response.py +++ b/src/cloudflare/types/zero_trust/access/application_update_response.py @@ -100,7 +100,7 @@ class SelfHostedApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -424,7 +424,7 @@ class SelfHostedApplication(BaseModel): class SaaSApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -765,7 +765,7 @@ class SaaSApplication(BaseModel): class BrowserSSHApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1089,7 +1089,7 @@ class BrowserSSHApplication(BaseModel): class BrowserVncApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1413,7 +1413,7 @@ class BrowserVncApplication(BaseModel): class AppLauncherApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1655,7 +1655,7 @@ class AppLauncherApplication(BaseModel): class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" @@ -1899,7 +1899,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): class BrowserIsolationPermissionsApplicationPolicy(BaseModel): id: Optional[str] = None - """UUID""" + """The UUID of the policy""" approval_groups: Optional[List[ApprovalGroup]] = None """Administrators who can approve a temporary authentication request.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/__init__.py b/src/cloudflare/types/zero_trust/access/applications/__init__.py index f34cf3dac26..206ec39071b 100644 --- a/src/cloudflare/types/zero_trust/access/applications/__init__.py +++ b/src/cloudflare/types/zero_trust/access/applications/__init__.py @@ -4,6 +4,16 @@ from .ca import CA as CA from .approval_group import ApprovalGroup as ApprovalGroup +from .ca_get_response import CAGetResponse as CAGetResponse +from .ca_create_response import CACreateResponse as CACreateResponse +from .ca_delete_response import CADeleteResponse as CADeleteResponse +from .policy_get_response import PolicyGetResponse as PolicyGetResponse from .approval_group_param import ApprovalGroupParam as ApprovalGroupParam +from .policy_create_params import PolicyCreateParams as PolicyCreateParams +from .policy_list_response import PolicyListResponse as PolicyListResponse +from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams from .user_policy_check_geo import UserPolicyCheckGeo as UserPolicyCheckGeo +from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse +from .policy_delete_response import PolicyDeleteResponse as PolicyDeleteResponse +from .policy_update_response import PolicyUpdateResponse as PolicyUpdateResponse from .user_policy_check_list_response import UserPolicyCheckListResponse as UserPolicyCheckListResponse diff --git a/src/cloudflare/types/zero_trust/access/applications/ca_create_response.py b/src/cloudflare/types/zero_trust/access/applications/ca_create_response.py new file mode 100644 index 00000000000..c0a4d7af889 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/ca_create_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +__all__ = ["CACreateResponse"] + +CACreateResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/zero_trust/access/applications/ca_delete_response.py b/src/cloudflare/types/zero_trust/access/applications/ca_delete_response.py new file mode 100644 index 00000000000..1067f82cd87 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/ca_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["CADeleteResponse"] + + +class CADeleteResponse(BaseModel): + id: Optional[str] = None + """The ID of the CA.""" diff --git a/src/cloudflare/types/zero_trust/access/applications/ca_get_response.py b/src/cloudflare/types/zero_trust/access/applications/ca_get_response.py new file mode 100644 index 00000000000..8a2b05ffa92 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/ca_get_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +__all__ = ["CAGetResponse"] + +CAGetResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py new file mode 100644 index 00000000000..358425ac3f4 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py @@ -0,0 +1,79 @@ +# 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 ..decision import Decision +from ...access_rule_param import AccessRuleParam +from .approval_group_param import ApprovalGroupParam + +__all__ = ["PolicyCreateParams"] + + +class PolicyCreateParams(TypedDict, total=False): + decision: Required[Decision] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py new file mode 100644 index 00000000000..733932309f2 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..decision import Decision +from ....._models import BaseModel +from ...access_rule import AccessRule +from .approval_group import ApprovalGroup + +__all__ = ["PolicyCreateResponse"] + + +class PolicyCreateResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_delete_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_delete_response.py new file mode 100644 index 00000000000..1d70dce656a --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["PolicyDeleteResponse"] + + +class PolicyDeleteResponse(BaseModel): + id: Optional[str] = None + """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py new file mode 100644 index 00000000000..58009c55c07 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..decision import Decision +from ....._models import BaseModel +from ...access_rule import AccessRule +from .approval_group import ApprovalGroup + +__all__ = ["PolicyGetResponse"] + + +class PolicyGetResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py new file mode 100644 index 00000000000..af894ba6981 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..decision import Decision +from ....._models import BaseModel +from ...access_rule import AccessRule +from .approval_group import ApprovalGroup + +__all__ = ["PolicyListResponse"] + + +class PolicyListResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py new file mode 100644 index 00000000000..88019eb676e --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py @@ -0,0 +1,82 @@ +# 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 ..decision import Decision +from ...access_rule_param import AccessRuleParam +from .approval_group_param import ApprovalGroupParam + +__all__ = ["PolicyUpdateParams"] + + +class PolicyUpdateParams(TypedDict, total=False): + app_id: Required[str] + """UUID""" + + decision: Required[Decision] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + precedence: int + """The order of execution for this policy. + + Must be unique for each policy within an app. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py new file mode 100644 index 00000000000..a3649ba0866 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from ..decision import Decision +from ....._models import BaseModel +from ...access_rule import AccessRule +from .approval_group import ApprovalGroup + +__all__ = ["PolicyUpdateResponse"] + + +class PolicyUpdateResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/bookmark.py b/src/cloudflare/types/zero_trust/access/bookmark.py new file mode 100644 index 00000000000..5d20f8b964c --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/bookmark.py @@ -0,0 +1,29 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["Bookmark"] + + +class Bookmark(BaseModel): + id: Optional[str] = None + """The unique identifier for the Bookmark application.""" + + app_launcher_visible: Optional[bool] = None + """Displays the application in the App Launcher.""" + + created_at: Optional[datetime] = None + + domain: Optional[str] = None + """The domain of the Bookmark application.""" + + logo_url: Optional[str] = None + """The image URL for the logo shown in the App Launcher dashboard.""" + + name: Optional[str] = None + """The name of the Bookmark application.""" + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/bookmark_create_params.py b/src/cloudflare/types/zero_trust/access/bookmark_create_params.py new file mode 100644 index 00000000000..a0278f281d7 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/bookmark_create_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["BookmarkCreateParams"] + + +class BookmarkCreateParams(TypedDict, total=False): + account_id: Required[str] + + body: Required[object] diff --git a/src/cloudflare/types/zero_trust/access/bookmark_delete_response.py b/src/cloudflare/types/zero_trust/access/bookmark_delete_response.py new file mode 100644 index 00000000000..93d03aba051 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/bookmark_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["BookmarkDeleteResponse"] + + +class BookmarkDeleteResponse(BaseModel): + id: Optional[str] = None + """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/bookmark_update_params.py b/src/cloudflare/types/zero_trust/access/bookmark_update_params.py new file mode 100644 index 00000000000..82a32f4b5e0 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/bookmark_update_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["BookmarkUpdateParams"] + + +class BookmarkUpdateParams(TypedDict, total=False): + account_id: Required[str] + + body: Required[object] diff --git a/src/cloudflare/types/zero_trust/access/certificate_delete_response.py b/src/cloudflare/types/zero_trust/access/certificate_delete_response.py new file mode 100644 index 00000000000..01177266648 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/certificate_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["CertificateDeleteResponse"] + + +class CertificateDeleteResponse(BaseModel): + id: Optional[str] = None + """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/certificate_update_params.py b/src/cloudflare/types/zero_trust/access/certificate_update_params.py new file mode 100644 index 00000000000..e546c333f21 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/certificate_update_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Required, TypedDict + +from .associated_hostnames import AssociatedHostnames + +__all__ = ["CertificateUpdateParams"] + + +class CertificateUpdateParams(TypedDict, total=False): + associated_hostnames: Required[List[AssociatedHostnames]] + """The hostnames of the applications that will use this certificate.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + name: str + """The name of the certificate.""" diff --git a/src/cloudflare/types/zero_trust/access/custom_page.py b/src/cloudflare/types/zero_trust/access/custom_page.py new file mode 100644 index 00000000000..4593071d37a --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/custom_page.py @@ -0,0 +1,30 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["CustomPage"] + + +class CustomPage(BaseModel): + custom_html: str + """Custom page HTML.""" + + name: str + """Custom page name.""" + + type: Literal["identity_denied", "forbidden"] + """Custom page type.""" + + app_count: Optional[int] = None + """Number of apps the custom page is assigned to.""" + + created_at: Optional[datetime] = None + + uid: Optional[str] = None + """UUID""" + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/custom_page_create_params.py b/src/cloudflare/types/zero_trust/access/custom_page_create_params.py new file mode 100644 index 00000000000..585692c65ba --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/custom_page_create_params.py @@ -0,0 +1,24 @@ +# 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__ = ["CustomPageCreateParams"] + + +class CustomPageCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + custom_html: Required[str] + """Custom page HTML.""" + + name: Required[str] + """Custom page name.""" + + type: Required[Literal["identity_denied", "forbidden"]] + """Custom page type.""" + + app_count: int + """Number of apps the custom page is assigned to.""" diff --git a/src/cloudflare/types/zero_trust/access/custom_page_delete_response.py b/src/cloudflare/types/zero_trust/access/custom_page_delete_response.py new file mode 100644 index 00000000000..bb6e38bee3b --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/custom_page_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["CustomPageDeleteResponse"] + + +class CustomPageDeleteResponse(BaseModel): + id: Optional[str] = None + """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/custom_page_update_params.py b/src/cloudflare/types/zero_trust/access/custom_page_update_params.py new file mode 100644 index 00000000000..14d5ec2ca9c --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/custom_page_update_params.py @@ -0,0 +1,24 @@ +# 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__ = ["CustomPageUpdateParams"] + + +class CustomPageUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + custom_html: Required[str] + """Custom page HTML.""" + + name: Required[str] + """Custom page name.""" + + type: Required[Literal["identity_denied", "forbidden"]] + """Custom page type.""" + + app_count: int + """Number of apps the custom page is assigned to.""" diff --git a/src/cloudflare/types/zero_trust/access/custom_page_without_html.py b/src/cloudflare/types/zero_trust/access/custom_page_without_html.py new file mode 100644 index 00000000000..d0aecfa61f5 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/custom_page_without_html.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["CustomPageWithoutHTML"] + + +class CustomPageWithoutHTML(BaseModel): + name: str + """Custom page name.""" + + type: Literal["identity_denied", "forbidden"] + """Custom page type.""" + + app_count: Optional[int] = None + """Number of apps the custom page is assigned to.""" + + created_at: Optional[datetime] = None + + uid: Optional[str] = None + """UUID""" + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/group_delete_response.py b/src/cloudflare/types/zero_trust/access/group_delete_response.py new file mode 100644 index 00000000000..4f17b96b793 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/group_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["GroupDeleteResponse"] + + +class GroupDeleteResponse(BaseModel): + id: Optional[str] = None + """UUID""" diff --git a/src/cloudflare/types/zero_trust/access/group_update_params.py b/src/cloudflare/types/zero_trust/access/group_update_params.py new file mode 100644 index 00000000000..68672edb40e --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/group_update_params.py @@ -0,0 +1,42 @@ +# 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 ..access_rule_param import AccessRuleParam + +__all__ = ["GroupUpdateParams"] + + +class GroupUpdateParams(TypedDict, total=False): + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access group.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match a policy, a user cannot meet any of the Exclude rules. + """ + + is_default: bool + """Whether this is the default group""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match a policy, a user must meet all of the Require rules. + """ diff --git a/src/cloudflare/types/zero_trust/access/key_get_response.py b/src/cloudflare/types/zero_trust/access/key_get_response.py new file mode 100644 index 00000000000..79cfd988d58 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/key_get_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union + +__all__ = ["KeyGetResponse"] + +KeyGetResponse = Union[str, object] diff --git a/src/cloudflare/types/zero_trust/access/key_rotate_response.py b/src/cloudflare/types/zero_trust/access/key_rotate_response.py new file mode 100644 index 00000000000..1ababd82b3c --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/key_rotate_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union + +__all__ = ["KeyRotateResponse"] + +KeyRotateResponse = Union[str, object] diff --git a/src/cloudflare/types/zero_trust/access/key_update_params.py b/src/cloudflare/types/zero_trust/access/key_update_params.py new file mode 100644 index 00000000000..b42e919649b --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/key_update_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["KeyUpdateParams"] + + +class KeyUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + key_rotation_interval_days: Required[float] + """The number of days between key rotations.""" diff --git a/src/cloudflare/types/zero_trust/access/key_update_response.py b/src/cloudflare/types/zero_trust/access/key_update_response.py new file mode 100644 index 00000000000..a63396635f6 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/key_update_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union + +__all__ = ["KeyUpdateResponse"] + +KeyUpdateResponse = Union[str, object] diff --git a/src/cloudflare/types/zero_trust/access/logs/__init__.py b/src/cloudflare/types/zero_trust/access/logs/__init__.py index f8ee8b14b1c..8044ec713b3 100644 --- a/src/cloudflare/types/zero_trust/access/logs/__init__.py +++ b/src/cloudflare/types/zero_trust/access/logs/__init__.py @@ -1,3 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .access_requests import AccessRequests as AccessRequests +from .access_request_list_response import AccessRequestListResponse as AccessRequestListResponse diff --git a/src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py b/src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py new file mode 100644 index 00000000000..b48a60046d9 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/logs/access_request_list_response.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .access_requests import AccessRequests + +__all__ = ["AccessRequestListResponse"] + +AccessRequestListResponse = List[AccessRequests] diff --git a/src/cloudflare/types/zero_trust/access/service_token_rotate_response.py b/src/cloudflare/types/zero_trust/access/service_token_rotate_response.py new file mode 100644 index 00000000000..b4a74bcfc69 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/service_token_rotate_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["ServiceTokenRotateResponse"] + + +class ServiceTokenRotateResponse(BaseModel): + id: Optional[str] = None + """The ID of the service token.""" + + client_id: Optional[str] = None + """The Client ID for the service token. + + Access will check for this value in the `CF-Access-Client-ID` request header. + """ + + client_secret: Optional[str] = None + """The Client Secret for the service token. + + Access will check for this value in the `CF-Access-Client-Secret` request + header. + """ + + created_at: Optional[datetime] = None + + duration: Optional[str] = None + """The duration for how long the service token will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. The default is 1 year in hours (8760h). + """ + + name: Optional[str] = None + """The name of the service token.""" + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/service_token_update_params.py b/src/cloudflare/types/zero_trust/access/service_token_update_params.py new file mode 100644 index 00000000000..93dc5d1c5bc --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/service_token_update_params.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["ServiceTokenUpdateParams"] + + +class ServiceTokenUpdateParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + duration: str + """The duration for how long the service token will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. The default is 1 year in hours (8760h). + """ + + name: str + """The name of the service token.""" diff --git a/src/cloudflare/types/zero_trust/access/tag.py b/src/cloudflare/types/zero_trust/access/tag.py new file mode 100644 index 00000000000..bf386015544 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/tag.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ...._models import BaseModel + +__all__ = ["Tag"] + + +class Tag(BaseModel): + name: str + """The name of the tag""" + + app_count: Optional[int] = None + """The number of applications that have this tag""" + + created_at: Optional[datetime] = None + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/tag_create_params.py b/src/cloudflare/types/zero_trust/access/tag_create_params.py new file mode 100644 index 00000000000..b28c8a8cc73 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/tag_create_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["TagCreateParams"] + + +class TagCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + name: Required[str] + """The name of the tag""" diff --git a/src/cloudflare/types/zero_trust/access/tag_delete_response.py b/src/cloudflare/types/zero_trust/access/tag_delete_response.py new file mode 100644 index 00000000000..8ffb88e56bf --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/tag_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["TagDeleteResponse"] + + +class TagDeleteResponse(BaseModel): + name: Optional[str] = None + """The name of the tag""" diff --git a/src/cloudflare/types/zero_trust/access/tag_update_params.py b/src/cloudflare/types/zero_trust/access/tag_update_params.py new file mode 100644 index 00000000000..594920024fd --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/tag_update_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["TagUpdateParams"] + + +class TagUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + name: Required[str] + """The name of the tag""" diff --git a/src/cloudflare/types/zero_trust/access/users/__init__.py b/src/cloudflare/types/zero_trust/access/users/__init__.py index f8ee8b14b1c..5f23decf1fe 100644 --- a/src/cloudflare/types/zero_trust/access/users/__init__.py +++ b/src/cloudflare/types/zero_trust/access/users/__init__.py @@ -1,3 +1,8 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .identity import Identity as Identity +from .failed_login_list_response import FailedLoginListResponse as FailedLoginListResponse +from .active_session_get_response import ActiveSessionGetResponse as ActiveSessionGetResponse +from .active_session_list_response import ActiveSessionListResponse as ActiveSessionListResponse diff --git a/src/cloudflare/types/zero_trust/access/users/active_session_get_response.py b/src/cloudflare/types/zero_trust/access/users/active_session_get_response.py new file mode 100644 index 00000000000..2414f09a55c --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/users/active_session_get_response.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Optional + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel +from ..applications.user_policy_check_geo import UserPolicyCheckGeo + +__all__ = ["ActiveSessionGetResponse", "DeviceSessions", "DevicePosture", "DevicePostureCheck", "IdP", "MTLSAuth"] + + +class DeviceSessions(BaseModel): + last_authenticated: Optional[float] = None + + +class DevicePostureCheck(BaseModel): + exists: Optional[bool] = None + + path: Optional[str] = None + + +class DevicePosture(BaseModel): + id: Optional[str] = None + + check: Optional[DevicePostureCheck] = None + + data: Optional[object] = None + + description: Optional[str] = None + + error: Optional[str] = None + + rule_name: Optional[str] = None + + success: Optional[bool] = None + + timestamp: Optional[str] = None + + type: Optional[str] = None + + +class IdP(BaseModel): + id: Optional[str] = None + + type: Optional[str] = None + + +class MTLSAuth(BaseModel): + auth_status: Optional[str] = None + + cert_issuer_dn: Optional[str] = None + + cert_issuer_ski: Optional[str] = None + + cert_presented: Optional[bool] = None + + cert_serial: Optional[str] = None + + +class ActiveSessionGetResponse(BaseModel): + account_id: Optional[str] = None + + auth_status: Optional[str] = None + + common_name: Optional[str] = None + + device_id: Optional[str] = None + + device_sessions: Optional[Dict[str, DeviceSessions]] = None + + device_posture: Optional[Dict[str, DevicePosture]] = FieldInfo(alias="devicePosture", default=None) + + email: Optional[str] = None + + geo: Optional[UserPolicyCheckGeo] = None + + iat: Optional[float] = None + + idp: Optional[IdP] = None + + ip: Optional[str] = None + + is_gateway: Optional[bool] = None + + is_warp: Optional[bool] = None + + is_active: Optional[bool] = FieldInfo(alias="isActive", default=None) + + mtls_auth: Optional[MTLSAuth] = None + + service_token_id: Optional[str] = None + + service_token_status: Optional[bool] = None + + user_uuid: Optional[str] = None + + version: Optional[float] = None diff --git a/src/cloudflare/types/zero_trust/access/users/active_session_list_response.py b/src/cloudflare/types/zero_trust/access/users/active_session_list_response.py new file mode 100644 index 00000000000..ac0f4059a81 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/users/active_session_list_response.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Optional + +from ....._models import BaseModel + +__all__ = ["ActiveSessionListResponse", "Metadata", "MetadataApps"] + + +class MetadataApps(BaseModel): + hostname: Optional[str] = None + + name: Optional[str] = None + + type: Optional[str] = None + + uid: Optional[str] = None + + +class Metadata(BaseModel): + apps: Optional[Dict[str, MetadataApps]] = None + + expires: Optional[int] = None + + iat: Optional[int] = None + + nonce: Optional[str] = None + + ttl: Optional[int] = None + + +class ActiveSessionListResponse(BaseModel): + expiration: Optional[int] = None + + metadata: Optional[Metadata] = None + + name: Optional[str] = None diff --git a/src/cloudflare/types/zero_trust/access/users/failed_login_list_response.py b/src/cloudflare/types/zero_trust/access/users/failed_login_list_response.py new file mode 100644 index 00000000000..358f7afc443 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/users/failed_login_list_response.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["FailedLoginListResponse"] + + +class FailedLoginListResponse(BaseModel): + expiration: Optional[int] = None + + metadata: Optional[object] = None diff --git a/src/cloudflare/types/zero_trust/access/users/identity.py b/src/cloudflare/types/zero_trust/access/users/identity.py new file mode 100644 index 00000000000..52f27fee6c2 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/users/identity.py @@ -0,0 +1,96 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Optional + +from pydantic import Field as FieldInfo + +from ....._models import BaseModel +from ..applications.user_policy_check_geo import UserPolicyCheckGeo + +__all__ = ["Identity", "DeviceSessions", "DevicePosture", "DevicePostureCheck", "IdP", "MTLSAuth"] + + +class DeviceSessions(BaseModel): + last_authenticated: Optional[float] = None + + +class DevicePostureCheck(BaseModel): + exists: Optional[bool] = None + + path: Optional[str] = None + + +class DevicePosture(BaseModel): + id: Optional[str] = None + + check: Optional[DevicePostureCheck] = None + + data: Optional[object] = None + + description: Optional[str] = None + + error: Optional[str] = None + + rule_name: Optional[str] = None + + success: Optional[bool] = None + + timestamp: Optional[str] = None + + type: Optional[str] = None + + +class IdP(BaseModel): + id: Optional[str] = None + + type: Optional[str] = None + + +class MTLSAuth(BaseModel): + auth_status: Optional[str] = None + + cert_issuer_dn: Optional[str] = None + + cert_issuer_ski: Optional[str] = None + + cert_presented: Optional[bool] = None + + cert_serial: Optional[str] = None + + +class Identity(BaseModel): + account_id: Optional[str] = None + + auth_status: Optional[str] = None + + common_name: Optional[str] = None + + device_id: Optional[str] = None + + device_sessions: Optional[Dict[str, DeviceSessions]] = None + + device_posture: Optional[Dict[str, DevicePosture]] = FieldInfo(alias="devicePosture", default=None) + + email: Optional[str] = None + + geo: Optional[UserPolicyCheckGeo] = None + + iat: Optional[float] = None + + idp: Optional[IdP] = None + + ip: Optional[str] = None + + is_gateway: Optional[bool] = None + + is_warp: Optional[bool] = None + + mtls_auth: Optional[MTLSAuth] = None + + service_token_id: Optional[str] = None + + service_token_status: Optional[bool] = None + + user_uuid: Optional[str] = None + + version: Optional[float] = None diff --git a/src/cloudflare/types/zero_trust/identity_provider_delete_response.py b/src/cloudflare/types/zero_trust/identity_provider_delete_response.py new file mode 100644 index 00000000000..4c84ce5d197 --- /dev/null +++ b/src/cloudflare/types/zero_trust/identity_provider_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["IdentityProviderDeleteResponse"] + + +class IdentityProviderDeleteResponse(BaseModel): + id: Optional[str] = None + """UUID""" diff --git a/src/cloudflare/types/zero_trust/identity_provider_update_params.py b/src/cloudflare/types/zero_trust/identity_provider_update_params.py new file mode 100644 index 00000000000..9667f9f04ba --- /dev/null +++ b/src/cloudflare/types/zero_trust/identity_provider_update_params.py @@ -0,0 +1,697 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union, Iterable +from typing_extensions import Literal, Required, TypedDict + +from .scim_config_param import ScimConfigParam +from .identity_provider_type import IdentityProviderType +from .generic_oauth_config_param import GenericOAuthConfigParam + +__all__ = [ + "IdentityProviderUpdateParams", + "AzureAD", + "AzureADConfig", + "AccessCentrify", + "AccessCentrifyConfig", + "AccessFacebook", + "AccessGitHub", + "AccessGoogle", + "AccessGoogleConfig", + "AccessGoogleApps", + "AccessGoogleAppsConfig", + "AccessLinkedin", + "AccessOIDC", + "AccessOIDCConfig", + "AccessOkta", + "AccessOktaConfig", + "AccessOnelogin", + "AccessOneloginConfig", + "AccessPingone", + "AccessPingoneConfig", + "AccessSAML", + "AccessSAMLConfig", + "AccessSAMLConfigHeaderAttribute", + "AccessYandex", + "AccessOnetimepin", +] + + +class AzureAD(TypedDict, total=False): + config: Required[AzureADConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AzureADConfig(TypedDict, total=False): + claims: List[str] + """Custom claims""" + + client_id: str + """Your OAuth Client ID""" + + client_secret: str + """Your OAuth Client Secret""" + + conditional_access_enabled: bool + """Should Cloudflare try to load authentication contexts from your account""" + + directory_id: str + """Your Azure directory uuid""" + + email_claim_name: str + """The claim name for email in the id_token response.""" + + prompt: Literal["login", "select_account", "none"] + """Indicates the type of user interaction that is required. + + prompt=login forces the user to enter their credentials on that request, + negating single-sign on. prompt=none is the opposite. It ensures that the user + isn't presented with any interactive prompt. If the request can't be completed + silently by using single-sign on, the Microsoft identity platform returns an + interaction_required error. prompt=select_account interrupts single sign-on + providing account selection experience listing all the accounts either in + session or any remembered account or an option to choose to use a different + account altogether. + """ + + support_groups: bool + """Should Cloudflare try to load groups from your account""" + + +class AccessCentrify(TypedDict, total=False): + config: Required[AccessCentrifyConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessCentrifyConfig(TypedDict, total=False): + centrify_account: str + """Your centrify account url""" + + centrify_app_id: str + """Your centrify app id""" + + claims: List[str] + """Custom claims""" + + client_id: str + """Your OAuth Client ID""" + + client_secret: str + """Your OAuth Client Secret""" + + email_claim_name: str + """The claim name for email in the id_token response.""" + + +class AccessFacebook(TypedDict, total=False): + config: Required[GenericOAuthConfigParam] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessGitHub(TypedDict, total=False): + config: Required[GenericOAuthConfigParam] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessGoogle(TypedDict, total=False): + config: Required[AccessGoogleConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessGoogleConfig(TypedDict, total=False): + claims: List[str] + """Custom claims""" + + client_id: str + """Your OAuth Client ID""" + + client_secret: str + """Your OAuth Client Secret""" + + email_claim_name: str + """The claim name for email in the id_token response.""" + + +class AccessGoogleApps(TypedDict, total=False): + config: Required[AccessGoogleAppsConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessGoogleAppsConfig(TypedDict, total=False): + apps_domain: str + """Your companies TLD""" + + claims: List[str] + """Custom claims""" + + client_id: str + """Your OAuth Client ID""" + + client_secret: str + """Your OAuth Client Secret""" + + email_claim_name: str + """The claim name for email in the id_token response.""" + + +class AccessLinkedin(TypedDict, total=False): + config: Required[GenericOAuthConfigParam] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessOIDC(TypedDict, total=False): + config: Required[AccessOIDCConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessOIDCConfig(TypedDict, total=False): + auth_url: str + """The authorization_endpoint URL of your IdP""" + + certs_url: str + """The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens""" + + claims: List[str] + """Custom claims""" + + client_id: str + """Your OAuth Client ID""" + + client_secret: str + """Your OAuth Client Secret""" + + email_claim_name: str + """The claim name for email in the id_token response.""" + + scopes: List[str] + """OAuth scopes""" + + token_url: str + """The token_endpoint URL of your IdP""" + + +class AccessOkta(TypedDict, total=False): + config: Required[AccessOktaConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessOktaConfig(TypedDict, total=False): + authorization_server_id: str + """Your okta authorization server id""" + + claims: List[str] + """Custom claims""" + + client_id: str + """Your OAuth Client ID""" + + client_secret: str + """Your OAuth Client Secret""" + + email_claim_name: str + """The claim name for email in the id_token response.""" + + okta_account: str + """Your okta account url""" + + +class AccessOnelogin(TypedDict, total=False): + config: Required[AccessOneloginConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessOneloginConfig(TypedDict, total=False): + claims: List[str] + """Custom claims""" + + client_id: str + """Your OAuth Client ID""" + + client_secret: str + """Your OAuth Client Secret""" + + email_claim_name: str + """The claim name for email in the id_token response.""" + + onelogin_account: str + """Your OneLogin account url""" + + +class AccessPingone(TypedDict, total=False): + config: Required[AccessPingoneConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessPingoneConfig(TypedDict, total=False): + claims: List[str] + """Custom claims""" + + client_id: str + """Your OAuth Client ID""" + + client_secret: str + """Your OAuth Client Secret""" + + email_claim_name: str + """The claim name for email in the id_token response.""" + + ping_env_id: str + """Your PingOne environment identifier""" + + +class AccessSAML(TypedDict, total=False): + config: Required[AccessSAMLConfig] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessSAMLConfigHeaderAttribute(TypedDict, total=False): + attribute_name: str + """attribute name from the IDP""" + + header_name: str + """header that will be added on the request to the origin""" + + +class AccessSAMLConfig(TypedDict, total=False): + attributes: List[str] + """ + A list of SAML attribute names that will be added to your signed JWT token and + can be used in SAML policy rules. + """ + + email_attribute_name: str + """The attribute name for email in the SAML response.""" + + header_attributes: Iterable[AccessSAMLConfigHeaderAttribute] + """ + Add a list of attribute names that will be returned in the response header from + the Access callback. + """ + + idp_public_certs: List[str] + """X509 certificate to verify the signature in the SAML authentication response""" + + issuer_url: str + """IdP Entity ID or Issuer URL""" + + sign_request: bool + """Sign the SAML authentication request with Access credentials. + + To verify the signature, use the public key from the Access certs endpoints. + """ + + sso_target_url: str + """URL to send the SAML authentication requests to""" + + +class AccessYandex(TypedDict, total=False): + config: Required[GenericOAuthConfigParam] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +class AccessOnetimepin(TypedDict, total=False): + config: Required[object] + """The configuration parameters for the identity provider. + + To view the required parameters for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + name: Required[str] + """The name of the identity provider, shown to users on the login page.""" + + type: Required[IdentityProviderType] + """The type of identity provider. + + To determine the value for a specific provider, refer to our + [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + """ + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + scim_config: ScimConfigParam + """ + The configuration settings for enabling a System for Cross-Domain Identity + Management (SCIM) with the identity provider. + """ + + +IdentityProviderUpdateParams = Union[ + AzureAD, + AccessCentrify, + AccessFacebook, + AccessGitHub, + AccessGoogle, + AccessGoogleApps, + AccessLinkedin, + AccessOIDC, + AccessOkta, + AccessOnelogin, + AccessPingone, + AccessSAML, + AccessYandex, + AccessOnetimepin, +] diff --git a/src/cloudflare/types/zero_trust/seat.py b/src/cloudflare/types/zero_trust/seat.py new file mode 100644 index 00000000000..bf56403a543 --- /dev/null +++ b/src/cloudflare/types/zero_trust/seat.py @@ -0,0 +1,23 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["Seat"] + + +class Seat(BaseModel): + access_seat: Optional[bool] = None + """True if the seat is part of Access.""" + + created_at: Optional[datetime] = None + + gateway_seat: Optional[bool] = None + """True if the seat is part of Gateway.""" + + seat_uid: Optional[str] = None + """Identifier""" + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/seat_edit_params.py b/src/cloudflare/types/zero_trust/seat_edit_params.py new file mode 100644 index 00000000000..5e6696944c1 --- /dev/null +++ b/src/cloudflare/types/zero_trust/seat_edit_params.py @@ -0,0 +1,23 @@ +# 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 + +__all__ = ["SeatEditParams", "Body"] + + +class SeatEditParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[Iterable[Body]] + + +class Body(TypedDict, total=False): + access_seat: Required[bool] + """True if the seat is part of Access.""" + + gateway_seat: Required[bool] + """True if the seat is part of Gateway.""" diff --git a/src/cloudflare/types/zero_trust/seat_edit_response.py b/src/cloudflare/types/zero_trust/seat_edit_response.py new file mode 100644 index 00000000000..a29d3feb33b --- /dev/null +++ b/src/cloudflare/types/zero_trust/seat_edit_response.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .seat import Seat + +__all__ = ["SeatEditResponse"] + +SeatEditResponse = List[Seat] diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py index 1496d433303..b457e152f24 100644 --- a/tests/api_resources/rulesets/test_rules.py +++ b/tests/api_resources/rulesets/test_rules.py @@ -1394,6 +1394,156 @@ def test_path_params_create_overload_16(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_17(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_delete(self, client: Cloudflare) -> None: @@ -3072,6 +3222,184 @@ def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + class TestAsyncRules: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -4313,7 +4641,86 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy "respect_strong_etags": True, "serve_stale": {"disable_stale_while_updating": True}, }, - description="Set cache settings when the hostname address is not example.com", + description="Set cache settings when the hostname address is not example.com", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log_custom_field", + action_parameters={ + "cookie_fields": [{"name": "cookie_name_1"}], + "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], + "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], + }, + description="Log custom field when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4323,7 +4730,7 @@ async def test_method_create_with_all_params_overload_15(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4336,7 +4743,7 @@ async def test_raw_response_create_overload_15(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4351,7 +4758,7 @@ async def test_streaming_response_create_overload_15(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -4372,7 +4779,7 @@ async def test_path_params_create_overload_15(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4381,18 +4788,14 @@ async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="log_custom_field", - action_parameters={ - "cookie_fields": [{"name": "cookie_name_1"}], - "request_fields": [{"name": "http_request_header_name_1_in_lower_case"}], - "response_fields": [{"name": "http_response_header_name_1_in_lower_case"}], - }, - description="Log custom field when the IP address is not 1.1.1.1", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -4402,7 +4805,7 @@ async def test_method_create_with_all_params_overload_16(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4415,7 +4818,7 @@ async def test_raw_response_create_overload_16(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -4430,7 +4833,82 @@ async def test_streaming_response_create_overload_16(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_18(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( "", @@ -6126,3 +6604,181 @@ async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="ddos_dynamic", + action_parameters={}, + description="Performs a specific action according to a set of internal guidelines defined by Cloudflare.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="force_connection_close", + action_parameters={}, + description="Closes ongoing HTTP connections. This action does not block a request, but it forces the client to reconnect. For HTTP/2 and HTTP/3 connections, the connection will be closed even if it breaks other requests running on the same connection.", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + ) diff --git a/tests/api_resources/zero_trust/access/applications/test_cas.py b/tests/api_resources/zero_trust/access/applications/test_cas.py index e80d89059db..d544d4b922b 100644 --- a/tests/api_resources/zero_trust/access/applications/test_cas.py +++ b/tests/api_resources/zero_trust/access/applications/test_cas.py @@ -3,14 +3,14 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access.applications import CA +from cloudflare.types.zero_trust.access.applications import CA, CAGetResponse, CACreateResponse, CADeleteResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -18,6 +18,73 @@ class TestCAs: 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: + ca = client.zero_trust.access.applications.cas.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + ca = client.zero_trust.access.applications.cas.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.cas.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ca = response.parse() + assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.cas.with_streaming_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ca = response.parse() + assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -73,10 +140,211 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + ca = client.zero_trust.access.applications.cas.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + ca = client.zero_trust.access.applications.cas.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.cas.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ca = response.parse() + assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.cas.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ca = response.parse() + assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + ca = client.zero_trust.access.applications.cas.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + ca = client.zero_trust.access.applications.cas.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.cas.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ca = response.parse() + assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.cas.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ca = response.parse() + assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.cas.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + class TestAsyncCAs: 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: + ca = await async_client.zero_trust.access.applications.cas.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + ca = await async_client.zero_trust.access.applications.cas.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CACreateResponse], ca, 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.access.applications.cas.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ca = await response.parse() + assert_matches_type(Optional[CACreateResponse], ca, 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.access.applications.cas.with_streaming_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ca = await response.parse() + assert_matches_type(Optional[CACreateResponse], ca, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.create( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -131,3 +399,137 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.applications.cas.with_raw_response.list( account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + ca = await async_client.zero_trust.access.applications.cas.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + ca = await async_client.zero_trust.access.applications.cas.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.applications.cas.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ca = await response.parse() + assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.applications.cas.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ca = await response.parse() + assert_matches_type(Optional[CADeleteResponse], ca, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + ca = await async_client.zero_trust.access.applications.cas.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + ca = await async_client.zero_trust.access.applications.cas.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CAGetResponse], ca, 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.access.applications.cas.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ca = await response.parse() + assert_matches_type(Optional[CAGetResponse], ca, 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.access.applications.cas.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ca = await response.parse() + assert_matches_type(Optional[CAGetResponse], ca, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.cas.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) diff --git a/tests/api_resources/zero_trust/access/applications/test_policies.py b/tests/api_resources/zero_trust/access/applications/test_policies.py new file mode 100644 index 00000000000..767aa03ea30 --- /dev/null +++ b/tests/api_resources/zero_trust/access/applications/test_policies.py @@ -0,0 +1,1105 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.access.applications import ( + PolicyGetResponse, + PolicyListResponse, + PolicyCreateResponse, + PolicyDeleteResponse, + PolicyUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestPolicies: + 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.access.applications.policies.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + assert_matches_type(Optional[PolicyCreateResponse], policy, 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.access.applications.policies.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + approval_groups=[ + { + "approvals_needed": 1, + "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "string", + }, + { + "approvals_needed": 3, + "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", + }, + ], + approval_required=True, + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + isolation_required=False, + precedence=0, + purpose_justification_prompt="Please enter a justification for entering this protected domain.", + purpose_justification_required=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + session_duration="24h", + ) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.policies.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.policies.with_streaming_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.create( + "", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + approval_groups=[ + { + "approvals_needed": 1, + "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "string", + }, + { + "approvals_needed": 3, + "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", + }, + ], + approval_required=True, + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + isolation_required=False, + precedence=0, + purpose_justification_prompt="Please enter a justification for entering this protected domain.", + purpose_justification_required=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + session_duration="24h", + ) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.policies.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.update( + "", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.policies.with_streaming_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.list( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + 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"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.policies.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) 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"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.delete( + "", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.applications.policies.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.applications.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.applications.policies.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.get( + "", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.applications.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + +class TestAsyncPolicies: + 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.access.applications.policies.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + assert_matches_type(Optional[PolicyCreateResponse], policy, 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.access.applications.policies.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + approval_groups=[ + { + "approvals_needed": 1, + "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "string", + }, + { + "approvals_needed": 3, + "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", + }, + ], + approval_required=True, + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + isolation_required=False, + precedence=0, + purpose_justification_prompt="Please enter a justification for entering this protected domain.", + purpose_justification_required=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + session_duration="24h", + ) + assert_matches_type(Optional[PolicyCreateResponse], policy, 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.access.applications.policies.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(Optional[PolicyCreateResponse], policy, 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.access.applications.policies.with_streaming_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) 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[PolicyCreateResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.create( + "", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + approval_groups=[ + { + "approvals_needed": 1, + "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "string", + }, + { + "approvals_needed": 3, + "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", + }, + ], + approval_required=True, + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + isolation_required=False, + precedence=0, + purpose_justification_prompt="Please enter a justification for entering this protected domain.", + purpose_justification_required=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + session_duration="24h", + ) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.applications.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.applications.policies.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) 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[PolicyUpdateResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.update( + "", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.applications.policies.with_streaming_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) 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[PolicyListResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.list( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.applications.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + 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"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.applications.policies.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) 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"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.delete( + "", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @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.access.applications.policies.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.applications.policies.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[PolicyGetResponse], policy, 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.access.applications.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(Optional[PolicyGetResponse], policy, 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.access.applications.policies.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) 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[PolicyGetResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.get( + "", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.applications.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + app_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) diff --git a/tests/api_resources/zero_trust/access/logs/__init__.py b/tests/api_resources/zero_trust/access/logs/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/zero_trust/access/logs/__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/access/logs/test_access_requests.py b/tests/api_resources/zero_trust/access/logs/test_access_requests.py new file mode 100644 index 00000000000..88f7703f1a6 --- /dev/null +++ b/tests/api_resources/zero_trust/access/logs/test_access_requests.py @@ -0,0 +1,98 @@ +# 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.access.logs import AccessRequestListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAccessRequests: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + access_request = client.zero_trust.access.logs.access_requests.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.logs.access_requests.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + access_request = response.parse() + assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.logs.access_requests.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + access_request = response.parse() + assert_matches_type(Optional[AccessRequestListResponse], access_request, 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.access.logs.access_requests.with_raw_response.list( + account_id="", + ) + + +class TestAsyncAccessRequests: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + access_request = await async_client.zero_trust.access.logs.access_requests.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.logs.access_requests.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + access_request = await response.parse() + assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.logs.access_requests.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + access_request = await response.parse() + assert_matches_type(Optional[AccessRequestListResponse], access_request, 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.access.logs.access_requests.with_raw_response.list( + account_id="", + ) diff --git a/tests/api_resources/zero_trust/access/test_applications.py b/tests/api_resources/zero_trust/access/test_applications.py index df34f66d7ef..299c51d1ce9 100644 --- a/tests/api_resources/zero_trust/access/test_applications.py +++ b/tests/api_resources/zero_trust/access/test_applications.py @@ -73,7 +73,20 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -203,7 +216,20 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -368,7 +394,20 @@ def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -520,7 +559,20 @@ def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -644,7 +696,20 @@ def test_method_create_with_all_params_overload_5(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -759,7 +824,20 @@ def test_method_create_with_all_params_overload_6(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -874,7 +952,20 @@ def test_method_create_with_all_params_overload_7(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -1126,7 +1217,20 @@ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -1262,7 +1366,20 @@ def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> N ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -1433,7 +1550,20 @@ def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -1591,7 +1721,20 @@ def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> N name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -1721,7 +1864,20 @@ def test_method_update_with_all_params_overload_5(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -1842,7 +1998,20 @@ def test_method_update_with_all_params_overload_6(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -1963,7 +2132,20 @@ def test_method_update_with_all_params_overload_7(self, client: Cloudflare) -> N "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -2465,7 +2647,20 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -2595,7 +2790,20 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -2760,7 +2968,20 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -2912,7 +3133,20 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -3036,7 +3270,20 @@ async def test_method_create_with_all_params_overload_5(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -3151,7 +3398,20 @@ async def test_method_create_with_all_params_overload_6(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -3266,7 +3526,20 @@ async def test_method_create_with_all_params_overload_7(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -3518,7 +3791,20 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -3654,7 +3940,20 @@ async def test_method_update_with_all_params_overload_2(self, async_client: Asyn ], logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", name="Admin Site", - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], saas_app={ "auth_type": "saml", "consumer_service_url": "https://example.com", @@ -3825,7 +4124,20 @@ async def test_method_update_with_all_params_overload_3(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -3983,7 +4295,20 @@ async def test_method_update_with_all_params_overload_4(self, async_client: Asyn name="Admin Site", options_preflight_bypass=True, path_cookie_attribute=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], same_site_cookie_attribute="strict", scim_config={ "authentication": { @@ -4113,7 +4438,20 @@ async def test_method_update_with_all_params_overload_5(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -4234,7 +4572,20 @@ async def test_method_update_with_all_params_overload_6(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", @@ -4355,7 +4706,20 @@ async def test_method_update_with_all_params_overload_7(self, async_client: Asyn "699d98642c564d2e855e9661899b7252", ], auto_redirect_to_identity=True, - policies=[{"precedence": 0}, {"precedence": 0}, {"precedence": 0}], + policies=[ + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + { + "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "precedence": 0, + }, + ], scim_config={ "authentication": { "password": "string", diff --git a/tests/api_resources/zero_trust/access/test_bookmarks.py b/tests/api_resources/zero_trust/access/test_bookmarks.py new file mode 100644 index 00000000000..5cd16fddf4a --- /dev/null +++ b/tests/api_resources/zero_trust/access/test_bookmarks.py @@ -0,0 +1,506 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.access import ( + Bookmark, + BookmarkDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestBookmarks: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + bookmark = client.zero_trust.access.bookmarks.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.access.bookmarks.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = response.parse() + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.access.bookmarks.with_streaming_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bookmark = response.parse() + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.access.bookmarks.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bookmark_id` but received ''"): + client.zero_trust.access.bookmarks.with_raw_response.create( + "", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + bookmark = client.zero_trust.access.bookmarks.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.bookmarks.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = response.parse() + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.bookmarks.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bookmark = response.parse() + assert_matches_type(Optional[Bookmark], bookmark, 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.access.bookmarks.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bookmark_id` but received ''"): + client.zero_trust.access.bookmarks.with_raw_response.update( + "", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + bookmark = client.zero_trust.access.bookmarks.list( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(SyncSinglePage[Bookmark], bookmark, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.bookmarks.with_raw_response.list( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = response.parse() + assert_matches_type(SyncSinglePage[Bookmark], bookmark, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.bookmarks.with_streaming_response.list( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bookmark = response.parse() + assert_matches_type(SyncSinglePage[Bookmark], bookmark, 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.access.bookmarks.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + bookmark = client.zero_trust.access.bookmarks.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.bookmarks.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = response.parse() + assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.bookmarks.with_streaming_response.delete( + "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" + + bookmark = response.parse() + assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, 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.access.bookmarks.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bookmark_id` but received ''"): + client.zero_trust.access.bookmarks.with_raw_response.delete( + "", + account_id="699d98642c564d2e855e9661899b7252", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + bookmark = client.zero_trust.access.bookmarks.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.bookmarks.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = response.parse() + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.bookmarks.with_streaming_response.get( + "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" + + bookmark = response.parse() + assert_matches_type(Optional[Bookmark], bookmark, 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.access.bookmarks.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bookmark_id` but received ''"): + client.zero_trust.access.bookmarks.with_raw_response.get( + "", + account_id="699d98642c564d2e855e9661899b7252", + ) + + +class TestAsyncBookmarks: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + bookmark = await async_client.zero_trust.access.bookmarks.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.bookmarks.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = await response.parse() + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.bookmarks.with_streaming_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bookmark = await response.parse() + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.access.bookmarks.with_raw_response.create( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bookmark_id` but received ''"): + await async_client.zero_trust.access.bookmarks.with_raw_response.create( + "", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + bookmark = await async_client.zero_trust.access.bookmarks.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.bookmarks.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = await response.parse() + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.bookmarks.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bookmark = await response.parse() + assert_matches_type(Optional[Bookmark], bookmark, 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.access.bookmarks.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bookmark_id` but received ''"): + await async_client.zero_trust.access.bookmarks.with_raw_response.update( + "", + account_id="699d98642c564d2e855e9661899b7252", + body={}, + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + bookmark = await async_client.zero_trust.access.bookmarks.list( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(AsyncSinglePage[Bookmark], bookmark, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.bookmarks.with_raw_response.list( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = await response.parse() + assert_matches_type(AsyncSinglePage[Bookmark], bookmark, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.bookmarks.with_streaming_response.list( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + bookmark = await response.parse() + assert_matches_type(AsyncSinglePage[Bookmark], bookmark, 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.access.bookmarks.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + bookmark = await async_client.zero_trust.access.bookmarks.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.bookmarks.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = await response.parse() + assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.bookmarks.with_streaming_response.delete( + "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" + + bookmark = await response.parse() + assert_matches_type(Optional[BookmarkDeleteResponse], bookmark, 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.access.bookmarks.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bookmark_id` but received ''"): + await async_client.zero_trust.access.bookmarks.with_raw_response.delete( + "", + account_id="699d98642c564d2e855e9661899b7252", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + bookmark = await async_client.zero_trust.access.bookmarks.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.bookmarks.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + bookmark = await response.parse() + assert_matches_type(Optional[Bookmark], bookmark, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.bookmarks.with_streaming_response.get( + "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" + + bookmark = await response.parse() + assert_matches_type(Optional[Bookmark], bookmark, 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.access.bookmarks.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `bookmark_id` but received ''"): + await async_client.zero_trust.access.bookmarks.with_raw_response.get( + "", + account_id="699d98642c564d2e855e9661899b7252", + ) diff --git a/tests/api_resources/zero_trust/access/test_certificates.py b/tests/api_resources/zero_trust/access/test_certificates.py index feb21df3ea5..cfcd002940d 100644 --- a/tests/api_resources/zero_trust/access/test_certificates.py +++ b/tests/api_resources/zero_trust/access/test_certificates.py @@ -10,7 +10,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import Certificate +from cloudflare.types.zero_trust.access import ( + Certificate, + CertificateDeleteResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -86,6 +89,81 @@ def test_path_params_create(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + certificate = client.zero_trust.access.certificates.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + certificate = client.zero_trust.access.certificates.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + name="Allow devs", + ) + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.certificates.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = response.parse() + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.certificates.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = response.parse() + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.update( + "", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -141,6 +219,140 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + certificate = client.zero_trust.access.certificates.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + certificate = client.zero_trust.access.certificates.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = response.parse() + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.certificates.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = response.parse() + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + certificate = client.zero_trust.access.certificates.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + certificate = client.zero_trust.access.certificates.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = response.parse() + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.certificates.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = response.parse() + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + class TestAsyncCertificates: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -213,6 +425,81 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.access.certificates.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.access.certificates.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + name="Allow devs", + ) + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.certificates.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = await response.parse() + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.certificates.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = await response.parse() + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.update( + "", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + associated_hostnames=["admin.example.com", "admin.example.com", "admin.example.com"], + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -267,3 +554,137 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.certificates.with_raw_response.list( account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.access.certificates.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.access.certificates.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = await response.parse() + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.certificates.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = await response.parse() + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.access.certificates.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.access.certificates.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[Certificate], certificate, 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.access.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = await response.parse() + assert_matches_type(Optional[Certificate], certificate, 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.access.certificates.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = await response.parse() + assert_matches_type(Optional[Certificate], certificate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) diff --git a/tests/api_resources/zero_trust/access/test_custom_pages.py b/tests/api_resources/zero_trust/access/test_custom_pages.py new file mode 100644 index 00000000000..4677021a7a3 --- /dev/null +++ b/tests/api_resources/zero_trust/access/test_custom_pages.py @@ -0,0 +1,567 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.access import ( + CustomPage, + CustomPageWithoutHTML, + CustomPageDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestCustomPages: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + app_count=0, + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.access.custom_pages.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.access.custom_pages.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.access.custom_pages.with_raw_response.create( + account_id="", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + app_count=0, + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.custom_pages.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.custom_pages.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, 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.access.custom_pages.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `custom_page_id` but received ''"): + client.zero_trust.access.custom_pages.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.custom_pages.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = response.parse() + assert_matches_type(SyncSinglePage[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.custom_pages.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = response.parse() + assert_matches_type(SyncSinglePage[CustomPageWithoutHTML], custom_page, 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.access.custom_pages.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.custom_pages.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = response.parse() + assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.custom_pages.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = response.parse() + assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, 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.access.custom_pages.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `custom_page_id` but received ''"): + client.zero_trust.access.custom_pages.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + custom_page = client.zero_trust.access.custom_pages.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[CustomPage], custom_page, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.custom_pages.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = response.parse() + assert_matches_type(Optional[CustomPage], custom_page, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.custom_pages.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = response.parse() + assert_matches_type(Optional[CustomPage], custom_page, 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.access.custom_pages.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `custom_page_id` but received ''"): + client.zero_trust.access.custom_pages.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncCustomPages: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + app_count=0, + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.custom_pages.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = await response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.custom_pages.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = await response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.access.custom_pages.with_raw_response.create( + account_id="", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + app_count=0, + ) + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.custom_pages.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = await response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.custom_pages.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = await response.parse() + assert_matches_type(Optional[CustomPageWithoutHTML], custom_page, 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.access.custom_pages.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `custom_page_id` but received ''"): + await async_client.zero_trust.access.custom_pages.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + custom_html="

Access Denied

", + name="string", + type="identity_denied", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.custom_pages.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = await response.parse() + assert_matches_type(AsyncSinglePage[CustomPageWithoutHTML], custom_page, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.custom_pages.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = await response.parse() + assert_matches_type(AsyncSinglePage[CustomPageWithoutHTML], custom_page, 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.access.custom_pages.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.custom_pages.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = await response.parse() + assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.custom_pages.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = await response.parse() + assert_matches_type(Optional[CustomPageDeleteResponse], custom_page, 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.access.custom_pages.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `custom_page_id` but received ''"): + await async_client.zero_trust.access.custom_pages.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + custom_page = await async_client.zero_trust.access.custom_pages.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[CustomPage], custom_page, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.custom_pages.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + custom_page = await response.parse() + assert_matches_type(Optional[CustomPage], custom_page, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.custom_pages.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + custom_page = await response.parse() + assert_matches_type(Optional[CustomPage], custom_page, 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.access.custom_pages.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `custom_page_id` but received ''"): + await async_client.zero_trust.access.custom_pages.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/zero_trust/access/test_groups.py b/tests/api_resources/zero_trust/access/test_groups.py index 757c6dd633a..c9f83d20c8b 100644 --- a/tests/api_resources/zero_trust/access/test_groups.py +++ b/tests/api_resources/zero_trust/access/test_groups.py @@ -10,7 +10,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import ZeroTrustGroup +from cloudflare.types.zero_trust.access import ( + ZeroTrustGroup, + GroupDeleteResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -120,6 +123,126 @@ def test_path_params_create(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + group = client.zero_trust.access.groups.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + group = client.zero_trust.access.groups.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + is_default=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + ) + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.groups.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + group = response.parse() + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.groups.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + group = response.parse() + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `group_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.update( + "", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -175,6 +298,140 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + group = client.zero_trust.access.groups.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + group = client.zero_trust.access.groups.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.groups.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + group = response.parse() + assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.groups.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + group = response.parse() + assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `group_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + group = client.zero_trust.access.groups.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + group = client.zero_trust.access.groups.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.groups.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + group = response.parse() + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.groups.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + group = response.parse() + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `group_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.groups.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + class TestAsyncGroups: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -281,6 +538,126 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + group = await async_client.zero_trust.access.groups.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + group = await async_client.zero_trust.access.groups.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + is_default=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + ) + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.groups.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + group = await response.parse() + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.groups.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + group = await response.parse() + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `group_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.update( + "", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -335,3 +712,137 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.groups.with_raw_response.list( account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + group = await async_client.zero_trust.access.groups.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + group = await async_client.zero_trust.access.groups.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.groups.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + group = await response.parse() + assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.groups.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + group = await response.parse() + assert_matches_type(Optional[GroupDeleteResponse], group, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `group_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + group = await async_client.zero_trust.access.groups.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + group = await async_client.zero_trust.access.groups.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ZeroTrustGroup], group, 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.access.groups.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + group = await response.parse() + assert_matches_type(Optional[ZeroTrustGroup], group, 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.access.groups.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + group = await response.parse() + assert_matches_type(Optional[ZeroTrustGroup], group, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `group_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.groups.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) diff --git a/tests/api_resources/zero_trust/access/test_keys.py b/tests/api_resources/zero_trust/access/test_keys.py new file mode 100644 index 00000000000..f0b87f16c0f --- /dev/null +++ b/tests/api_resources/zero_trust/access/test_keys.py @@ -0,0 +1,258 @@ +# 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.access import KeyGetResponse, KeyRotateResponse, KeyUpdateResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestKeys: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + key = client.zero_trust.access.keys.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + key_rotation_interval_days=30, + ) + assert_matches_type(Optional[KeyUpdateResponse], key, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.keys.with_raw_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + key_rotation_interval_days=30, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(Optional[KeyUpdateResponse], key, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.keys.with_streaming_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + key_rotation_interval_days=30, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(Optional[KeyUpdateResponse], key, 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.access.keys.with_raw_response.update( + account_id="", + key_rotation_interval_days=30, + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + key = client.zero_trust.access.keys.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[KeyGetResponse], key, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.keys.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(Optional[KeyGetResponse], key, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.keys.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(Optional[KeyGetResponse], key, 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.access.keys.with_raw_response.get( + account_id="", + ) + + @parametrize + def test_method_rotate(self, client: Cloudflare) -> None: + key = client.zero_trust.access.keys.rotate( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) + + @parametrize + def test_raw_response_rotate(self, client: Cloudflare) -> None: + response = client.zero_trust.access.keys.with_raw_response.rotate( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) + + @parametrize + def test_streaming_response_rotate(self, client: Cloudflare) -> None: + with client.zero_trust.access.keys.with_streaming_response.rotate( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_rotate(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.keys.with_raw_response.rotate( + account_id="", + ) + + +class TestAsyncKeys: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + key = await async_client.zero_trust.access.keys.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + key_rotation_interval_days=30, + ) + assert_matches_type(Optional[KeyUpdateResponse], key, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.keys.with_raw_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + key_rotation_interval_days=30, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(Optional[KeyUpdateResponse], key, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.keys.with_streaming_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + key_rotation_interval_days=30, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(Optional[KeyUpdateResponse], key, 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.access.keys.with_raw_response.update( + account_id="", + key_rotation_interval_days=30, + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + key = await async_client.zero_trust.access.keys.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[KeyGetResponse], key, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.keys.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(Optional[KeyGetResponse], key, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.keys.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(Optional[KeyGetResponse], key, 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.access.keys.with_raw_response.get( + account_id="", + ) + + @parametrize + async def test_method_rotate(self, async_client: AsyncCloudflare) -> None: + key = await async_client.zero_trust.access.keys.rotate( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) + + @parametrize + async def test_raw_response_rotate(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.keys.with_raw_response.rotate( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) + + @parametrize + async def test_streaming_response_rotate(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.keys.with_streaming_response.rotate( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(Optional[KeyRotateResponse], key, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_rotate(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.access.keys.with_raw_response.rotate( + account_id="", + ) diff --git a/tests/api_resources/zero_trust/access/test_service_tokens.py b/tests/api_resources/zero_trust/access/test_service_tokens.py index dd32841ccab..6031d72107d 100644 --- a/tests/api_resources/zero_trust/access/test_service_tokens.py +++ b/tests/api_resources/zero_trust/access/test_service_tokens.py @@ -10,7 +10,11 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.access import ServiceToken, ServiceTokenCreateResponse +from cloudflare.types.zero_trust.access import ( + ServiceToken, + ServiceTokenCreateResponse, + ServiceTokenRotateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -80,6 +84,75 @@ def test_path_params_create(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + duration="60m", + name="CI/CD token", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.service_tokens.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.service_tokens.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.update( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: @@ -135,6 +208,236 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.service_tokens.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.service_tokens.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.service_tokens.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @parametrize + def test_method_refresh(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.refresh( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @parametrize + def test_raw_response_refresh(self, client: Cloudflare) -> None: + response = client.zero_trust.access.service_tokens.with_raw_response.refresh( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @parametrize + def test_streaming_response_refresh(self, client: Cloudflare) -> None: + with client.zero_trust.access.service_tokens.with_streaming_response.refresh( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_refresh(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.refresh( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.refresh( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_rotate(self, client: Cloudflare) -> None: + service_token = client.zero_trust.access.service_tokens.rotate( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) + + @parametrize + def test_raw_response_rotate(self, client: Cloudflare) -> None: + response = client.zero_trust.access.service_tokens.with_raw_response.rotate( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = response.parse() + assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) + + @parametrize + def test_streaming_response_rotate(self, client: Cloudflare) -> None: + with client.zero_trust.access.service_tokens.with_streaming_response.rotate( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = response.parse() + assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_rotate(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.rotate( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + client.zero_trust.access.service_tokens.with_raw_response.rotate( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + class TestAsyncServiceTokens: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -201,6 +504,75 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + duration="60m", + name="CI/CD token", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.service_tokens.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.service_tokens.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.update( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: @@ -255,3 +627,233 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.access.service_tokens.with_raw_response.list( account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.service_tokens.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.service_tokens.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[ServiceToken], service_token, 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.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, 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.access.service_tokens.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @parametrize + async def test_method_refresh(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.refresh( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @parametrize + async def test_raw_response_refresh(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.service_tokens.with_raw_response.refresh( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + @parametrize + async def test_streaming_response_refresh(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.service_tokens.with_streaming_response.refresh( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = await response.parse() + assert_matches_type(Optional[ServiceToken], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_refresh(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.access.service_tokens.with_raw_response.refresh( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.refresh( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_rotate(self, async_client: AsyncCloudflare) -> None: + service_token = await async_client.zero_trust.access.service_tokens.rotate( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) + + @parametrize + async def test_raw_response_rotate(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.service_tokens.with_raw_response.rotate( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + service_token = await response.parse() + assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) + + @parametrize + async def test_streaming_response_rotate(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.service_tokens.with_streaming_response.rotate( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + service_token = await response.parse() + assert_matches_type(Optional[ServiceTokenRotateResponse], service_token, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_rotate(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.access.service_tokens.with_raw_response.rotate( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `service_token_id` but received ''"): + await async_client.zero_trust.access.service_tokens.with_raw_response.rotate( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/zero_trust/access/test_tags.py b/tests/api_resources/zero_trust/access/test_tags.py new file mode 100644 index 00000000000..9693f511303 --- /dev/null +++ b/tests/api_resources/zero_trust/access/test_tags.py @@ -0,0 +1,481 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.access import Tag, TagDeleteResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestTags: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + tag = client.zero_trust.access.tags.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.access.tags.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = response.parse() + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.access.tags.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = response.parse() + assert_matches_type(Optional[Tag], tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.access.tags.with_raw_response.create( + account_id="", + name="engineers", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + tag = client.zero_trust.access.tags.update( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.tags.with_raw_response.update( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = response.parse() + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.tags.with_streaming_response.update( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = response.parse() + assert_matches_type(Optional[Tag], tag, 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.access.tags.with_raw_response.update( + "engineers", + account_id="", + name="engineers", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_name` but received ''"): + client.zero_trust.access.tags.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + tag = client.zero_trust.access.tags.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[Tag], tag, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.tags.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = response.parse() + assert_matches_type(SyncSinglePage[Tag], tag, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.tags.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = response.parse() + assert_matches_type(SyncSinglePage[Tag], tag, 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.access.tags.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + tag = client.zero_trust.access.tags.delete( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[TagDeleteResponse], tag, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.tags.with_raw_response.delete( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = response.parse() + assert_matches_type(Optional[TagDeleteResponse], tag, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.tags.with_streaming_response.delete( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = response.parse() + assert_matches_type(Optional[TagDeleteResponse], tag, 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.access.tags.with_raw_response.delete( + "engineers", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_name` but received ''"): + client.zero_trust.access.tags.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + tag = client.zero_trust.access.tags.get( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.tags.with_raw_response.get( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = response.parse() + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.tags.with_streaming_response.get( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = response.parse() + assert_matches_type(Optional[Tag], tag, 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.access.tags.with_raw_response.get( + "engineers", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_name` but received ''"): + client.zero_trust.access.tags.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncTags: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + tag = await async_client.zero_trust.access.tags.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.tags.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = await response.parse() + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.tags.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = await response.parse() + assert_matches_type(Optional[Tag], tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.access.tags.with_raw_response.create( + account_id="", + name="engineers", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + tag = await async_client.zero_trust.access.tags.update( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.tags.with_raw_response.update( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = await response.parse() + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.tags.with_streaming_response.update( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = await response.parse() + assert_matches_type(Optional[Tag], tag, 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.access.tags.with_raw_response.update( + "engineers", + account_id="", + name="engineers", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_name` but received ''"): + await async_client.zero_trust.access.tags.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + name="engineers", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + tag = await async_client.zero_trust.access.tags.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[Tag], tag, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.tags.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = await response.parse() + assert_matches_type(AsyncSinglePage[Tag], tag, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.tags.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = await response.parse() + assert_matches_type(AsyncSinglePage[Tag], tag, 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.access.tags.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + tag = await async_client.zero_trust.access.tags.delete( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[TagDeleteResponse], tag, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.tags.with_raw_response.delete( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = await response.parse() + assert_matches_type(Optional[TagDeleteResponse], tag, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.tags.with_streaming_response.delete( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = await response.parse() + assert_matches_type(Optional[TagDeleteResponse], tag, 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.access.tags.with_raw_response.delete( + "engineers", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_name` but received ''"): + await async_client.zero_trust.access.tags.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + tag = await async_client.zero_trust.access.tags.get( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.tags.with_raw_response.get( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tag = await response.parse() + assert_matches_type(Optional[Tag], tag, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.tags.with_streaming_response.get( + "engineers", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tag = await response.parse() + assert_matches_type(Optional[Tag], tag, 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.access.tags.with_raw_response.get( + "engineers", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_name` but received ''"): + await async_client.zero_trust.access.tags.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/zero_trust/access/test_users.py b/tests/api_resources/zero_trust/access/test_users.py new file mode 100644 index 00000000000..eb05e5be04b --- /dev/null +++ b/tests/api_resources/zero_trust/access/test_users.py @@ -0,0 +1,99 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.access import AccessUser + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestUsers: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + user = client.zero_trust.access.users.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[AccessUser], user, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.users.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user = response.parse() + assert_matches_type(SyncSinglePage[AccessUser], user, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.users.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user = response.parse() + assert_matches_type(SyncSinglePage[AccessUser], user, 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.access.users.with_raw_response.list( + account_id="", + ) + + +class TestAsyncUsers: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + user = await async_client.zero_trust.access.users.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[AccessUser], user, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.users.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + user = await response.parse() + assert_matches_type(AsyncSinglePage[AccessUser], user, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.users.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + user = await response.parse() + assert_matches_type(AsyncSinglePage[AccessUser], user, 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.access.users.with_raw_response.list( + account_id="", + ) diff --git a/tests/api_resources/zero_trust/access/users/__init__.py b/tests/api_resources/zero_trust/access/users/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/zero_trust/access/users/__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/access/users/test_active_sessions.py b/tests/api_resources/zero_trust/access/users/test_active_sessions.py new file mode 100644 index 00000000000..55ae6bab3de --- /dev/null +++ b/tests/api_resources/zero_trust/access/users/test_active_sessions.py @@ -0,0 +1,239 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.access.users import ActiveSessionGetResponse, ActiveSessionListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestActiveSessions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + active_session = client.zero_trust.access.users.active_sessions.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[ActiveSessionListResponse], active_session, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.users.active_sessions.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + active_session = response.parse() + assert_matches_type(SyncSinglePage[ActiveSessionListResponse], active_session, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.users.active_sessions.with_streaming_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + active_session = response.parse() + assert_matches_type(SyncSinglePage[ActiveSessionListResponse], active_session, 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.access.users.active_sessions.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + client.zero_trust.access.users.active_sessions.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + active_session = client.zero_trust.access.users.active_sessions.get( + "X1aXj1lFVcqqyoXF", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + assert_matches_type(Optional[ActiveSessionGetResponse], active_session, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.users.active_sessions.with_raw_response.get( + "X1aXj1lFVcqqyoXF", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + active_session = response.parse() + assert_matches_type(Optional[ActiveSessionGetResponse], active_session, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.users.active_sessions.with_streaming_response.get( + "X1aXj1lFVcqqyoXF", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + active_session = response.parse() + assert_matches_type(Optional[ActiveSessionGetResponse], active_session, 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.access.users.active_sessions.with_raw_response.get( + "X1aXj1lFVcqqyoXF", + account_id="", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + client.zero_trust.access.users.active_sessions.with_raw_response.get( + "X1aXj1lFVcqqyoXF", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `nonce` but received ''"): + client.zero_trust.access.users.active_sessions.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + + +class TestAsyncActiveSessions: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + active_session = await async_client.zero_trust.access.users.active_sessions.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[ActiveSessionListResponse], active_session, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.users.active_sessions.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + active_session = await response.parse() + assert_matches_type(AsyncSinglePage[ActiveSessionListResponse], active_session, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.users.active_sessions.with_streaming_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + active_session = await response.parse() + assert_matches_type(AsyncSinglePage[ActiveSessionListResponse], active_session, 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.access.users.active_sessions.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + await async_client.zero_trust.access.users.active_sessions.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + active_session = await async_client.zero_trust.access.users.active_sessions.get( + "X1aXj1lFVcqqyoXF", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + assert_matches_type(Optional[ActiveSessionGetResponse], active_session, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.users.active_sessions.with_raw_response.get( + "X1aXj1lFVcqqyoXF", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + active_session = await response.parse() + assert_matches_type(Optional[ActiveSessionGetResponse], active_session, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.users.active_sessions.with_streaming_response.get( + "X1aXj1lFVcqqyoXF", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + active_session = await response.parse() + assert_matches_type(Optional[ActiveSessionGetResponse], active_session, 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.access.users.active_sessions.with_raw_response.get( + "X1aXj1lFVcqqyoXF", + account_id="", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + await async_client.zero_trust.access.users.active_sessions.with_raw_response.get( + "X1aXj1lFVcqqyoXF", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `nonce` but received ''"): + await async_client.zero_trust.access.users.active_sessions.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + user_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) diff --git a/tests/api_resources/zero_trust/access/users/test_failed_logins.py b/tests/api_resources/zero_trust/access/users/test_failed_logins.py new file mode 100644 index 00000000000..d2280ea6572 --- /dev/null +++ b/tests/api_resources/zero_trust/access/users/test_failed_logins.py @@ -0,0 +1,119 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.access.users import FailedLoginListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestFailedLogins: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + failed_login = client.zero_trust.access.users.failed_logins.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[FailedLoginListResponse], failed_login, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.users.failed_logins.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + failed_login = response.parse() + assert_matches_type(SyncSinglePage[FailedLoginListResponse], failed_login, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.users.failed_logins.with_streaming_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + failed_login = response.parse() + assert_matches_type(SyncSinglePage[FailedLoginListResponse], failed_login, 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.access.users.failed_logins.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + client.zero_trust.access.users.failed_logins.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncFailedLogins: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + failed_login = await async_client.zero_trust.access.users.failed_logins.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[FailedLoginListResponse], failed_login, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.users.failed_logins.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + failed_login = await response.parse() + assert_matches_type(AsyncSinglePage[FailedLoginListResponse], failed_login, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.users.failed_logins.with_streaming_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + failed_login = await response.parse() + assert_matches_type(AsyncSinglePage[FailedLoginListResponse], failed_login, 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.access.users.failed_logins.with_raw_response.list( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + await async_client.zero_trust.access.users.failed_logins.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/zero_trust/access/users/test_last_seen_identity.py b/tests/api_resources/zero_trust/access/users/test_last_seen_identity.py new file mode 100644 index 00000000000..6363aec38d0 --- /dev/null +++ b/tests/api_resources/zero_trust/access/users/test_last_seen_identity.py @@ -0,0 +1,118 @@ +# 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.access.users import Identity + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestLastSeenIdentity: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + last_seen_identity = client.zero_trust.access.users.last_seen_identity.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[Identity], last_seen_identity, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.users.last_seen_identity.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + last_seen_identity = response.parse() + assert_matches_type(Optional[Identity], last_seen_identity, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.users.last_seen_identity.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + last_seen_identity = response.parse() + assert_matches_type(Optional[Identity], last_seen_identity, 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.access.users.last_seen_identity.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + client.zero_trust.access.users.last_seen_identity.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncLastSeenIdentity: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + last_seen_identity = await async_client.zero_trust.access.users.last_seen_identity.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[Identity], last_seen_identity, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.users.last_seen_identity.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + last_seen_identity = await response.parse() + assert_matches_type(Optional[Identity], last_seen_identity, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.users.last_seen_identity.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + last_seen_identity = await response.parse() + assert_matches_type(Optional[Identity], last_seen_identity, 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.access.users.last_seen_identity.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + await async_client.zero_trust.access.users.last_seen_identity.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/zero_trust/test_identity_providers.py b/tests/api_resources/zero_trust/test_identity_providers.py index b78e5843fd8..3977deba608 100644 --- a/tests/api_resources/zero_trust/test_identity_providers.py +++ b/tests/api_resources/zero_trust/test_identity_providers.py @@ -13,6 +13,7 @@ from cloudflare.types.zero_trust import ( IdentityProvider, IdentityProviderListResponse, + IdentityProviderDeleteResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -1229,68 +1230,2748 @@ def test_path_params_create_overload_14(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_1(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "conditional_access_enabled": True, + "directory_id": "", + "prompt": "login", + "support_groups": True, + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "centrify_account": "https://abc123.my.centrify.com/", + "centrify_app_id": "exampleapp", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_3(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_4(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_4(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_5(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_5(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_5(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_6(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_6(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "apps_domain": "mycompany.com", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_6(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_7(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_7(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_7(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_7(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_7(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_8(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_8(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "auth_url": "https://accounts.google.com/o/oauth2/auth", + "certs_url": "https://www.googleapis.com/oauth2/v3/certs", + "scopes": ["openid", "email", "profile"], + "token_url": "https://accounts.google.com/o/oauth2/token", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_8(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_8(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_8(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_9(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_9(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "authorization_server_id": "aus9o8wzkhckw9TLa0h7z", + "okta_account": "https://dev-abc123.oktapreview.com", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_9(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_9(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_9(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_10(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_10(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "onelogin_account": "https://mycompany.onelogin.com", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_10(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_10(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_10(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_11(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_11(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "ping_env_id": "342b5660-0c32-4936-a5a4-ce21fae57b0a", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_11(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_11(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_11(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_12(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_12(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "attributes": ["group", "department_code", "divison"], + "email_attribute_name": "Email", + "header_attributes": [ + { + "attribute_name": "string", + "header_name": "string", + }, + { + "attribute_name": "string", + "header_name": "string", + }, + { + "attribute_name": "string", + "header_name": "string", + }, + ], + "idp_public_certs": ["string", "string", "string"], + "issuer_url": "https://whoami.com", + "sign_request": True, + "sso_target_url": "https://edgeaccess.org/idp/saml/login", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_12(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_12(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_12(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_13(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_13(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={ + "client_id": "", + "client_secret": "", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_13(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_13(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_13(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_14(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_14(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_14(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_14(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_14(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_list(self, client: Cloudflare) -> None: identity_provider = client.zero_trust.identity_providers.list( account_id="string", ) - assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) + assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.list( + account_id="string", + ) + assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.list( + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.list( + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.list( + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.list( + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + identity_provider = client.zero_trust.identity_providers.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.identity_providers.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.identity_providers.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.zero_trust.identity_providers.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + +class TestAsyncIdentityProviders: + 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_overload_1(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "conditional_access_enabled": True, + "directory_id": "", + "prompt": "login", + "support_groups": True, + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_1(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "centrify_account": "https://abc123.my.centrify.com/", + "centrify_app_id": "exampleapp", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_2(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_3(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_4(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_5(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_5(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_6(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "apps_domain": "mycompany.com", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_6(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_7(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_7(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_8(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "auth_url": "https://accounts.google.com/o/oauth2/auth", + "certs_url": "https://www.googleapis.com/oauth2/v3/certs", + "scopes": ["openid", "email", "profile"], + "token_url": "https://accounts.google.com/o/oauth2/token", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_8(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_9(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "authorization_server_id": "aus9o8wzkhckw9TLa0h7z", + "okta_account": "https://dev-abc123.oktapreview.com", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_9(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_10(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "onelogin_account": "https://mycompany.onelogin.com", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_10(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_11(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + "claims": ["email_verified", "preferred_username", "custom_claim_name"], + "email_claim_name": "custom_claim_name", + "ping_env_id": "342b5660-0c32-4936-a5a4-ce21fae57b0a", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_11(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_12(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "attributes": ["group", "department_code", "divison"], + "email_attribute_name": "Email", + "header_attributes": [ + { + "attribute_name": "string", + "header_name": "string", + }, + { + "attribute_name": "string", + "header_name": "string", + }, + { + "attribute_name": "string", + "header_name": "string", + }, + ], + "idp_public_certs": ["string", "string", "string"], + "issuer_url": "https://whoami.com", + "sign_request": True, + "sso_target_url": "https://edgeaccess.org/idp/saml/login", + }, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_12(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_13(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - identity_provider = client.zero_trust.identity_providers.list( + async def test_method_create_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.create( + config={ + "client_id": "", + "client_secret": "", + }, + name="Widget Corps IDP", + type="onetimepin", account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, ) - assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.identity_providers.with_raw_response.list( + async def test_raw_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", account_id="string", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.identity_providers.with_streaming_response.list( + async def test_streaming_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", account_id="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - identity_provider = response.parse() - assert_matches_type(SyncSinglePage[IdentityProviderListResponse], identity_provider, path=["response"]) + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: + async def test_path_params_create_overload_13(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.list( + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zero_trust.identity_providers.with_raw_response.list( + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", account_id="string", ) - -class TestAsyncIdentityProviders: - 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_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_14(self, async_client: AsyncCloudflare) -> None: identity_provider = await async_client.zero_trust.identity_providers.create( config={}, name="Widget Corps IDP", @@ -1301,8 +3982,90 @@ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: identity_provider = await async_client.zero_trust.identity_providers.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + scim_config={ + "enabled": True, + "group_member_deprovision": True, + "seat_deprovision": True, + "secret": "string", + "user_deprovision": True, + }, + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_14(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.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.create( + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -1328,8 +4091,9 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1343,8 +4107,9 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1360,9 +4125,19 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1370,7 +4145,8 @@ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1379,8 +4155,9 @@ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1390,8 +4167,9 @@ async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -1415,8 +4193,9 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1430,8 +4209,9 @@ async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1447,9 +4227,19 @@ async def test_streaming_response_create_overload_2(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1457,7 +4247,8 @@ async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1466,8 +4257,9 @@ async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1477,8 +4269,9 @@ async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -1498,8 +4291,9 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1513,8 +4307,9 @@ async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1530,9 +4325,19 @@ async def test_streaming_response_create_overload_3(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_3(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1540,7 +4345,8 @@ async def test_path_params_create_overload_3(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1549,8 +4355,9 @@ async def test_path_params_create_overload_3(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1560,8 +4367,9 @@ async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -1581,8 +4389,9 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1596,8 +4405,9 @@ async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1613,9 +4423,19 @@ async def test_streaming_response_create_overload_4(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_4(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1623,7 +4443,8 @@ async def test_path_params_create_overload_4(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1632,8 +4453,9 @@ async def test_path_params_create_overload_4(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_5(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1643,8 +4465,9 @@ async def test_method_create_overload_5(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -1666,8 +4489,9 @@ async def test_method_create_with_all_params_overload_5(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1681,8 +4505,9 @@ async def test_raw_response_create_overload_5(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1698,9 +4523,19 @@ async def test_streaming_response_create_overload_5(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_5(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1708,7 +4543,8 @@ async def test_path_params_create_overload_5(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1717,8 +4553,9 @@ async def test_path_params_create_overload_5(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_6(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1728,8 +4565,9 @@ async def test_method_create_overload_6(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -1752,8 +4590,9 @@ async def test_method_create_with_all_params_overload_6(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1767,8 +4606,9 @@ async def test_raw_response_create_overload_6(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1784,9 +4624,19 @@ async def test_streaming_response_create_overload_6(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_6(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1794,7 +4644,8 @@ async def test_path_params_create_overload_6(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1803,8 +4654,9 @@ async def test_path_params_create_overload_6(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_7(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_7(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1814,8 +4666,9 @@ async def test_method_create_overload_7(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -1835,8 +4688,9 @@ async def test_method_create_with_all_params_overload_7(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_7(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1850,8 +4704,9 @@ async def test_raw_response_create_overload_7(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_7(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1867,9 +4722,19 @@ async def test_streaming_response_create_overload_7(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_7(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_7(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1877,7 +4742,8 @@ async def test_path_params_create_overload_7(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1886,8 +4752,9 @@ async def test_path_params_create_overload_7(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_8(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_8(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1897,8 +4764,9 @@ async def test_method_create_overload_8(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -1924,8 +4792,9 @@ async def test_method_create_with_all_params_overload_8(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_8(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1939,8 +4808,9 @@ async def test_raw_response_create_overload_8(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_8(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1956,9 +4826,19 @@ async def test_streaming_response_create_overload_8(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_8(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_8(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1966,7 +4846,8 @@ async def test_path_params_create_overload_8(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1975,8 +4856,9 @@ async def test_path_params_create_overload_8(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_9(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_9(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -1986,8 +4868,9 @@ async def test_method_create_overload_9(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -2011,8 +4894,9 @@ async def test_method_create_with_all_params_overload_9(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_9(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2026,8 +4910,9 @@ async def test_raw_response_create_overload_9(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_9(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2043,9 +4928,19 @@ async def test_streaming_response_create_overload_9(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_9(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_9(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2053,7 +4948,8 @@ async def test_path_params_create_overload_9(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2062,8 +4958,9 @@ async def test_path_params_create_overload_9(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_10(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_10(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2073,8 +4970,9 @@ async def test_method_create_overload_10(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -2097,8 +4995,9 @@ async def test_method_create_with_all_params_overload_10(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_10(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2112,8 +5011,9 @@ async def test_raw_response_create_overload_10(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_10(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2129,9 +5029,19 @@ async def test_streaming_response_create_overload_10(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_10(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_10(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2139,7 +5049,8 @@ async def test_path_params_create_overload_10(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2148,8 +5059,9 @@ async def test_path_params_create_overload_10(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_11(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_11(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2159,8 +5071,9 @@ async def test_method_create_overload_11(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -2183,8 +5096,9 @@ async def test_method_create_with_all_params_overload_11(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_11(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2198,8 +5112,9 @@ async def test_raw_response_create_overload_11(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_11(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2215,9 +5130,19 @@ async def test_streaming_response_create_overload_11(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_11(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_11(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2225,7 +5150,8 @@ async def test_path_params_create_overload_11(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2234,8 +5160,9 @@ async def test_path_params_create_overload_11(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_12(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_12(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2245,8 +5172,9 @@ async def test_method_create_overload_12(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "attributes": ["group", "department_code", "divison"], "email_attribute_name": "Email", @@ -2284,8 +5212,9 @@ async def test_method_create_with_all_params_overload_12(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_12(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2299,8 +5228,9 @@ async def test_raw_response_create_overload_12(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_12(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2316,9 +5246,19 @@ async def test_streaming_response_create_overload_12(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_12(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_12(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2326,7 +5266,8 @@ async def test_path_params_create_overload_12(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2335,8 +5276,9 @@ async def test_path_params_create_overload_12(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_13(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_13(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2346,8 +5288,9 @@ async def test_method_create_overload_13(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={ "client_id": "", "client_secret": "", @@ -2367,8 +5310,9 @@ async def test_method_create_with_all_params_overload_13(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_13(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2382,8 +5326,9 @@ async def test_raw_response_create_overload_13(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_13(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2399,9 +5344,19 @@ async def test_streaming_response_create_overload_13(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_13(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_13(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2409,7 +5364,8 @@ async def test_path_params_create_overload_13(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2418,8 +5374,9 @@ async def test_path_params_create_overload_13(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_14(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_overload_14(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2429,8 +5386,9 @@ async def test_method_create_overload_14(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: - identity_provider = await async_client.zero_trust.identity_providers.create( + async def test_method_update_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2447,8 +5405,9 @@ async def test_method_create_with_all_params_overload_14(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.identity_providers.with_raw_response.create( + async def test_raw_response_update_overload_14(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2462,8 +5421,9 @@ async def test_raw_response_create_overload_14(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.identity_providers.with_streaming_response.create( + async def test_streaming_response_update_overload_14(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2479,9 +5439,19 @@ async def test_streaming_response_create_overload_14(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_14(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_14(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.update( + "", + config={}, + name="Widget Corps IDP", + type="onetimepin", + account_id="string", + ) + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2489,7 +5459,8 @@ async def test_path_params_create_overload_14(self, async_client: AsyncCloudflar ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zero_trust.identity_providers.with_raw_response.create( + await async_client.zero_trust.identity_providers.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", config={}, name="Widget Corps IDP", type="onetimepin", @@ -2550,3 +5521,137 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.identity_providers.with_raw_response.list( account_id="string", ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.identity_providers.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.identity_providers.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProviderDeleteResponse], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.delete( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + identity_provider = await async_client.zero_trust.identity_providers.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + assert_matches_type(Optional[IdentityProvider], identity_provider, 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.identity_providers.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, 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.identity_providers.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + identity_provider = await response.parse() + assert_matches_type(Optional[IdentityProvider], identity_provider, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identity_provider_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.get( + "", + account_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.zero_trust.identity_providers.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="string", + ) diff --git a/tests/api_resources/zero_trust/test_seats.py b/tests/api_resources/zero_trust/test_seats.py new file mode 100644 index 00000000000..76a871664a8 --- /dev/null +++ b/tests/api_resources/zero_trust/test_seats.py @@ -0,0 +1,218 @@ +# 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 import SeatEditResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSeats: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + seat = client.zero_trust.seats.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + ], + ) + assert_matches_type(Optional[SeatEditResponse], seat, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.zero_trust.seats.with_raw_response.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + seat = response.parse() + assert_matches_type(Optional[SeatEditResponse], seat, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.zero_trust.seats.with_streaming_response.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + seat = response.parse() + assert_matches_type(Optional[SeatEditResponse], seat, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.seats.with_raw_response.edit( + account_id="", + body=[ + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + ], + ) + + +class TestAsyncSeats: + 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_edit(self, async_client: AsyncCloudflare) -> None: + seat = await async_client.zero_trust.seats.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + ], + ) + assert_matches_type(Optional[SeatEditResponse], seat, 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.seats.with_raw_response.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + seat = await response.parse() + assert_matches_type(Optional[SeatEditResponse], seat, 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.seats.with_streaming_response.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body=[ + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + seat = await response.parse() + assert_matches_type(Optional[SeatEditResponse], seat, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.seats.with_raw_response.edit( + account_id="", + body=[ + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + { + "access_seat": False, + "gateway_seat": False, + }, + ], + ) From 4ca97ec63dcd1baa99ab53a8a8f96435df2c16c2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 09:18:33 +0000 Subject: [PATCH 247/532] feat(api): OpenAPI spec update via Stainless API (#728) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a157cc5cf6b..fbcd944afc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml diff --git a/api.md b/api.md index bcf2f8086e2..ba42f34eec6 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 26fd50450a3c626df938dd12c976d71eac604728 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 09:20:46 +0000 Subject: [PATCH 248/532] feat(api): OpenAPI spec update via Stainless API (#729) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index fbcd944afc9..ab79704ed9f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a3b3746ec899f1aabc177d0170340930e90ba7ef87a13c9dd510f5232a3611de.yml diff --git a/api.md b/api.md index ba42f34eec6..bcf2f8086e2 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 45acdc076313cb27bdac600896333e9234a0c304 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 09:33:38 +0000 Subject: [PATCH 249/532] feat(api): OpenAPI spec update via Stainless API (#730) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index ab79704ed9f..9a6098c023f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a3b3746ec899f1aabc177d0170340930e90ba7ef87a13c9dd510f5232a3611de.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml diff --git a/api.md b/api.md index bcf2f8086e2..ba42f34eec6 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 799f40eb7b149090d87ff3bb522621dbe73c8a47 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 11:11:35 +0000 Subject: [PATCH 250/532] feat(api): OpenAPI spec update via Stainless API (#731) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9a6098c023f..a157cc5cf6b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml diff --git a/api.md b/api.md index ba42f34eec6..bcf2f8086e2 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 1bdd586a537837b08069faa92af8da6c2b956c88 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 11:13:38 +0000 Subject: [PATCH 251/532] feat(api): OpenAPI spec update via Stainless API (#732) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a157cc5cf6b..9a6098c023f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml diff --git a/api.md b/api.md index bcf2f8086e2..ba42f34eec6 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 5c45e6e24fb544d21bcc07cb5175364ccae157e4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 11:20:20 +0000 Subject: [PATCH 252/532] feat(api): OpenAPI spec update via Stainless API (#733) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9a6098c023f..ab79704ed9f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a3b3746ec899f1aabc177d0170340930e90ba7ef87a13c9dd510f5232a3611de.yml diff --git a/api.md b/api.md index ba42f34eec6..bcf2f8086e2 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 5b3d98ddcda6958f888607b6e420d125be3ed32b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 11:26:00 +0000 Subject: [PATCH 253/532] feat(api): OpenAPI spec update via Stainless API (#734) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ab79704ed9f..a157cc5cf6b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a3b3746ec899f1aabc177d0170340930e90ba7ef87a13c9dd510f5232a3611de.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml From 45c575503a9b51403d2ea44b1e250d26dca9467d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 12:02:24 +0000 Subject: [PATCH 254/532] feat(api): OpenAPI spec update via Stainless API (#735) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a157cc5cf6b..9a6098c023f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml diff --git a/api.md b/api.md index bcf2f8086e2..ba42f34eec6 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 556227a4dea855bf414fdeab4606cbc2d912ccd3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 14:55:58 +0000 Subject: [PATCH 255/532] feat(api): OpenAPI spec update via Stainless API (#736) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9a6098c023f..fbcd944afc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml From 5a27fe15de393019289ad28a7744f8fda547c9f9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 14:58:07 +0000 Subject: [PATCH 256/532] feat(api): OpenAPI spec update via Stainless API (#737) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fbcd944afc9..9a6098c023f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml From 3258d858d78449cebec4d0c3f0480eeac15201ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 15:18:57 +0000 Subject: [PATCH 257/532] feat(api): OpenAPI spec update via Stainless API (#738) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9a6098c023f..ab79704ed9f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a3b3746ec899f1aabc177d0170340930e90ba7ef87a13c9dd510f5232a3611de.yml diff --git a/api.md b/api.md index ba42f34eec6..bcf2f8086e2 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 760506b6bd05fedcd12e310e7fe87dd9665e7a26 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 15:21:22 +0000 Subject: [PATCH 258/532] feat(api): OpenAPI spec update via Stainless API (#739) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index ab79704ed9f..fbcd944afc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a3b3746ec899f1aabc177d0170340930e90ba7ef87a13c9dd510f5232a3611de.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml diff --git a/api.md b/api.md index bcf2f8086e2..ba42f34eec6 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 947a9e996d9cd68bb97a6e56ec6d2f9d0a931411 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 15:50:49 +0000 Subject: [PATCH 259/532] feat(api): OpenAPI spec update via Stainless API (#740) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fbcd944afc9..9a6098c023f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml From 07a5624809bb04e45bb08ec7b7dfcde700677fc9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 16:23:38 +0000 Subject: [PATCH 260/532] feat(api): OpenAPI spec update via Stainless API (#741) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9a6098c023f..fbcd944afc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d96bf16635986ad2cf00e1d6b6e108e3c6a069d19ef1285400b28af9d958af3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml From a7301751431c4306bfc32212ea130a0d900304fa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 16:33:02 +0000 Subject: [PATCH 261/532] feat(api): OpenAPI spec update via Stainless API (#742) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index fbcd944afc9..a157cc5cf6b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml diff --git a/api.md b/api.md index ba42f34eec6..bcf2f8086e2 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 0a87d13db8a1679a16019159d679f38ed3efb595 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 16:35:07 +0000 Subject: [PATCH 262/532] feat(api): OpenAPI spec update via Stainless API (#743) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a157cc5cf6b..fbcd944afc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml diff --git a/api.md b/api.md index bcf2f8086e2..ba42f34eec6 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 8353bfe5af9e60ce20130aa158d5301be016eba2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 18:59:57 +0000 Subject: [PATCH 263/532] feat(api): OpenAPI spec update via Stainless API (#744) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index fbcd944afc9..a157cc5cf6b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml diff --git a/api.md b/api.md index ba42f34eec6..bcf2f8086e2 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From dfa69f4694afe0202dbec8e449c38aa1fa09e382 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 19:02:18 +0000 Subject: [PATCH 264/532] feat(api): OpenAPI spec update via Stainless API (#745) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index a157cc5cf6b..fbcd944afc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-faaa81dda06d091c58d19e3aba3fc1609f647c8af561f2aa645b484412805084.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml diff --git a/api.md b/api.md index bcf2f8086e2..ba42f34eec6 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7642,14 +7642,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7665,10 +7665,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7685,11 +7685,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 1dffe018eaeb5c4a0424a6f52e3c6f983ab89cf3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 20:08:13 +0000 Subject: [PATCH 265/532] feat(api): OpenAPI spec update via Stainless API (#746) --- .stats.yml | 2 +- api.md | 5 +- .../zero_trust/gateway/proxy_endpoints.py | 51 ++++++++++--------- .../types/zero_trust/gateway/__init__.py | 1 + .../gateway/proxy_endpoint_get_response.py | 9 ++++ .../gateway/test_proxy_endpoints.py | 26 +++++----- 6 files changed, 55 insertions(+), 39 deletions(-) create mode 100644 src/cloudflare/types/zero_trust/gateway/proxy_endpoint_get_response.py diff --git a/.stats.yml b/.stats.yml index fbcd944afc9..35ba8798674 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-15ceeb11cd4134501a557652ceaeacda4b60ea635ea5ac2e0d06974b130cc60a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f68e176f43592631364d94df7670824a599296f6734ca70ffa94454c58da466.yml diff --git a/api.md b/api.md index ba42f34eec6..8d42917a9ec 100644 --- a/api.md +++ b/api.md @@ -6031,16 +6031,17 @@ from cloudflare.types.zero_trust.gateway import ( GatewayIPs, ProxyEndpoint, ProxyEndpointDeleteResponse, + ProxyEndpointGetResponse, ) ``` Methods: - client.zero_trust.gateway.proxy_endpoints.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.proxy_endpoints.list(\*, account_id) -> SyncSinglePage[ProxyEndpoint] +- client.zero_trust.gateway.proxy_endpoints.list(\*, account_id) -> Optional - client.zero_trust.gateway.proxy_endpoints.delete(proxy_endpoint_id, \*, account_id) -> Optional - client.zero_trust.gateway.proxy_endpoints.edit(proxy_endpoint_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.proxy_endpoints.get(proxy_endpoint_id, \*, account_id) -> Optional +- client.zero_trust.gateway.proxy_endpoints.get(proxy_endpoint_id, \*, account_id) -> Optional ### Rules diff --git a/src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py b/src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py index c1b0d3b653f..6ff679a7bc6 100644 --- a/src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py +++ b/src/cloudflare/resources/zero_trust/gateway/proxy_endpoints.py @@ -20,14 +20,13 @@ 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.gateway import proxy_endpoint_edit_params, proxy_endpoint_create_params from ....types.zero_trust.gateway.gateway_ips import GatewayIPs from ....types.zero_trust.gateway.proxy_endpoint import ProxyEndpoint +from ....types.zero_trust.gateway.proxy_endpoint_get_response import ProxyEndpointGetResponse from ....types.zero_trust.gateway.proxy_endpoint_delete_response import ProxyEndpointDeleteResponse __all__ = ["ProxyEndpointsResource", "AsyncProxyEndpointsResource"] @@ -102,9 +101,9 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[ProxyEndpoint]: + ) -> Optional[ProxyEndpoint]: """ - Fetches a single Zero Trust Gateway proxy endpoint. + Fetches all Zero Trust Gateway proxy endpoints for an account. Args: extra_headers: Send extra headers @@ -117,13 +116,16 @@ def list( """ 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( + return self._get( f"/accounts/{account_id}/gateway/proxy_endpoints", - page=SyncSinglePage[ProxyEndpoint], 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, + post_parser=ResultWrapper[Optional[ProxyEndpoint]]._unwrapper, ), - model=ProxyEndpoint, + cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]), ) def delete( @@ -235,9 +237,9 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ProxyEndpoint]: + ) -> Optional[ProxyEndpointGetResponse]: """ - Fetches all Zero Trust Gateway proxy endpoints for an account. + Fetches a single Zero Trust Gateway proxy endpoint. Args: extra_headers: Send extra headers @@ -259,9 +261,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[ProxyEndpoint]]._unwrapper, + post_parser=ResultWrapper[Optional[ProxyEndpointGetResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]), + cast_to=cast(Type[Optional[ProxyEndpointGetResponse]], ResultWrapper[ProxyEndpointGetResponse]), ) @@ -324,7 +326,7 @@ async def create( cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]), ) - def list( + async def list( self, *, account_id: str, @@ -334,9 +336,9 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[ProxyEndpoint, AsyncSinglePage[ProxyEndpoint]]: + ) -> Optional[ProxyEndpoint]: """ - Fetches a single Zero Trust Gateway proxy endpoint. + Fetches all Zero Trust Gateway proxy endpoints for an account. Args: extra_headers: Send extra headers @@ -349,13 +351,16 @@ def list( """ 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( + return await self._get( f"/accounts/{account_id}/gateway/proxy_endpoints", - page=AsyncSinglePage[ProxyEndpoint], 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, + post_parser=ResultWrapper[Optional[ProxyEndpoint]]._unwrapper, ), - model=ProxyEndpoint, + cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]), ) async def delete( @@ -467,9 +472,9 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[ProxyEndpoint]: + ) -> Optional[ProxyEndpointGetResponse]: """ - Fetches all Zero Trust Gateway proxy endpoints for an account. + Fetches a single Zero Trust Gateway proxy endpoint. Args: extra_headers: Send extra headers @@ -491,9 +496,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[ProxyEndpoint]]._unwrapper, + post_parser=ResultWrapper[Optional[ProxyEndpointGetResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[ProxyEndpoint]], ResultWrapper[ProxyEndpoint]), + cast_to=cast(Type[Optional[ProxyEndpointGetResponse]], ResultWrapper[ProxyEndpointGetResponse]), ) diff --git a/src/cloudflare/types/zero_trust/gateway/__init__.py b/src/cloudflare/types/zero_trust/gateway/__init__.py index b8627d5f6fc..c3abd0c2212 100644 --- a/src/cloudflare/types/zero_trust/gateway/__init__.py +++ b/src/cloudflare/types/zero_trust/gateway/__init__.py @@ -57,6 +57,7 @@ from .configuration_update_params import ConfigurationUpdateParams as ConfigurationUpdateParams from .custom_certificate_settings import CustomCertificateSettings as CustomCertificateSettings from .notification_settings_param import NotificationSettingsParam as NotificationSettingsParam +from .proxy_endpoint_get_response import ProxyEndpointGetResponse as ProxyEndpointGetResponse from .body_scanning_settings_param import BodyScanningSettingsParam as BodyScanningSettingsParam from .proxy_endpoint_create_params import ProxyEndpointCreateParams as ProxyEndpointCreateParams from .configuration_update_response import ConfigurationUpdateResponse as ConfigurationUpdateResponse diff --git a/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_get_response.py b/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_get_response.py new file mode 100644 index 00000000000..225dd8730e2 --- /dev/null +++ b/src/cloudflare/types/zero_trust/gateway/proxy_endpoint_get_response.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .proxy_endpoint import ProxyEndpoint + +__all__ = ["ProxyEndpointGetResponse"] + +ProxyEndpointGetResponse = List[ProxyEndpoint] diff --git a/tests/api_resources/zero_trust/gateway/test_proxy_endpoints.py b/tests/api_resources/zero_trust/gateway/test_proxy_endpoints.py index d46c4b8884e..2d5b505ed3c 100644 --- a/tests/api_resources/zero_trust/gateway/test_proxy_endpoints.py +++ b/tests/api_resources/zero_trust/gateway/test_proxy_endpoints.py @@ -9,9 +9,9 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.zero_trust.gateway import ( ProxyEndpoint, + ProxyEndpointGetResponse, ProxyEndpointDeleteResponse, ) @@ -72,7 +72,7 @@ def test_method_list(self, client: Cloudflare) -> None: proxy_endpoint = client.zero_trust.gateway.proxy_endpoints.list( account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(SyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -83,7 +83,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" proxy_endpoint = response.parse() - assert_matches_type(SyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -94,7 +94,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" proxy_endpoint = response.parse() - assert_matches_type(SyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) assert cast(Any, response.is_closed) is True @@ -217,7 +217,7 @@ def test_method_get(self, client: Cloudflare) -> None: "ed35569b41ce4d1facfe683550f54086", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -229,7 +229,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" proxy_endpoint = response.parse() - assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -241,7 +241,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" proxy_endpoint = response.parse() - assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"]) assert cast(Any, response.is_closed) is True @@ -314,7 +314,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: proxy_endpoint = await async_client.zero_trust.gateway.proxy_endpoints.list( account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(AsyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -325,7 +325,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" proxy_endpoint = await response.parse() - assert_matches_type(AsyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -336,7 +336,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" proxy_endpoint = await response.parse() - assert_matches_type(AsyncSinglePage[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) assert cast(Any, response.is_closed) is True @@ -459,7 +459,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "ed35569b41ce4d1facfe683550f54086", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -471,7 +471,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" proxy_endpoint = await response.parse() - assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" proxy_endpoint = await response.parse() - assert_matches_type(Optional[ProxyEndpoint], proxy_endpoint, path=["response"]) + assert_matches_type(Optional[ProxyEndpointGetResponse], proxy_endpoint, path=["response"]) assert cast(Any, response.is_closed) is True From 8b8fd23a03c7c20c1cdd260c195e14301a0e687e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 20:16:06 +0000 Subject: [PATCH 266/532] feat(api): OpenAPI spec update via Stainless API (#747) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 35ba8798674..2ff6fd3a13b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f68e176f43592631364d94df7670824a599296f6734ca70ffa94454c58da466.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0560036bc26f789658066e3350d9d3e6d0d4168f1a4f8ba0e7f55ca889e3ebfe.yml diff --git a/api.md b/api.md index 8d42917a9ec..b961effc2c3 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 588623e18406e1b3d6a162416a66f34015c31da9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 20:19:02 +0000 Subject: [PATCH 267/532] feat(api): OpenAPI spec update via Stainless API (#748) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2ff6fd3a13b..b3c2fa72c4a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0560036bc26f789658066e3350d9d3e6d0d4168f1a4f8ba0e7f55ca889e3ebfe.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a18a8d7f1f80a39beb83a6541eb29dea4a69df37444aeb85493c94256c11d3a6.yml diff --git a/api.md b/api.md index b961effc2c3..8d42917a9ec 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From c64285555159e5f374c06a31a41c88e4e2023b7c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 20:21:12 +0000 Subject: [PATCH 268/532] feat(api): OpenAPI spec update via Stainless API (#749) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index b3c2fa72c4a..2ff6fd3a13b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a18a8d7f1f80a39beb83a6541eb29dea4a69df37444aeb85493c94256c11d3a6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0560036bc26f789658066e3350d9d3e6d0d4168f1a4f8ba0e7f55ca889e3ebfe.yml diff --git a/api.md b/api.md index 8d42917a9ec..b961effc2c3 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From cb5aa0599c74bf7d6c0a7018ac95677d4d739c2b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 20:35:33 +0000 Subject: [PATCH 269/532] feat(api): OpenAPI spec update via Stainless API (#750) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2ff6fd3a13b..b3c2fa72c4a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0560036bc26f789658066e3350d9d3e6d0d4168f1a4f8ba0e7f55ca889e3ebfe.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a18a8d7f1f80a39beb83a6541eb29dea4a69df37444aeb85493c94256c11d3a6.yml diff --git a/api.md b/api.md index b961effc2c3..8d42917a9ec 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 19b730bd51d04cf93868797e454563ddb62c3372 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 22:08:05 +0000 Subject: [PATCH 270/532] feat(api): OpenAPI spec update via Stainless API (#751) --- .stats.yml | 2 +- .../resources/zero_trust/dex/colos.py | 24 ++-- .../zero_trust/dex/fleet_status/devices.py | 42 ++++-- .../dex/fleet_status/fleet_status.py | 24 ++-- .../zero_trust/dex/http_tests/http_tests.py | 28 ++-- .../zero_trust/dex/http_tests/percentiles.py | 24 ++-- .../zero_trust/dex/traceroute_tests.py | 80 +++++------ .../types/zero_trust/dex/colo_list_params.py | 8 +- .../dex/fleet_status/device_list_params.py | 18 ++- .../dex/fleet_status_over_time_params.py | 8 +- .../zero_trust/dex/http_test_get_params.py | 8 +- .../dex/http_tests/percentile_get_params.py | 8 +- .../dex/traceroute_test_get_params.py | 8 +- .../traceroute_test_network_path_params.py | 8 +- .../dex/traceroute_test_percentiles_params.py | 8 +- .../network_path_get_response.py | 3 - .../dex/fleet_status/test_devices.py | 50 ++++--- .../dex/http_tests/test_percentiles.py | 48 +++---- .../zero_trust/dex/test_colos.py | 40 +++--- .../zero_trust/dex/test_fleet_status.py | 40 +++--- .../zero_trust/dex/test_http_tests.py | 48 +++---- .../zero_trust/dex/test_traceroute_tests.py | 136 +++++++++--------- 22 files changed, 350 insertions(+), 313 deletions(-) diff --git a/.stats.yml b/.stats.yml index b3c2fa72c4a..62a18d0f9d3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a18a8d7f1f80a39beb83a6541eb29dea4a69df37444aeb85493c94256c11d3a6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7080386fb1d04dafc80523803a44e41bab56e2907c13694ced938d02a3abb9d5.yml diff --git a/src/cloudflare/resources/zero_trust/dex/colos.py b/src/cloudflare/resources/zero_trust/dex/colos.py index 6423b82ef5a..82c072ad419 100644 --- a/src/cloudflare/resources/zero_trust/dex/colos.py +++ b/src/cloudflare/resources/zero_trust/dex/colos.py @@ -39,8 +39,8 @@ def list( self, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, sort_by: Literal["fleet-status-usage", "application-tests-usage"] | 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. @@ -55,9 +55,9 @@ def list( are also returned and sorted alphabetically. Args: - time_end: End time for connection period in RFC3339 (ISO 8601) format. + from_: Start time for connection period in RFC3339 (ISO 8601) format. - time_start: Start time for connection period in RFC3339 (ISO 8601) format. + to: End time for connection period in RFC3339 (ISO 8601) format. sort_by: Type of usage that colos should be sorted by. If unspecified, returns all Cloudflare colos sorted alphabetically. @@ -82,8 +82,8 @@ def list( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "sort_by": sort_by, }, colo_list_params.ColoListParams, @@ -106,8 +106,8 @@ def list( self, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, sort_by: Literal["fleet-status-usage", "application-tests-usage"] | 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. @@ -122,9 +122,9 @@ def list( are also returned and sorted alphabetically. Args: - time_end: End time for connection period in RFC3339 (ISO 8601) format. + from_: Start time for connection period in RFC3339 (ISO 8601) format. - time_start: Start time for connection period in RFC3339 (ISO 8601) format. + to: End time for connection period in RFC3339 (ISO 8601) format. sort_by: Type of usage that colos should be sorted by. If unspecified, returns all Cloudflare colos sorted alphabetically. @@ -149,8 +149,8 @@ def list( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "sort_by": sort_by, }, colo_list_params.ColoListParams, diff --git a/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py b/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py index 34a786574f9..1aec99e00cf 100644 --- a/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py +++ b/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py @@ -40,10 +40,11 @@ def list( self, *, account_id: str, + from_: str, page: float, per_page: float, - time_end: str, - time_start: str, + source: Literal["last_seen", "hourly", "raw"], + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, mode: str | NotGiven = NOT_GIVEN, @@ -63,13 +64,20 @@ def list( List details for devices using WARP Args: + from_: Timestamp in ISO format + page: Page number of paginated results per_page: Number of items per page - time_end: Timestamp in ISO format + source: + Source: + + - `hourly` - device details aggregated hourly, up to 7 days prior + - `last_seen` - device details, up to 24 hours prior + - `raw` - device details, up to 7 days prior - time_start: Timestamp in ISO format + to: Timestamp in ISO format colo: Cloudflare colo @@ -105,10 +113,11 @@ def list( timeout=timeout, query=maybe_transform( { + "from_": from_, "page": page, "per_page": per_page, - "time_end": time_end, - "time_start": time_start, + "source": source, + "to": to, "colo": colo, "device_id": device_id, "mode": mode, @@ -137,10 +146,11 @@ def list( self, *, account_id: str, + from_: str, page: float, per_page: float, - time_end: str, - time_start: str, + source: Literal["last_seen", "hourly", "raw"], + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, mode: str | NotGiven = NOT_GIVEN, @@ -160,13 +170,20 @@ def list( List details for devices using WARP Args: + from_: Timestamp in ISO format + page: Page number of paginated results per_page: Number of items per page - time_end: Timestamp in ISO format + source: + Source: + + - `hourly` - device details aggregated hourly, up to 7 days prior + - `last_seen` - device details, up to 24 hours prior + - `raw` - device details, up to 7 days prior - time_start: Timestamp in ISO format + to: Timestamp in ISO format colo: Cloudflare colo @@ -202,10 +219,11 @@ def list( timeout=timeout, query=maybe_transform( { + "from_": from_, "page": page, "per_page": per_page, - "time_end": time_end, - "time_start": time_start, + "source": source, + "to": to, "colo": colo, "device_id": device_id, "mode": mode, diff --git a/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py b/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py index 23033b3ea99..fd44aab6d52 100644 --- a/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py +++ b/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py @@ -95,8 +95,8 @@ def over_time( self, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -110,9 +110,9 @@ def over_time( List details for devices using WARP, up to 7 days Args: - time_end: Timestamp in ISO format + from_: Timestamp in ISO format - time_start: Timestamp in ISO format + to: Timestamp in ISO format colo: Cloudflare colo @@ -138,8 +138,8 @@ def over_time( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, @@ -210,8 +210,8 @@ async def over_time( self, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -225,9 +225,9 @@ async def over_time( List details for devices using WARP, up to 7 days Args: - time_end: Timestamp in ISO format + from_: Timestamp in ISO format - time_start: Timestamp in ISO format + to: Timestamp in ISO format colo: Cloudflare colo @@ -253,8 +253,8 @@ async def over_time( timeout=timeout, query=await async_maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py b/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py index 31b71442618..efeb1dec67e 100644 --- a/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py +++ b/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py @@ -56,9 +56,9 @@ def get( test_id: str, *, account_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -75,11 +75,11 @@ def get( Args: test_id: API Resource UUID tag. - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -108,9 +108,9 @@ def get( timeout=timeout, query=maybe_transform( { + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, "colo": colo, "device_id": device_id, }, @@ -140,9 +140,9 @@ async def get( test_id: str, *, account_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -159,11 +159,11 @@ async def get( Args: test_id: API Resource UUID tag. - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -192,9 +192,9 @@ async def get( timeout=timeout, query=await async_maybe_transform( { + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py b/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py index b8b4330a11c..3f38cee74f1 100644 --- a/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py +++ b/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py @@ -43,8 +43,8 @@ def get( test_id: str, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -61,9 +61,9 @@ def get( Args: test_id: API Resource UUID tag. - time_end: End time for aggregate metrics in ISO format + from_: Start time for aggregate metrics in ISO format - time_start: Start time for aggregate metrics in ISO format + to: End time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -92,8 +92,8 @@ def get( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, @@ -119,8 +119,8 @@ async def get( test_id: str, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -137,9 +137,9 @@ async def get( Args: test_id: API Resource UUID tag. - time_end: End time for aggregate metrics in ISO format + from_: Start time for aggregate metrics in ISO format - time_start: Start time for aggregate metrics in ISO format + to: End time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -168,8 +168,8 @@ async def get( timeout=timeout, query=await async_maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py b/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py index ebbf05826a8..865312380a0 100644 --- a/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py +++ b/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py @@ -50,9 +50,9 @@ def get( test_id: str, *, account_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -69,11 +69,11 @@ def get( Args: test_id: API Resource UUID tag. - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -102,9 +102,9 @@ def get( timeout=timeout, query=maybe_transform( { + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, "colo": colo, "device_id": device_id, }, @@ -121,9 +121,9 @@ def network_path( *, account_id: str, device_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: 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, @@ -139,11 +139,11 @@ def network_path( device_id: Device to filter tracroute result runs to - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms extra_headers: Send extra headers @@ -167,9 +167,9 @@ def network_path( query=maybe_transform( { "device_id": device_id, + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, }, traceroute_test_network_path_params.TracerouteTestNetworkPathParams, ), @@ -183,8 +183,8 @@ def percentiles( test_id: str, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -201,9 +201,9 @@ def percentiles( Args: test_id: API Resource UUID tag. - time_end: End time for aggregate metrics in ISO format + from_: Start time for aggregate metrics in ISO format - time_start: Start time for aggregate metrics in ISO format + to: End time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -232,8 +232,8 @@ def percentiles( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, @@ -261,9 +261,9 @@ async def get( test_id: str, *, account_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -280,11 +280,11 @@ async def get( Args: test_id: API Resource UUID tag. - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -313,9 +313,9 @@ async def get( timeout=timeout, query=await async_maybe_transform( { + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, "colo": colo, "device_id": device_id, }, @@ -332,9 +332,9 @@ async def network_path( *, account_id: str, device_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: 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, @@ -350,11 +350,11 @@ async def network_path( device_id: Device to filter tracroute result runs to - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms extra_headers: Send extra headers @@ -378,9 +378,9 @@ async def network_path( query=await async_maybe_transform( { "device_id": device_id, + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, }, traceroute_test_network_path_params.TracerouteTestNetworkPathParams, ), @@ -394,8 +394,8 @@ async def percentiles( test_id: str, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -412,9 +412,9 @@ async def percentiles( Args: test_id: API Resource UUID tag. - time_end: End time for aggregate metrics in ISO format + from_: Start time for aggregate metrics in ISO format - time_start: Start time for aggregate metrics in ISO format + to: End time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -443,8 +443,8 @@ async def percentiles( timeout=timeout, query=await async_maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/types/zero_trust/dex/colo_list_params.py b/src/cloudflare/types/zero_trust/dex/colo_list_params.py index f078937ff17..975e137ecac 100644 --- a/src/cloudflare/types/zero_trust/dex/colo_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/colo_list_params.py @@ -12,12 +12,12 @@ class ColoListParams(TypedDict, total=False): account_id: Required[str] - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] - """End time for connection period in RFC3339 (ISO 8601) format.""" - - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for connection period in RFC3339 (ISO 8601) format.""" + to: Required[str] + """End time for connection period in RFC3339 (ISO 8601) format.""" + sort_by: Annotated[Literal["fleet-status-usage", "application-tests-usage"], PropertyInfo(alias="sortBy")] """Type of usage that colos should be sorted by. diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py index 187868d3ef2..f75de002a5a 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py @@ -2,7 +2,9 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ....._utils import PropertyInfo __all__ = ["DeviceListParams"] @@ -10,16 +12,24 @@ class DeviceListParams(TypedDict, total=False): account_id: Required[str] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] + """Timestamp in ISO format""" + page: Required[float] """Page number of paginated results""" per_page: Required[float] """Number of items per page""" - time_end: Required[str] - """Timestamp in ISO format""" + source: Required[Literal["last_seen", "hourly", "raw"]] + """Source: + + - `hourly` - device details aggregated hourly, up to 7 days prior + - `last_seen` - device details, up to 24 hours prior + - `raw` - device details, up to 7 days prior + """ - time_start: Required[str] + to: Required[str] """Timestamp in ISO format""" colo: str diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py index ce01bfb979e..42bb856443c 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py @@ -2,7 +2,9 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import Required, Annotated, TypedDict + +from ...._utils import PropertyInfo __all__ = ["FleetStatusOverTimeParams"] @@ -10,10 +12,10 @@ class FleetStatusOverTimeParams(TypedDict, total=False): account_id: Required[str] - time_end: Required[str] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Timestamp in ISO format""" - time_start: Required[str] + to: Required[str] """Timestamp in ISO format""" colo: str diff --git a/src/cloudflare/types/zero_trust/dex/http_test_get_params.py b/src/cloudflare/types/zero_trust/dex/http_test_get_params.py index d0ce2cbe5d3..dd57bbf6128 100644 --- a/src/cloudflare/types/zero_trust/dex/http_test_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/http_test_get_params.py @@ -13,15 +13,15 @@ class HTTPTestGetParams(TypedDict, total=False): account_id: Required[str] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] + """Start time for aggregate metrics in ISO ms""" + interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] + to: Required[str] """End time for aggregate metrics in ISO ms""" - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] - """Start time for aggregate metrics in ISO ms""" - colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py b/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py index febc0fd6177..78d1009603e 100644 --- a/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py @@ -13,12 +13,12 @@ class PercentileGetParams(TypedDict, total=False): account_id: Required[str] - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] - """End time for aggregate metrics in ISO format""" - - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for aggregate metrics in ISO format""" + to: Required[str] + """End time for aggregate metrics in ISO format""" + colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py index dc8afa0c5d9..54b4a51b5fb 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py @@ -13,15 +13,15 @@ class TracerouteTestGetParams(TypedDict, total=False): account_id: Required[str] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] + """Start time for aggregate metrics in ISO ms""" + interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] + to: Required[str] """End time for aggregate metrics in ISO ms""" - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] - """Start time for aggregate metrics in ISO ms""" - colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py index b23b29c2bff..b6ffc3f49e0 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py @@ -15,11 +15,11 @@ class TracerouteTestNetworkPathParams(TypedDict, total=False): device_id: Required[Annotated[str, PropertyInfo(alias="deviceId")]] """Device to filter tracroute result runs to""" + from_: Required[Annotated[str, PropertyInfo(alias="from")]] + """Start time for aggregate metrics in ISO ms""" + interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] + to: Required[str] """End time for aggregate metrics in ISO ms""" - - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] - """Start time for aggregate metrics in ISO ms""" diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py index 5a4199a097d..d6ada52d1d2 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py @@ -13,12 +13,12 @@ class TracerouteTestPercentilesParams(TypedDict, total=False): account_id: Required[str] - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] - """End time for aggregate metrics in ISO format""" - - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for aggregate metrics in ISO format""" + to: Required[str] + """End time for aggregate metrics in ISO format""" + colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py index 2dc7a507b92..8b14533ea18 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py @@ -45,9 +45,6 @@ class NetworkPathGetResponse(BaseModel): result_id: str = FieldInfo(alias="resultId") """API Resource UUID tag.""" - time_start: str - """date time of this traceroute test""" - device_name: Optional[str] = FieldInfo(alias="deviceName", default=None) """name of the device associated with this network path response""" diff --git a/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py b/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py index 3f7e10dbbc6..53def98e79c 100644 --- a/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py +++ b/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py @@ -23,10 +23,11 @@ class TestDevices: def test_method_list(self, client: Cloudflare) -> None: device = client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) assert_matches_type(SyncV4PagePaginationArray[DeviceListResponse], device, path=["response"]) @@ -35,10 +36,11 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: device = client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", mode="proxy", @@ -54,10 +56,11 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.dex.fleet_status.devices.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -70,10 +73,11 @@ def test_raw_response_list(self, client: Cloudflare) -> None: def test_streaming_response_list(self, client: Cloudflare) -> None: with client.zero_trust.dex.fleet_status.devices.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -89,10 +93,11 @@ 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.dex.fleet_status.devices.with_raw_response.list( account_id="", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) @@ -104,10 +109,11 @@ class TestAsyncDevices: async def test_method_list(self, async_client: AsyncCloudflare) -> None: device = await async_client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) assert_matches_type(AsyncV4PagePaginationArray[DeviceListResponse], device, path=["response"]) @@ -116,10 +122,11 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: device = await async_client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", mode="proxy", @@ -135,10 +142,11 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.fleet_status.devices.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -151,10 +159,11 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.fleet_status.devices.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -170,8 +179,9 @@ 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.dex.fleet_status.devices.with_raw_response.list( account_id="", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py b/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py index 417e9fe4ec4..73561c37fb5 100644 --- a/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py +++ b/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py @@ -22,8 +22,8 @@ def test_method_get(self, client: Cloudflare) -> None: percentile = client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[HTTPDetailsPercentiles], percentile, path=["response"]) @@ -32,8 +32,8 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: percentile = client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -44,8 +44,8 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -58,8 +58,8 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.http_tests.percentiles.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -75,16 +75,16 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) @@ -96,8 +96,8 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: percentile = await async_client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[HTTPDetailsPercentiles], percentile, path=["response"]) @@ -106,8 +106,8 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - percentile = await async_client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -118,8 +118,8 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -132,8 +132,8 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.http_tests.percentiles.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -149,14 +149,14 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_colos.py b/tests/api_resources/zero_trust/dex/test_colos.py index ea3b48d65ae..8e4d0db4399 100644 --- a/tests/api_resources/zero_trust/dex/test_colos.py +++ b/tests/api_resources/zero_trust/dex/test_colos.py @@ -21,8 +21,8 @@ class TestColos: def test_method_list(self, client: Cloudflare) -> None: colo = client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) assert_matches_type(SyncSinglePage[object], colo, path=["response"]) @@ -30,8 +30,8 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: colo = client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", sort_by="fleet-status-usage", ) assert_matches_type(SyncSinglePage[object], colo, path=["response"]) @@ -40,8 +40,8 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.dex.colos.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) assert response.is_closed is True @@ -53,8 +53,8 @@ def test_raw_response_list(self, client: Cloudflare) -> None: def test_streaming_response_list(self, client: Cloudflare) -> None: with client.zero_trust.dex.colos.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -69,8 +69,8 @@ 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.dex.colos.with_raw_response.list( account_id="", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) @@ -81,8 +81,8 @@ class TestAsyncColos: async def test_method_list(self, async_client: AsyncCloudflare) -> None: colo = await async_client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) assert_matches_type(AsyncSinglePage[object], colo, path=["response"]) @@ -90,8 +90,8 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: colo = await async_client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", sort_by="fleet-status-usage", ) assert_matches_type(AsyncSinglePage[object], colo, path=["response"]) @@ -100,8 +100,8 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.colos.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) assert response.is_closed is True @@ -113,8 +113,8 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.colos.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -129,6 +129,6 @@ 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.dex.colos.with_raw_response.list( account_id="", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_fleet_status.py b/tests/api_resources/zero_trust/dex/test_fleet_status.py index c8810f5404b..db1676eacde 100644 --- a/tests/api_resources/zero_trust/dex/test_fleet_status.py +++ b/tests/api_resources/zero_trust/dex/test_fleet_status.py @@ -65,8 +65,8 @@ def test_path_params_live(self, client: Cloudflare) -> None: def test_method_over_time(self, client: Cloudflare) -> None: fleet_status = client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) assert fleet_status is None @@ -74,8 +74,8 @@ def test_method_over_time(self, client: Cloudflare) -> None: def test_method_over_time_with_all_params(self, client: Cloudflare) -> None: fleet_status = client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", ) @@ -85,8 +85,8 @@ def test_method_over_time_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_over_time(self, client: Cloudflare) -> None: response = client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -98,8 +98,8 @@ def test_raw_response_over_time(self, client: Cloudflare) -> None: def test_streaming_response_over_time(self, client: Cloudflare) -> None: with client.zero_trust.dex.fleet_status.with_streaming_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -114,8 +114,8 @@ def test_path_params_over_time(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) @@ -168,8 +168,8 @@ async def test_path_params_live(self, async_client: AsyncCloudflare) -> None: async def test_method_over_time(self, async_client: AsyncCloudflare) -> None: fleet_status = await async_client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) assert fleet_status is None @@ -177,8 +177,8 @@ async def test_method_over_time(self, async_client: AsyncCloudflare) -> None: async def test_method_over_time_with_all_params(self, async_client: AsyncCloudflare) -> None: fleet_status = await async_client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", ) @@ -188,8 +188,8 @@ async def test_method_over_time_with_all_params(self, async_client: AsyncCloudfl async def test_raw_response_over_time(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -201,8 +201,8 @@ async def test_raw_response_over_time(self, async_client: AsyncCloudflare) -> No async def test_streaming_response_over_time(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.fleet_status.with_streaming_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -217,6 +217,6 @@ async def test_path_params_over_time(self, async_client: AsyncCloudflare) -> Non with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_http_tests.py b/tests/api_resources/zero_trust/dex/test_http_tests.py index 48a2fa21dfe..2b038de5a40 100644 --- a/tests/api_resources/zero_trust/dex/test_http_tests.py +++ b/tests/api_resources/zero_trust/dex/test_http_tests.py @@ -22,9 +22,9 @@ def test_method_get(self, client: Cloudflare) -> None: http_test = client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[HTTPDetails], http_test, path=["response"]) @@ -33,9 +33,9 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: http_test = client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", colo="string", device_id=["string", "string", "string"], ) @@ -46,9 +46,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -61,9 +61,9 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.http_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -79,18 +79,18 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.http_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @@ -102,9 +102,9 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: http_test = await async_client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[HTTPDetails], http_test, path=["response"]) @@ -113,9 +113,9 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - http_test = await async_client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", colo="string", device_id=["string", "string", "string"], ) @@ -126,9 +126,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -141,9 +141,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.http_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -159,16 +159,16 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.http_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) diff --git a/tests/api_resources/zero_trust/dex/test_traceroute_tests.py b/tests/api_resources/zero_trust/dex/test_traceroute_tests.py index 687a44e7675..a5a47a30db8 100644 --- a/tests/api_resources/zero_trust/dex/test_traceroute_tests.py +++ b/tests/api_resources/zero_trust/dex/test_traceroute_tests.py @@ -26,9 +26,9 @@ def test_method_get(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[Traceroute], traceroute_test, path=["response"]) @@ -37,9 +37,9 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", colo="string", device_id=["string", "string", "string"], ) @@ -50,9 +50,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -65,9 +65,9 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.traceroute_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -83,18 +83,18 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.traceroute_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @parametrize @@ -103,9 +103,9 @@ def test_method_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[NetworkPathResponse], traceroute_test, path=["response"]) @@ -115,9 +115,9 @@ def test_raw_response_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -131,9 +131,9 @@ def test_streaming_response_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -150,9 +150,9 @@ def test_path_params_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): @@ -160,9 +160,9 @@ def test_path_params_network_path(self, client: Cloudflare) -> None: "", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @parametrize @@ -170,8 +170,8 @@ def test_method_percentiles(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[TracerouteTestPercentilesResponse], traceroute_test, path=["response"]) @@ -180,8 +180,8 @@ def test_method_percentiles_with_all_params(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -192,8 +192,8 @@ def test_raw_response_percentiles(self, client: Cloudflare) -> None: response = client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -206,8 +206,8 @@ def test_streaming_response_percentiles(self, client: Cloudflare) -> None: with client.zero_trust.dex.traceroute_tests.with_streaming_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -223,16 +223,16 @@ def test_path_params_percentiles(self, client: Cloudflare) -> None: client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) @@ -244,9 +244,9 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: traceroute_test = await async_client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[Traceroute], traceroute_test, path=["response"]) @@ -255,9 +255,9 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - traceroute_test = await async_client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", colo="string", device_id=["string", "string", "string"], ) @@ -268,9 +268,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -283,9 +283,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.traceroute_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -301,18 +301,18 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @parametrize @@ -321,9 +321,9 @@ async def test_method_network_path(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[NetworkPathResponse], traceroute_test, path=["response"]) @@ -333,9 +333,9 @@ async def test_raw_response_network_path(self, async_client: AsyncCloudflare) -> "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -349,9 +349,9 @@ async def test_streaming_response_network_path(self, async_client: AsyncCloudfla "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -368,9 +368,9 @@ async def test_path_params_network_path(self, async_client: AsyncCloudflare) -> "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): @@ -378,9 +378,9 @@ async def test_path_params_network_path(self, async_client: AsyncCloudflare) -> "", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @parametrize @@ -388,8 +388,8 @@ async def test_method_percentiles(self, async_client: AsyncCloudflare) -> None: traceroute_test = await async_client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[TracerouteTestPercentilesResponse], traceroute_test, path=["response"]) @@ -398,8 +398,8 @@ async def test_method_percentiles_with_all_params(self, async_client: AsyncCloud traceroute_test = await async_client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -410,8 +410,8 @@ async def test_raw_response_percentiles(self, async_client: AsyncCloudflare) -> response = await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -424,8 +424,8 @@ async def test_streaming_response_percentiles(self, async_client: AsyncCloudflar async with async_client.zero_trust.dex.traceroute_tests.with_streaming_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -441,14 +441,14 @@ async def test_path_params_percentiles(self, async_client: AsyncCloudflare) -> N await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) From 9b0b40de707fb282debb67242c7bcf4db4ff9572 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 22:10:17 +0000 Subject: [PATCH 271/532] feat(api): OpenAPI spec update via Stainless API (#752) --- .stats.yml | 2 +- .../resources/zero_trust/dex/colos.py | 24 ++-- .../zero_trust/dex/fleet_status/devices.py | 42 ++---- .../dex/fleet_status/fleet_status.py | 24 ++-- .../zero_trust/dex/http_tests/http_tests.py | 28 ++-- .../zero_trust/dex/http_tests/percentiles.py | 24 ++-- .../zero_trust/dex/traceroute_tests.py | 80 +++++------ .../types/zero_trust/dex/colo_list_params.py | 8 +- .../dex/fleet_status/device_list_params.py | 18 +-- .../dex/fleet_status_over_time_params.py | 8 +- .../zero_trust/dex/http_test_get_params.py | 8 +- .../dex/http_tests/percentile_get_params.py | 8 +- .../dex/traceroute_test_get_params.py | 8 +- .../traceroute_test_network_path_params.py | 8 +- .../dex/traceroute_test_percentiles_params.py | 8 +- .../network_path_get_response.py | 3 + .../dex/fleet_status/test_devices.py | 50 +++---- .../dex/http_tests/test_percentiles.py | 48 +++---- .../zero_trust/dex/test_colos.py | 40 +++--- .../zero_trust/dex/test_fleet_status.py | 40 +++--- .../zero_trust/dex/test_http_tests.py | 48 +++---- .../zero_trust/dex/test_traceroute_tests.py | 136 +++++++++--------- 22 files changed, 313 insertions(+), 350 deletions(-) diff --git a/.stats.yml b/.stats.yml index 62a18d0f9d3..b3c2fa72c4a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7080386fb1d04dafc80523803a44e41bab56e2907c13694ced938d02a3abb9d5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a18a8d7f1f80a39beb83a6541eb29dea4a69df37444aeb85493c94256c11d3a6.yml diff --git a/src/cloudflare/resources/zero_trust/dex/colos.py b/src/cloudflare/resources/zero_trust/dex/colos.py index 82c072ad419..6423b82ef5a 100644 --- a/src/cloudflare/resources/zero_trust/dex/colos.py +++ b/src/cloudflare/resources/zero_trust/dex/colos.py @@ -39,8 +39,8 @@ def list( self, *, account_id: str, - from_: str, - to: str, + time_end: str, + time_start: str, sort_by: Literal["fleet-status-usage", "application-tests-usage"] | 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. @@ -55,9 +55,9 @@ def list( are also returned and sorted alphabetically. Args: - from_: Start time for connection period in RFC3339 (ISO 8601) format. + time_end: End time for connection period in RFC3339 (ISO 8601) format. - to: End time for connection period in RFC3339 (ISO 8601) format. + time_start: Start time for connection period in RFC3339 (ISO 8601) format. sort_by: Type of usage that colos should be sorted by. If unspecified, returns all Cloudflare colos sorted alphabetically. @@ -82,8 +82,8 @@ def list( timeout=timeout, query=maybe_transform( { - "from_": from_, - "to": to, + "time_end": time_end, + "time_start": time_start, "sort_by": sort_by, }, colo_list_params.ColoListParams, @@ -106,8 +106,8 @@ def list( self, *, account_id: str, - from_: str, - to: str, + time_end: str, + time_start: str, sort_by: Literal["fleet-status-usage", "application-tests-usage"] | 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. @@ -122,9 +122,9 @@ def list( are also returned and sorted alphabetically. Args: - from_: Start time for connection period in RFC3339 (ISO 8601) format. + time_end: End time for connection period in RFC3339 (ISO 8601) format. - to: End time for connection period in RFC3339 (ISO 8601) format. + time_start: Start time for connection period in RFC3339 (ISO 8601) format. sort_by: Type of usage that colos should be sorted by. If unspecified, returns all Cloudflare colos sorted alphabetically. @@ -149,8 +149,8 @@ def list( timeout=timeout, query=maybe_transform( { - "from_": from_, - "to": to, + "time_end": time_end, + "time_start": time_start, "sort_by": sort_by, }, colo_list_params.ColoListParams, diff --git a/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py b/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py index 1aec99e00cf..34a786574f9 100644 --- a/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py +++ b/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py @@ -40,11 +40,10 @@ def list( self, *, account_id: str, - from_: str, page: float, per_page: float, - source: Literal["last_seen", "hourly", "raw"], - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, mode: str | NotGiven = NOT_GIVEN, @@ -64,20 +63,13 @@ def list( List details for devices using WARP Args: - from_: Timestamp in ISO format - page: Page number of paginated results per_page: Number of items per page - source: - Source: - - - `hourly` - device details aggregated hourly, up to 7 days prior - - `last_seen` - device details, up to 24 hours prior - - `raw` - device details, up to 7 days prior + time_end: Timestamp in ISO format - to: Timestamp in ISO format + time_start: Timestamp in ISO format colo: Cloudflare colo @@ -113,11 +105,10 @@ def list( timeout=timeout, query=maybe_transform( { - "from_": from_, "page": page, "per_page": per_page, - "source": source, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, "mode": mode, @@ -146,11 +137,10 @@ def list( self, *, account_id: str, - from_: str, page: float, per_page: float, - source: Literal["last_seen", "hourly", "raw"], - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, mode: str | NotGiven = NOT_GIVEN, @@ -170,20 +160,13 @@ def list( List details for devices using WARP Args: - from_: Timestamp in ISO format - page: Page number of paginated results per_page: Number of items per page - source: - Source: - - - `hourly` - device details aggregated hourly, up to 7 days prior - - `last_seen` - device details, up to 24 hours prior - - `raw` - device details, up to 7 days prior + time_end: Timestamp in ISO format - to: Timestamp in ISO format + time_start: Timestamp in ISO format colo: Cloudflare colo @@ -219,11 +202,10 @@ def list( timeout=timeout, query=maybe_transform( { - "from_": from_, "page": page, "per_page": per_page, - "source": source, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, "mode": mode, diff --git a/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py b/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py index fd44aab6d52..23033b3ea99 100644 --- a/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py +++ b/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py @@ -95,8 +95,8 @@ def over_time( self, *, account_id: str, - from_: str, - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -110,9 +110,9 @@ def over_time( List details for devices using WARP, up to 7 days Args: - from_: Timestamp in ISO format + time_end: Timestamp in ISO format - to: Timestamp in ISO format + time_start: Timestamp in ISO format colo: Cloudflare colo @@ -138,8 +138,8 @@ def over_time( timeout=timeout, query=maybe_transform( { - "from_": from_, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, @@ -210,8 +210,8 @@ async def over_time( self, *, account_id: str, - from_: str, - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -225,9 +225,9 @@ async def over_time( List details for devices using WARP, up to 7 days Args: - from_: Timestamp in ISO format + time_end: Timestamp in ISO format - to: Timestamp in ISO format + time_start: Timestamp in ISO format colo: Cloudflare colo @@ -253,8 +253,8 @@ async def over_time( timeout=timeout, query=await async_maybe_transform( { - "from_": from_, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py b/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py index efeb1dec67e..31b71442618 100644 --- a/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py +++ b/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py @@ -56,9 +56,9 @@ def get( test_id: str, *, account_id: str, - from_: str, interval: Literal["minute", "hour"], - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -75,11 +75,11 @@ def get( Args: test_id: API Resource UUID tag. - from_: Start time for aggregate metrics in ISO ms - interval: Time interval for aggregate time slots. - to: End time for aggregate metrics in ISO ms + time_end: End time for aggregate metrics in ISO ms + + time_start: Start time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -108,9 +108,9 @@ def get( timeout=timeout, query=maybe_transform( { - "from_": from_, "interval": interval, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, @@ -140,9 +140,9 @@ async def get( test_id: str, *, account_id: str, - from_: str, interval: Literal["minute", "hour"], - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -159,11 +159,11 @@ async def get( Args: test_id: API Resource UUID tag. - from_: Start time for aggregate metrics in ISO ms - interval: Time interval for aggregate time slots. - to: End time for aggregate metrics in ISO ms + time_end: End time for aggregate metrics in ISO ms + + time_start: Start time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -192,9 +192,9 @@ async def get( timeout=timeout, query=await async_maybe_transform( { - "from_": from_, "interval": interval, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py b/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py index 3f38cee74f1..b8b4330a11c 100644 --- a/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py +++ b/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py @@ -43,8 +43,8 @@ def get( test_id: str, *, account_id: str, - from_: str, - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -61,9 +61,9 @@ def get( Args: test_id: API Resource UUID tag. - from_: Start time for aggregate metrics in ISO format + time_end: End time for aggregate metrics in ISO format - to: End time for aggregate metrics in ISO format + time_start: Start time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -92,8 +92,8 @@ def get( timeout=timeout, query=maybe_transform( { - "from_": from_, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, @@ -119,8 +119,8 @@ async def get( test_id: str, *, account_id: str, - from_: str, - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -137,9 +137,9 @@ async def get( Args: test_id: API Resource UUID tag. - from_: Start time for aggregate metrics in ISO format + time_end: End time for aggregate metrics in ISO format - to: End time for aggregate metrics in ISO format + time_start: Start time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -168,8 +168,8 @@ async def get( timeout=timeout, query=await async_maybe_transform( { - "from_": from_, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py b/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py index 865312380a0..ebbf05826a8 100644 --- a/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py +++ b/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py @@ -50,9 +50,9 @@ def get( test_id: str, *, account_id: str, - from_: str, interval: Literal["minute", "hour"], - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -69,11 +69,11 @@ def get( Args: test_id: API Resource UUID tag. - from_: Start time for aggregate metrics in ISO ms - interval: Time interval for aggregate time slots. - to: End time for aggregate metrics in ISO ms + time_end: End time for aggregate metrics in ISO ms + + time_start: Start time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -102,9 +102,9 @@ def get( timeout=timeout, query=maybe_transform( { - "from_": from_, "interval": interval, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, @@ -121,9 +121,9 @@ def network_path( *, account_id: str, device_id: str, - from_: str, interval: Literal["minute", "hour"], - to: str, + time_end: str, + time_start: 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, @@ -139,11 +139,11 @@ def network_path( device_id: Device to filter tracroute result runs to - from_: Start time for aggregate metrics in ISO ms - interval: Time interval for aggregate time slots. - to: End time for aggregate metrics in ISO ms + time_end: End time for aggregate metrics in ISO ms + + time_start: Start time for aggregate metrics in ISO ms extra_headers: Send extra headers @@ -167,9 +167,9 @@ def network_path( query=maybe_transform( { "device_id": device_id, - "from_": from_, "interval": interval, - "to": to, + "time_end": time_end, + "time_start": time_start, }, traceroute_test_network_path_params.TracerouteTestNetworkPathParams, ), @@ -183,8 +183,8 @@ def percentiles( test_id: str, *, account_id: str, - from_: str, - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -201,9 +201,9 @@ def percentiles( Args: test_id: API Resource UUID tag. - from_: Start time for aggregate metrics in ISO format + time_end: End time for aggregate metrics in ISO format - to: End time for aggregate metrics in ISO format + time_start: Start time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -232,8 +232,8 @@ def percentiles( timeout=timeout, query=maybe_transform( { - "from_": from_, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, @@ -261,9 +261,9 @@ async def get( test_id: str, *, account_id: str, - from_: str, interval: Literal["minute", "hour"], - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -280,11 +280,11 @@ async def get( Args: test_id: API Resource UUID tag. - from_: Start time for aggregate metrics in ISO ms - interval: Time interval for aggregate time slots. - to: End time for aggregate metrics in ISO ms + time_end: End time for aggregate metrics in ISO ms + + time_start: Start time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -313,9 +313,9 @@ async def get( timeout=timeout, query=await async_maybe_transform( { - "from_": from_, "interval": interval, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, @@ -332,9 +332,9 @@ async def network_path( *, account_id: str, device_id: str, - from_: str, interval: Literal["minute", "hour"], - to: str, + time_end: str, + time_start: 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, @@ -350,11 +350,11 @@ async def network_path( device_id: Device to filter tracroute result runs to - from_: Start time for aggregate metrics in ISO ms - interval: Time interval for aggregate time slots. - to: End time for aggregate metrics in ISO ms + time_end: End time for aggregate metrics in ISO ms + + time_start: Start time for aggregate metrics in ISO ms extra_headers: Send extra headers @@ -378,9 +378,9 @@ async def network_path( query=await async_maybe_transform( { "device_id": device_id, - "from_": from_, "interval": interval, - "to": to, + "time_end": time_end, + "time_start": time_start, }, traceroute_test_network_path_params.TracerouteTestNetworkPathParams, ), @@ -394,8 +394,8 @@ async def percentiles( test_id: str, *, account_id: str, - from_: str, - to: str, + time_end: str, + time_start: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -412,9 +412,9 @@ async def percentiles( Args: test_id: API Resource UUID tag. - from_: Start time for aggregate metrics in ISO format + time_end: End time for aggregate metrics in ISO format - to: End time for aggregate metrics in ISO format + time_start: Start time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -443,8 +443,8 @@ async def percentiles( timeout=timeout, query=await async_maybe_transform( { - "from_": from_, - "to": to, + "time_end": time_end, + "time_start": time_start, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/types/zero_trust/dex/colo_list_params.py b/src/cloudflare/types/zero_trust/dex/colo_list_params.py index 975e137ecac..f078937ff17 100644 --- a/src/cloudflare/types/zero_trust/dex/colo_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/colo_list_params.py @@ -12,12 +12,12 @@ class ColoListParams(TypedDict, total=False): account_id: Required[str] - from_: Required[Annotated[str, PropertyInfo(alias="from")]] - """Start time for connection period in RFC3339 (ISO 8601) format.""" - - to: Required[str] + time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] """End time for connection period in RFC3339 (ISO 8601) format.""" + time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + """Start time for connection period in RFC3339 (ISO 8601) format.""" + sort_by: Annotated[Literal["fleet-status-usage", "application-tests-usage"], PropertyInfo(alias="sortBy")] """Type of usage that colos should be sorted by. diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py index f75de002a5a..187868d3ef2 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py @@ -2,9 +2,7 @@ from __future__ import annotations -from typing_extensions import Literal, Required, Annotated, TypedDict - -from ....._utils import PropertyInfo +from typing_extensions import Literal, Required, TypedDict __all__ = ["DeviceListParams"] @@ -12,24 +10,16 @@ class DeviceListParams(TypedDict, total=False): account_id: Required[str] - from_: Required[Annotated[str, PropertyInfo(alias="from")]] - """Timestamp in ISO format""" - page: Required[float] """Page number of paginated results""" per_page: Required[float] """Number of items per page""" - source: Required[Literal["last_seen", "hourly", "raw"]] - """Source: - - - `hourly` - device details aggregated hourly, up to 7 days prior - - `last_seen` - device details, up to 24 hours prior - - `raw` - device details, up to 7 days prior - """ + time_end: Required[str] + """Timestamp in ISO format""" - to: Required[str] + time_start: Required[str] """Timestamp in ISO format""" colo: str diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py index 42bb856443c..ce01bfb979e 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py @@ -2,9 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, Annotated, TypedDict - -from ...._utils import PropertyInfo +from typing_extensions import Required, TypedDict __all__ = ["FleetStatusOverTimeParams"] @@ -12,10 +10,10 @@ class FleetStatusOverTimeParams(TypedDict, total=False): account_id: Required[str] - from_: Required[Annotated[str, PropertyInfo(alias="from")]] + time_end: Required[str] """Timestamp in ISO format""" - to: Required[str] + time_start: Required[str] """Timestamp in ISO format""" colo: str diff --git a/src/cloudflare/types/zero_trust/dex/http_test_get_params.py b/src/cloudflare/types/zero_trust/dex/http_test_get_params.py index dd57bbf6128..d0ce2cbe5d3 100644 --- a/src/cloudflare/types/zero_trust/dex/http_test_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/http_test_get_params.py @@ -13,15 +13,15 @@ class HTTPTestGetParams(TypedDict, total=False): account_id: Required[str] - from_: Required[Annotated[str, PropertyInfo(alias="from")]] - """Start time for aggregate metrics in ISO ms""" - interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - to: Required[str] + time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] """End time for aggregate metrics in ISO ms""" + time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + """Start time for aggregate metrics in ISO ms""" + colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py b/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py index 78d1009603e..febc0fd6177 100644 --- a/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py @@ -13,12 +13,12 @@ class PercentileGetParams(TypedDict, total=False): account_id: Required[str] - from_: Required[Annotated[str, PropertyInfo(alias="from")]] - """Start time for aggregate metrics in ISO format""" - - to: Required[str] + time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] """End time for aggregate metrics in ISO format""" + time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + """Start time for aggregate metrics in ISO format""" + colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py index 54b4a51b5fb..dc8afa0c5d9 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py @@ -13,15 +13,15 @@ class TracerouteTestGetParams(TypedDict, total=False): account_id: Required[str] - from_: Required[Annotated[str, PropertyInfo(alias="from")]] - """Start time for aggregate metrics in ISO ms""" - interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - to: Required[str] + time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] """End time for aggregate metrics in ISO ms""" + time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + """Start time for aggregate metrics in ISO ms""" + colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py index b6ffc3f49e0..b23b29c2bff 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py @@ -15,11 +15,11 @@ class TracerouteTestNetworkPathParams(TypedDict, total=False): device_id: Required[Annotated[str, PropertyInfo(alias="deviceId")]] """Device to filter tracroute result runs to""" - from_: Required[Annotated[str, PropertyInfo(alias="from")]] - """Start time for aggregate metrics in ISO ms""" - interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - to: Required[str] + time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] """End time for aggregate metrics in ISO ms""" + + time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + """Start time for aggregate metrics in ISO ms""" diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py index d6ada52d1d2..5a4199a097d 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py @@ -13,12 +13,12 @@ class TracerouteTestPercentilesParams(TypedDict, total=False): account_id: Required[str] - from_: Required[Annotated[str, PropertyInfo(alias="from")]] - """Start time for aggregate metrics in ISO format""" - - to: Required[str] + time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] """End time for aggregate metrics in ISO format""" + time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + """Start time for aggregate metrics in ISO format""" + colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py index 8b14533ea18..2dc7a507b92 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py @@ -45,6 +45,9 @@ class NetworkPathGetResponse(BaseModel): result_id: str = FieldInfo(alias="resultId") """API Resource UUID tag.""" + time_start: str + """date time of this traceroute test""" + device_name: Optional[str] = FieldInfo(alias="deviceName", default=None) """name of the device associated with this network path response""" diff --git a/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py b/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py index 53def98e79c..3f7e10dbbc6 100644 --- a/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py +++ b/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py @@ -23,11 +23,10 @@ class TestDevices: def test_method_list(self, client: Cloudflare) -> None: device = client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) assert_matches_type(SyncV4PagePaginationArray[DeviceListResponse], device, path=["response"]) @@ -36,11 +35,10 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: device = client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", mode="proxy", @@ -56,11 +54,10 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.dex.fleet_status.devices.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -73,11 +70,10 @@ def test_raw_response_list(self, client: Cloudflare) -> None: def test_streaming_response_list(self, client: Cloudflare) -> None: with client.zero_trust.dex.fleet_status.devices.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -93,11 +89,10 @@ 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.dex.fleet_status.devices.with_raw_response.list( account_id="", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) @@ -109,11 +104,10 @@ class TestAsyncDevices: async def test_method_list(self, async_client: AsyncCloudflare) -> None: device = await async_client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) assert_matches_type(AsyncV4PagePaginationArray[DeviceListResponse], device, path=["response"]) @@ -122,11 +116,10 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: device = await async_client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", mode="proxy", @@ -142,11 +135,10 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.fleet_status.devices.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -159,11 +151,10 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.fleet_status.devices.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -179,9 +170,8 @@ 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.dex.fleet_status.devices.with_raw_response.list( account_id="", - from_="2023-10-11T00:00:00Z", page=1, per_page=10, - source="last_seen", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py b/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py index 73561c37fb5..417e9fe4ec4 100644 --- a/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py +++ b/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py @@ -22,8 +22,8 @@ def test_method_get(self, client: Cloudflare) -> None: percentile = client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[HTTPDetailsPercentiles], percentile, path=["response"]) @@ -32,8 +32,8 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: percentile = client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -44,8 +44,8 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -58,8 +58,8 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.http_tests.percentiles.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -75,16 +75,16 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) @@ -96,8 +96,8 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: percentile = await async_client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[HTTPDetailsPercentiles], percentile, path=["response"]) @@ -106,8 +106,8 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - percentile = await async_client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -118,8 +118,8 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -132,8 +132,8 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.http_tests.percentiles.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -149,14 +149,14 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_colos.py b/tests/api_resources/zero_trust/dex/test_colos.py index 8e4d0db4399..ea3b48d65ae 100644 --- a/tests/api_resources/zero_trust/dex/test_colos.py +++ b/tests/api_resources/zero_trust/dex/test_colos.py @@ -21,8 +21,8 @@ class TestColos: def test_method_list(self, client: Cloudflare) -> None: colo = client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", ) assert_matches_type(SyncSinglePage[object], colo, path=["response"]) @@ -30,8 +30,8 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: colo = client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", sort_by="fleet-status-usage", ) assert_matches_type(SyncSinglePage[object], colo, path=["response"]) @@ -40,8 +40,8 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.dex.colos.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", ) assert response.is_closed is True @@ -53,8 +53,8 @@ def test_raw_response_list(self, client: Cloudflare) -> None: def test_streaming_response_list(self, client: Cloudflare) -> None: with client.zero_trust.dex.colos.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -69,8 +69,8 @@ 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.dex.colos.with_raw_response.list( account_id="", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", ) @@ -81,8 +81,8 @@ class TestAsyncColos: async def test_method_list(self, async_client: AsyncCloudflare) -> None: colo = await async_client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", ) assert_matches_type(AsyncSinglePage[object], colo, path=["response"]) @@ -90,8 +90,8 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: colo = await async_client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", sort_by="fleet-status-usage", ) assert_matches_type(AsyncSinglePage[object], colo, path=["response"]) @@ -100,8 +100,8 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.colos.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", ) assert response.is_closed is True @@ -113,8 +113,8 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.colos.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -129,6 +129,6 @@ 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.dex.colos.with_raw_response.list( account_id="", - from_="2023-08-20T20:45:00Z", - to="2023-08-24T20:45:00Z", + time_end="2023-08-24T20:45:00Z", + time_start="2023-08-20T20:45:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_fleet_status.py b/tests/api_resources/zero_trust/dex/test_fleet_status.py index db1676eacde..c8810f5404b 100644 --- a/tests/api_resources/zero_trust/dex/test_fleet_status.py +++ b/tests/api_resources/zero_trust/dex/test_fleet_status.py @@ -65,8 +65,8 @@ def test_path_params_live(self, client: Cloudflare) -> None: def test_method_over_time(self, client: Cloudflare) -> None: fleet_status = client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) assert fleet_status is None @@ -74,8 +74,8 @@ def test_method_over_time(self, client: Cloudflare) -> None: def test_method_over_time_with_all_params(self, client: Cloudflare) -> None: fleet_status = client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", ) @@ -85,8 +85,8 @@ def test_method_over_time_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_over_time(self, client: Cloudflare) -> None: response = client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -98,8 +98,8 @@ def test_raw_response_over_time(self, client: Cloudflare) -> None: def test_streaming_response_over_time(self, client: Cloudflare) -> None: with client.zero_trust.dex.fleet_status.with_streaming_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -114,8 +114,8 @@ def test_path_params_over_time(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) @@ -168,8 +168,8 @@ async def test_path_params_live(self, async_client: AsyncCloudflare) -> None: async def test_method_over_time(self, async_client: AsyncCloudflare) -> None: fleet_status = await async_client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) assert fleet_status is None @@ -177,8 +177,8 @@ async def test_method_over_time(self, async_client: AsyncCloudflare) -> None: async def test_method_over_time_with_all_params(self, async_client: AsyncCloudflare) -> None: fleet_status = await async_client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", ) @@ -188,8 +188,8 @@ async def test_method_over_time_with_all_params(self, async_client: AsyncCloudfl async def test_raw_response_over_time(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -201,8 +201,8 @@ async def test_raw_response_over_time(self, async_client: AsyncCloudflare) -> No async def test_streaming_response_over_time(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.fleet_status.with_streaming_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -217,6 +217,6 @@ async def test_path_params_over_time(self, async_client: AsyncCloudflare) -> Non with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="", - from_="2023-10-11T00:00:00Z", - to="2023-10-11T00:00:00Z", + time_end="2023-10-11T00:00:00Z", + time_start="2023-10-11T00:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_http_tests.py b/tests/api_resources/zero_trust/dex/test_http_tests.py index 2b038de5a40..48a2fa21dfe 100644 --- a/tests/api_resources/zero_trust/dex/test_http_tests.py +++ b/tests/api_resources/zero_trust/dex/test_http_tests.py @@ -22,9 +22,9 @@ def test_method_get(self, client: Cloudflare) -> None: http_test = client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert_matches_type(Optional[HTTPDetails], http_test, path=["response"]) @@ -33,9 +33,9 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: http_test = client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", colo="string", device_id=["string", "string", "string"], ) @@ -46,9 +46,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert response.is_closed is True @@ -61,9 +61,9 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.http_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -79,18 +79,18 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.http_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) @@ -102,9 +102,9 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: http_test = await async_client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert_matches_type(Optional[HTTPDetails], http_test, path=["response"]) @@ -113,9 +113,9 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - http_test = await async_client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", colo="string", device_id=["string", "string", "string"], ) @@ -126,9 +126,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert response.is_closed is True @@ -141,9 +141,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.http_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -159,16 +159,16 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.http_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) diff --git a/tests/api_resources/zero_trust/dex/test_traceroute_tests.py b/tests/api_resources/zero_trust/dex/test_traceroute_tests.py index a5a47a30db8..687a44e7675 100644 --- a/tests/api_resources/zero_trust/dex/test_traceroute_tests.py +++ b/tests/api_resources/zero_trust/dex/test_traceroute_tests.py @@ -26,9 +26,9 @@ def test_method_get(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert_matches_type(Optional[Traceroute], traceroute_test, path=["response"]) @@ -37,9 +37,9 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", colo="string", device_id=["string", "string", "string"], ) @@ -50,9 +50,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert response.is_closed is True @@ -65,9 +65,9 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.traceroute_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -83,18 +83,18 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.traceroute_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) @parametrize @@ -103,9 +103,9 @@ def test_method_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert_matches_type(Optional[NetworkPathResponse], traceroute_test, path=["response"]) @@ -115,9 +115,9 @@ def test_raw_response_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert response.is_closed is True @@ -131,9 +131,9 @@ def test_streaming_response_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -150,9 +150,9 @@ def test_path_params_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): @@ -160,9 +160,9 @@ def test_path_params_network_path(self, client: Cloudflare) -> None: "", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) @parametrize @@ -170,8 +170,8 @@ def test_method_percentiles(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[TracerouteTestPercentilesResponse], traceroute_test, path=["response"]) @@ -180,8 +180,8 @@ def test_method_percentiles_with_all_params(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -192,8 +192,8 @@ def test_raw_response_percentiles(self, client: Cloudflare) -> None: response = client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -206,8 +206,8 @@ def test_streaming_response_percentiles(self, client: Cloudflare) -> None: with client.zero_trust.dex.traceroute_tests.with_streaming_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -223,16 +223,16 @@ def test_path_params_percentiles(self, client: Cloudflare) -> None: client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) @@ -244,9 +244,9 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: traceroute_test = await async_client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert_matches_type(Optional[Traceroute], traceroute_test, path=["response"]) @@ -255,9 +255,9 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - traceroute_test = await async_client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", colo="string", device_id=["string", "string", "string"], ) @@ -268,9 +268,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert response.is_closed is True @@ -283,9 +283,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.traceroute_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -301,18 +301,18 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) @parametrize @@ -321,9 +321,9 @@ async def test_method_network_path(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert_matches_type(Optional[NetworkPathResponse], traceroute_test, path=["response"]) @@ -333,9 +333,9 @@ async def test_raw_response_network_path(self, async_client: AsyncCloudflare) -> "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) assert response.is_closed is True @@ -349,9 +349,9 @@ async def test_streaming_response_network_path(self, async_client: AsyncCloudfla "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -368,9 +368,9 @@ async def test_path_params_network_path(self, async_client: AsyncCloudflare) -> "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): @@ -378,9 +378,9 @@ async def test_path_params_network_path(self, async_client: AsyncCloudflare) -> "", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", - from_="1689520412000", interval="minute", - to="1689606812000", + time_end="1689606812000", + time_start="1689520412000", ) @parametrize @@ -388,8 +388,8 @@ async def test_method_percentiles(self, async_client: AsyncCloudflare) -> None: traceroute_test = await async_client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[TracerouteTestPercentilesResponse], traceroute_test, path=["response"]) @@ -398,8 +398,8 @@ async def test_method_percentiles_with_all_params(self, async_client: AsyncCloud traceroute_test = await async_client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -410,8 +410,8 @@ async def test_raw_response_percentiles(self, async_client: AsyncCloudflare) -> response = await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -424,8 +424,8 @@ async def test_streaming_response_percentiles(self, async_client: AsyncCloudflar async with async_client.zero_trust.dex.traceroute_tests.with_streaming_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -441,14 +441,14 @@ async def test_path_params_percentiles(self, async_client: AsyncCloudflare) -> N await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "", account_id="01a7362d577a6c3019a474fd6f485823", - from_="2023-09-20T17:00:00Z", - to="2023-09-20T17:00:00Z", + time_end="2023-09-20T17:00:00Z", + time_start="2023-09-20T17:00:00Z", ) From cdb293551d9ef2d06e0f3379d79331d66cea3429 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 23:20:10 +0000 Subject: [PATCH 272/532] feat(api): OpenAPI spec update via Stainless API (#753) --- .stats.yml | 2 +- .../resources/zero_trust/dex/colos.py | 24 ++-- .../zero_trust/dex/fleet_status/devices.py | 42 ++++-- .../dex/fleet_status/fleet_status.py | 24 ++-- .../zero_trust/dex/http_tests/http_tests.py | 28 ++-- .../zero_trust/dex/http_tests/percentiles.py | 24 ++-- .../zero_trust/dex/traceroute_tests.py | 80 +++++------ .../types/zero_trust/dex/colo_list_params.py | 8 +- .../dex/fleet_status/device_list_params.py | 18 ++- .../dex/fleet_status_over_time_params.py | 8 +- .../zero_trust/dex/http_test_get_params.py | 8 +- .../dex/http_tests/percentile_get_params.py | 8 +- .../dex/traceroute_test_get_params.py | 8 +- .../traceroute_test_network_path_params.py | 8 +- .../dex/traceroute_test_percentiles_params.py | 8 +- .../network_path_get_response.py | 3 - .../dex/fleet_status/test_devices.py | 50 ++++--- .../dex/http_tests/test_percentiles.py | 48 +++---- .../zero_trust/dex/test_colos.py | 40 +++--- .../zero_trust/dex/test_fleet_status.py | 40 +++--- .../zero_trust/dex/test_http_tests.py | 48 +++---- .../zero_trust/dex/test_traceroute_tests.py | 136 +++++++++--------- 22 files changed, 350 insertions(+), 313 deletions(-) diff --git a/.stats.yml b/.stats.yml index b3c2fa72c4a..62a18d0f9d3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a18a8d7f1f80a39beb83a6541eb29dea4a69df37444aeb85493c94256c11d3a6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7080386fb1d04dafc80523803a44e41bab56e2907c13694ced938d02a3abb9d5.yml diff --git a/src/cloudflare/resources/zero_trust/dex/colos.py b/src/cloudflare/resources/zero_trust/dex/colos.py index 6423b82ef5a..82c072ad419 100644 --- a/src/cloudflare/resources/zero_trust/dex/colos.py +++ b/src/cloudflare/resources/zero_trust/dex/colos.py @@ -39,8 +39,8 @@ def list( self, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, sort_by: Literal["fleet-status-usage", "application-tests-usage"] | 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. @@ -55,9 +55,9 @@ def list( are also returned and sorted alphabetically. Args: - time_end: End time for connection period in RFC3339 (ISO 8601) format. + from_: Start time for connection period in RFC3339 (ISO 8601) format. - time_start: Start time for connection period in RFC3339 (ISO 8601) format. + to: End time for connection period in RFC3339 (ISO 8601) format. sort_by: Type of usage that colos should be sorted by. If unspecified, returns all Cloudflare colos sorted alphabetically. @@ -82,8 +82,8 @@ def list( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "sort_by": sort_by, }, colo_list_params.ColoListParams, @@ -106,8 +106,8 @@ def list( self, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, sort_by: Literal["fleet-status-usage", "application-tests-usage"] | 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. @@ -122,9 +122,9 @@ def list( are also returned and sorted alphabetically. Args: - time_end: End time for connection period in RFC3339 (ISO 8601) format. + from_: Start time for connection period in RFC3339 (ISO 8601) format. - time_start: Start time for connection period in RFC3339 (ISO 8601) format. + to: End time for connection period in RFC3339 (ISO 8601) format. sort_by: Type of usage that colos should be sorted by. If unspecified, returns all Cloudflare colos sorted alphabetically. @@ -149,8 +149,8 @@ def list( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "sort_by": sort_by, }, colo_list_params.ColoListParams, diff --git a/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py b/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py index 34a786574f9..1aec99e00cf 100644 --- a/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py +++ b/src/cloudflare/resources/zero_trust/dex/fleet_status/devices.py @@ -40,10 +40,11 @@ def list( self, *, account_id: str, + from_: str, page: float, per_page: float, - time_end: str, - time_start: str, + source: Literal["last_seen", "hourly", "raw"], + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, mode: str | NotGiven = NOT_GIVEN, @@ -63,13 +64,20 @@ def list( List details for devices using WARP Args: + from_: Timestamp in ISO format + page: Page number of paginated results per_page: Number of items per page - time_end: Timestamp in ISO format + source: + Source: + + - `hourly` - device details aggregated hourly, up to 7 days prior + - `last_seen` - device details, up to 24 hours prior + - `raw` - device details, up to 7 days prior - time_start: Timestamp in ISO format + to: Timestamp in ISO format colo: Cloudflare colo @@ -105,10 +113,11 @@ def list( timeout=timeout, query=maybe_transform( { + "from_": from_, "page": page, "per_page": per_page, - "time_end": time_end, - "time_start": time_start, + "source": source, + "to": to, "colo": colo, "device_id": device_id, "mode": mode, @@ -137,10 +146,11 @@ def list( self, *, account_id: str, + from_: str, page: float, per_page: float, - time_end: str, - time_start: str, + source: Literal["last_seen", "hourly", "raw"], + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, mode: str | NotGiven = NOT_GIVEN, @@ -160,13 +170,20 @@ def list( List details for devices using WARP Args: + from_: Timestamp in ISO format + page: Page number of paginated results per_page: Number of items per page - time_end: Timestamp in ISO format + source: + Source: + + - `hourly` - device details aggregated hourly, up to 7 days prior + - `last_seen` - device details, up to 24 hours prior + - `raw` - device details, up to 7 days prior - time_start: Timestamp in ISO format + to: Timestamp in ISO format colo: Cloudflare colo @@ -202,10 +219,11 @@ def list( timeout=timeout, query=maybe_transform( { + "from_": from_, "page": page, "per_page": per_page, - "time_end": time_end, - "time_start": time_start, + "source": source, + "to": to, "colo": colo, "device_id": device_id, "mode": mode, diff --git a/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py b/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py index 23033b3ea99..fd44aab6d52 100644 --- a/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py +++ b/src/cloudflare/resources/zero_trust/dex/fleet_status/fleet_status.py @@ -95,8 +95,8 @@ def over_time( self, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -110,9 +110,9 @@ def over_time( List details for devices using WARP, up to 7 days Args: - time_end: Timestamp in ISO format + from_: Timestamp in ISO format - time_start: Timestamp in ISO format + to: Timestamp in ISO format colo: Cloudflare colo @@ -138,8 +138,8 @@ def over_time( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, @@ -210,8 +210,8 @@ async def over_time( self, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -225,9 +225,9 @@ async def over_time( List details for devices using WARP, up to 7 days Args: - time_end: Timestamp in ISO format + from_: Timestamp in ISO format - time_start: Timestamp in ISO format + to: Timestamp in ISO format colo: Cloudflare colo @@ -253,8 +253,8 @@ async def over_time( timeout=timeout, query=await async_maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py b/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py index 31b71442618..efeb1dec67e 100644 --- a/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py +++ b/src/cloudflare/resources/zero_trust/dex/http_tests/http_tests.py @@ -56,9 +56,9 @@ def get( test_id: str, *, account_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -75,11 +75,11 @@ def get( Args: test_id: API Resource UUID tag. - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -108,9 +108,9 @@ def get( timeout=timeout, query=maybe_transform( { + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, "colo": colo, "device_id": device_id, }, @@ -140,9 +140,9 @@ async def get( test_id: str, *, account_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -159,11 +159,11 @@ async def get( Args: test_id: API Resource UUID tag. - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -192,9 +192,9 @@ async def get( timeout=timeout, query=await async_maybe_transform( { + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py b/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py index b8b4330a11c..3f38cee74f1 100644 --- a/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py +++ b/src/cloudflare/resources/zero_trust/dex/http_tests/percentiles.py @@ -43,8 +43,8 @@ def get( test_id: str, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -61,9 +61,9 @@ def get( Args: test_id: API Resource UUID tag. - time_end: End time for aggregate metrics in ISO format + from_: Start time for aggregate metrics in ISO format - time_start: Start time for aggregate metrics in ISO format + to: End time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -92,8 +92,8 @@ def get( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, @@ -119,8 +119,8 @@ async def get( test_id: str, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -137,9 +137,9 @@ async def get( Args: test_id: API Resource UUID tag. - time_end: End time for aggregate metrics in ISO format + from_: Start time for aggregate metrics in ISO format - time_start: Start time for aggregate metrics in ISO format + to: End time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -168,8 +168,8 @@ async def get( timeout=timeout, query=await async_maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py b/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py index ebbf05826a8..865312380a0 100644 --- a/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py +++ b/src/cloudflare/resources/zero_trust/dex/traceroute_tests.py @@ -50,9 +50,9 @@ def get( test_id: str, *, account_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -69,11 +69,11 @@ def get( Args: test_id: API Resource UUID tag. - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -102,9 +102,9 @@ def get( timeout=timeout, query=maybe_transform( { + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, "colo": colo, "device_id": device_id, }, @@ -121,9 +121,9 @@ def network_path( *, account_id: str, device_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: 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, @@ -139,11 +139,11 @@ def network_path( device_id: Device to filter tracroute result runs to - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms extra_headers: Send extra headers @@ -167,9 +167,9 @@ def network_path( query=maybe_transform( { "device_id": device_id, + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, }, traceroute_test_network_path_params.TracerouteTestNetworkPathParams, ), @@ -183,8 +183,8 @@ def percentiles( test_id: str, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -201,9 +201,9 @@ def percentiles( Args: test_id: API Resource UUID tag. - time_end: End time for aggregate metrics in ISO format + from_: Start time for aggregate metrics in ISO format - time_start: Start time for aggregate metrics in ISO format + to: End time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -232,8 +232,8 @@ def percentiles( timeout=timeout, query=maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, @@ -261,9 +261,9 @@ async def get( test_id: str, *, account_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -280,11 +280,11 @@ async def get( Args: test_id: API Resource UUID tag. - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -313,9 +313,9 @@ async def get( timeout=timeout, query=await async_maybe_transform( { + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, "colo": colo, "device_id": device_id, }, @@ -332,9 +332,9 @@ async def network_path( *, account_id: str, device_id: str, + from_: str, interval: Literal["minute", "hour"], - time_end: str, - time_start: str, + to: 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, @@ -350,11 +350,11 @@ async def network_path( device_id: Device to filter tracroute result runs to - interval: Time interval for aggregate time slots. + from_: Start time for aggregate metrics in ISO ms - time_end: End time for aggregate metrics in ISO ms + interval: Time interval for aggregate time slots. - time_start: Start time for aggregate metrics in ISO ms + to: End time for aggregate metrics in ISO ms extra_headers: Send extra headers @@ -378,9 +378,9 @@ async def network_path( query=await async_maybe_transform( { "device_id": device_id, + "from_": from_, "interval": interval, - "time_end": time_end, - "time_start": time_start, + "to": to, }, traceroute_test_network_path_params.TracerouteTestNetworkPathParams, ), @@ -394,8 +394,8 @@ async def percentiles( test_id: str, *, account_id: str, - time_end: str, - time_start: str, + from_: str, + to: str, colo: str | NotGiven = NOT_GIVEN, device_id: List[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -412,9 +412,9 @@ async def percentiles( Args: test_id: API Resource UUID tag. - time_end: End time for aggregate metrics in ISO format + from_: Start time for aggregate metrics in ISO format - time_start: Start time for aggregate metrics in ISO format + to: End time for aggregate metrics in ISO format colo: Optionally filter result stats to a Cloudflare colo. Cannot be used in combination with deviceId param. @@ -443,8 +443,8 @@ async def percentiles( timeout=timeout, query=await async_maybe_transform( { - "time_end": time_end, - "time_start": time_start, + "from_": from_, + "to": to, "colo": colo, "device_id": device_id, }, diff --git a/src/cloudflare/types/zero_trust/dex/colo_list_params.py b/src/cloudflare/types/zero_trust/dex/colo_list_params.py index f078937ff17..975e137ecac 100644 --- a/src/cloudflare/types/zero_trust/dex/colo_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/colo_list_params.py @@ -12,12 +12,12 @@ class ColoListParams(TypedDict, total=False): account_id: Required[str] - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] - """End time for connection period in RFC3339 (ISO 8601) format.""" - - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for connection period in RFC3339 (ISO 8601) format.""" + to: Required[str] + """End time for connection period in RFC3339 (ISO 8601) format.""" + sort_by: Annotated[Literal["fleet-status-usage", "application-tests-usage"], PropertyInfo(alias="sortBy")] """Type of usage that colos should be sorted by. diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py index 187868d3ef2..f75de002a5a 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status/device_list_params.py @@ -2,7 +2,9 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ....._utils import PropertyInfo __all__ = ["DeviceListParams"] @@ -10,16 +12,24 @@ class DeviceListParams(TypedDict, total=False): account_id: Required[str] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] + """Timestamp in ISO format""" + page: Required[float] """Page number of paginated results""" per_page: Required[float] """Number of items per page""" - time_end: Required[str] - """Timestamp in ISO format""" + source: Required[Literal["last_seen", "hourly", "raw"]] + """Source: + + - `hourly` - device details aggregated hourly, up to 7 days prior + - `last_seen` - device details, up to 24 hours prior + - `raw` - device details, up to 7 days prior + """ - time_start: Required[str] + to: Required[str] """Timestamp in ISO format""" colo: str diff --git a/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py b/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py index ce01bfb979e..42bb856443c 100644 --- a/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py +++ b/src/cloudflare/types/zero_trust/dex/fleet_status_over_time_params.py @@ -2,7 +2,9 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import Required, Annotated, TypedDict + +from ...._utils import PropertyInfo __all__ = ["FleetStatusOverTimeParams"] @@ -10,10 +12,10 @@ class FleetStatusOverTimeParams(TypedDict, total=False): account_id: Required[str] - time_end: Required[str] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Timestamp in ISO format""" - time_start: Required[str] + to: Required[str] """Timestamp in ISO format""" colo: str diff --git a/src/cloudflare/types/zero_trust/dex/http_test_get_params.py b/src/cloudflare/types/zero_trust/dex/http_test_get_params.py index d0ce2cbe5d3..dd57bbf6128 100644 --- a/src/cloudflare/types/zero_trust/dex/http_test_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/http_test_get_params.py @@ -13,15 +13,15 @@ class HTTPTestGetParams(TypedDict, total=False): account_id: Required[str] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] + """Start time for aggregate metrics in ISO ms""" + interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] + to: Required[str] """End time for aggregate metrics in ISO ms""" - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] - """Start time for aggregate metrics in ISO ms""" - colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py b/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py index febc0fd6177..78d1009603e 100644 --- a/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/http_tests/percentile_get_params.py @@ -13,12 +13,12 @@ class PercentileGetParams(TypedDict, total=False): account_id: Required[str] - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] - """End time for aggregate metrics in ISO format""" - - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for aggregate metrics in ISO format""" + to: Required[str] + """End time for aggregate metrics in ISO format""" + colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py index dc8afa0c5d9..54b4a51b5fb 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_get_params.py @@ -13,15 +13,15 @@ class TracerouteTestGetParams(TypedDict, total=False): account_id: Required[str] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] + """Start time for aggregate metrics in ISO ms""" + interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] + to: Required[str] """End time for aggregate metrics in ISO ms""" - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] - """Start time for aggregate metrics in ISO ms""" - colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py index b23b29c2bff..b6ffc3f49e0 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_network_path_params.py @@ -15,11 +15,11 @@ class TracerouteTestNetworkPathParams(TypedDict, total=False): device_id: Required[Annotated[str, PropertyInfo(alias="deviceId")]] """Device to filter tracroute result runs to""" + from_: Required[Annotated[str, PropertyInfo(alias="from")]] + """Start time for aggregate metrics in ISO ms""" + interval: Required[Literal["minute", "hour"]] """Time interval for aggregate time slots.""" - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] + to: Required[str] """End time for aggregate metrics in ISO ms""" - - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] - """Start time for aggregate metrics in ISO ms""" diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py index 5a4199a097d..d6ada52d1d2 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_percentiles_params.py @@ -13,12 +13,12 @@ class TracerouteTestPercentilesParams(TypedDict, total=False): account_id: Required[str] - time_end: Required[Annotated[str, PropertyInfo(alias="timeEnd")]] - """End time for aggregate metrics in ISO format""" - - time_start: Required[Annotated[str, PropertyInfo(alias="timeStart")]] + from_: Required[Annotated[str, PropertyInfo(alias="from")]] """Start time for aggregate metrics in ISO format""" + to: Required[str] + """End time for aggregate metrics in ISO format""" + colo: str """Optionally filter result stats to a Cloudflare colo. diff --git a/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py b/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py index 2dc7a507b92..8b14533ea18 100644 --- a/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py +++ b/src/cloudflare/types/zero_trust/dex/traceroute_test_results/network_path_get_response.py @@ -45,9 +45,6 @@ class NetworkPathGetResponse(BaseModel): result_id: str = FieldInfo(alias="resultId") """API Resource UUID tag.""" - time_start: str - """date time of this traceroute test""" - device_name: Optional[str] = FieldInfo(alias="deviceName", default=None) """name of the device associated with this network path response""" diff --git a/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py b/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py index 3f7e10dbbc6..53def98e79c 100644 --- a/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py +++ b/tests/api_resources/zero_trust/dex/fleet_status/test_devices.py @@ -23,10 +23,11 @@ class TestDevices: def test_method_list(self, client: Cloudflare) -> None: device = client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) assert_matches_type(SyncV4PagePaginationArray[DeviceListResponse], device, path=["response"]) @@ -35,10 +36,11 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: device = client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", mode="proxy", @@ -54,10 +56,11 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.dex.fleet_status.devices.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -70,10 +73,11 @@ def test_raw_response_list(self, client: Cloudflare) -> None: def test_streaming_response_list(self, client: Cloudflare) -> None: with client.zero_trust.dex.fleet_status.devices.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -89,10 +93,11 @@ 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.dex.fleet_status.devices.with_raw_response.list( account_id="", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) @@ -104,10 +109,11 @@ class TestAsyncDevices: async def test_method_list(self, async_client: AsyncCloudflare) -> None: device = await async_client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) assert_matches_type(AsyncV4PagePaginationArray[DeviceListResponse], device, path=["response"]) @@ -116,10 +122,11 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: device = await async_client.zero_trust.dex.fleet_status.devices.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", mode="proxy", @@ -135,10 +142,11 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.fleet_status.devices.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -151,10 +159,11 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.fleet_status.devices.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -170,8 +179,9 @@ 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.dex.fleet_status.devices.with_raw_response.list( account_id="", + from_="2023-10-11T00:00:00Z", page=1, per_page=10, - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + source="last_seen", + to="2023-10-11T00:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py b/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py index 417e9fe4ec4..73561c37fb5 100644 --- a/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py +++ b/tests/api_resources/zero_trust/dex/http_tests/test_percentiles.py @@ -22,8 +22,8 @@ def test_method_get(self, client: Cloudflare) -> None: percentile = client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[HTTPDetailsPercentiles], percentile, path=["response"]) @@ -32,8 +32,8 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: percentile = client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -44,8 +44,8 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -58,8 +58,8 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.http_tests.percentiles.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -75,16 +75,16 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) @@ -96,8 +96,8 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: percentile = await async_client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[HTTPDetailsPercentiles], percentile, path=["response"]) @@ -106,8 +106,8 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - percentile = await async_client.zero_trust.dex.http_tests.percentiles.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -118,8 +118,8 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -132,8 +132,8 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.http_tests.percentiles.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -149,14 +149,14 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.http_tests.percentiles.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_colos.py b/tests/api_resources/zero_trust/dex/test_colos.py index ea3b48d65ae..8e4d0db4399 100644 --- a/tests/api_resources/zero_trust/dex/test_colos.py +++ b/tests/api_resources/zero_trust/dex/test_colos.py @@ -21,8 +21,8 @@ class TestColos: def test_method_list(self, client: Cloudflare) -> None: colo = client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) assert_matches_type(SyncSinglePage[object], colo, path=["response"]) @@ -30,8 +30,8 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: colo = client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", sort_by="fleet-status-usage", ) assert_matches_type(SyncSinglePage[object], colo, path=["response"]) @@ -40,8 +40,8 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.dex.colos.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) assert response.is_closed is True @@ -53,8 +53,8 @@ def test_raw_response_list(self, client: Cloudflare) -> None: def test_streaming_response_list(self, client: Cloudflare) -> None: with client.zero_trust.dex.colos.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -69,8 +69,8 @@ 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.dex.colos.with_raw_response.list( account_id="", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) @@ -81,8 +81,8 @@ class TestAsyncColos: async def test_method_list(self, async_client: AsyncCloudflare) -> None: colo = await async_client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) assert_matches_type(AsyncSinglePage[object], colo, path=["response"]) @@ -90,8 +90,8 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: colo = await async_client.zero_trust.dex.colos.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", sort_by="fleet-status-usage", ) assert_matches_type(AsyncSinglePage[object], colo, path=["response"]) @@ -100,8 +100,8 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.colos.with_raw_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) assert response.is_closed is True @@ -113,8 +113,8 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.colos.with_streaming_response.list( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -129,6 +129,6 @@ 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.dex.colos.with_raw_response.list( account_id="", - time_end="2023-08-24T20:45:00Z", - time_start="2023-08-20T20:45:00Z", + from_="2023-08-20T20:45:00Z", + to="2023-08-24T20:45:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_fleet_status.py b/tests/api_resources/zero_trust/dex/test_fleet_status.py index c8810f5404b..db1676eacde 100644 --- a/tests/api_resources/zero_trust/dex/test_fleet_status.py +++ b/tests/api_resources/zero_trust/dex/test_fleet_status.py @@ -65,8 +65,8 @@ def test_path_params_live(self, client: Cloudflare) -> None: def test_method_over_time(self, client: Cloudflare) -> None: fleet_status = client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) assert fleet_status is None @@ -74,8 +74,8 @@ def test_method_over_time(self, client: Cloudflare) -> None: def test_method_over_time_with_all_params(self, client: Cloudflare) -> None: fleet_status = client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", ) @@ -85,8 +85,8 @@ def test_method_over_time_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_over_time(self, client: Cloudflare) -> None: response = client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -98,8 +98,8 @@ def test_raw_response_over_time(self, client: Cloudflare) -> None: def test_streaming_response_over_time(self, client: Cloudflare) -> None: with client.zero_trust.dex.fleet_status.with_streaming_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -114,8 +114,8 @@ def test_path_params_over_time(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) @@ -168,8 +168,8 @@ async def test_path_params_live(self, async_client: AsyncCloudflare) -> None: async def test_method_over_time(self, async_client: AsyncCloudflare) -> None: fleet_status = await async_client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) assert fleet_status is None @@ -177,8 +177,8 @@ async def test_method_over_time(self, async_client: AsyncCloudflare) -> None: async def test_method_over_time_with_all_params(self, async_client: AsyncCloudflare) -> None: fleet_status = await async_client.zero_trust.dex.fleet_status.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", colo="SJC", device_id="cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7", ) @@ -188,8 +188,8 @@ async def test_method_over_time_with_all_params(self, async_client: AsyncCloudfl async def test_raw_response_over_time(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) assert response.is_closed is True @@ -201,8 +201,8 @@ async def test_raw_response_over_time(self, async_client: AsyncCloudflare) -> No async def test_streaming_response_over_time(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.dex.fleet_status.with_streaming_response.over_time( account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -217,6 +217,6 @@ async def test_path_params_over_time(self, async_client: AsyncCloudflare) -> Non with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.zero_trust.dex.fleet_status.with_raw_response.over_time( account_id="", - time_end="2023-10-11T00:00:00Z", - time_start="2023-10-11T00:00:00Z", + from_="2023-10-11T00:00:00Z", + to="2023-10-11T00:00:00Z", ) diff --git a/tests/api_resources/zero_trust/dex/test_http_tests.py b/tests/api_resources/zero_trust/dex/test_http_tests.py index 48a2fa21dfe..2b038de5a40 100644 --- a/tests/api_resources/zero_trust/dex/test_http_tests.py +++ b/tests/api_resources/zero_trust/dex/test_http_tests.py @@ -22,9 +22,9 @@ def test_method_get(self, client: Cloudflare) -> None: http_test = client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[HTTPDetails], http_test, path=["response"]) @@ -33,9 +33,9 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: http_test = client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", colo="string", device_id=["string", "string", "string"], ) @@ -46,9 +46,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -61,9 +61,9 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.http_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -79,18 +79,18 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.http_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @@ -102,9 +102,9 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: http_test = await async_client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[HTTPDetails], http_test, path=["response"]) @@ -113,9 +113,9 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - http_test = await async_client.zero_trust.dex.http_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", colo="string", device_id=["string", "string", "string"], ) @@ -126,9 +126,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -141,9 +141,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.http_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -159,16 +159,16 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.http_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.http_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) diff --git a/tests/api_resources/zero_trust/dex/test_traceroute_tests.py b/tests/api_resources/zero_trust/dex/test_traceroute_tests.py index 687a44e7675..a5a47a30db8 100644 --- a/tests/api_resources/zero_trust/dex/test_traceroute_tests.py +++ b/tests/api_resources/zero_trust/dex/test_traceroute_tests.py @@ -26,9 +26,9 @@ def test_method_get(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[Traceroute], traceroute_test, path=["response"]) @@ -37,9 +37,9 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", colo="string", device_id=["string", "string", "string"], ) @@ -50,9 +50,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -65,9 +65,9 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.dex.traceroute_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -83,18 +83,18 @@ def test_path_params_get(self, client: Cloudflare) -> None: client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.traceroute_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @parametrize @@ -103,9 +103,9 @@ def test_method_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[NetworkPathResponse], traceroute_test, path=["response"]) @@ -115,9 +115,9 @@ def test_raw_response_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -131,9 +131,9 @@ def test_streaming_response_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -150,9 +150,9 @@ def test_path_params_network_path(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): @@ -160,9 +160,9 @@ def test_path_params_network_path(self, client: Cloudflare) -> None: "", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @parametrize @@ -170,8 +170,8 @@ def test_method_percentiles(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[TracerouteTestPercentilesResponse], traceroute_test, path=["response"]) @@ -180,8 +180,8 @@ def test_method_percentiles_with_all_params(self, client: Cloudflare) -> None: traceroute_test = client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -192,8 +192,8 @@ def test_raw_response_percentiles(self, client: Cloudflare) -> None: response = client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -206,8 +206,8 @@ def test_streaming_response_percentiles(self, client: Cloudflare) -> None: with client.zero_trust.dex.traceroute_tests.with_streaming_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -223,16 +223,16 @@ def test_path_params_percentiles(self, client: Cloudflare) -> None: client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) @@ -244,9 +244,9 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: traceroute_test = await async_client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[Traceroute], traceroute_test, path=["response"]) @@ -255,9 +255,9 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - traceroute_test = await async_client.zero_trust.dex.traceroute_tests.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", colo="string", device_id=["string", "string", "string"], ) @@ -268,9 +268,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -283,9 +283,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async with async_client.zero_trust.dex.traceroute_tests.with_streaming_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -301,18 +301,18 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.traceroute_tests.with_raw_response.get( "", account_id="01a7362d577a6c3019a474fd6f485823", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @parametrize @@ -321,9 +321,9 @@ async def test_method_network_path(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert_matches_type(Optional[NetworkPathResponse], traceroute_test, path=["response"]) @@ -333,9 +333,9 @@ async def test_raw_response_network_path(self, async_client: AsyncCloudflare) -> "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) assert response.is_closed is True @@ -349,9 +349,9 @@ async def test_streaming_response_network_path(self, async_client: AsyncCloudfla "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -368,9 +368,9 @@ async def test_path_params_network_path(self, async_client: AsyncCloudflare) -> "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): @@ -378,9 +378,9 @@ async def test_path_params_network_path(self, async_client: AsyncCloudflare) -> "", account_id="01a7362d577a6c3019a474fd6f485823", device_id="string", + from_="1689520412000", interval="minute", - time_end="1689606812000", - time_start="1689520412000", + to="1689606812000", ) @parametrize @@ -388,8 +388,8 @@ async def test_method_percentiles(self, async_client: AsyncCloudflare) -> None: traceroute_test = await async_client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert_matches_type(Optional[TracerouteTestPercentilesResponse], traceroute_test, path=["response"]) @@ -398,8 +398,8 @@ async def test_method_percentiles_with_all_params(self, async_client: AsyncCloud traceroute_test = await async_client.zero_trust.dex.traceroute_tests.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", colo="string", device_id=["string", "string", "string"], ) @@ -410,8 +410,8 @@ async def test_raw_response_percentiles(self, async_client: AsyncCloudflare) -> response = await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) assert response.is_closed is True @@ -424,8 +424,8 @@ async def test_streaming_response_percentiles(self, async_client: AsyncCloudflar async with async_client.zero_trust.dex.traceroute_tests.with_streaming_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -441,14 +441,14 @@ async def test_path_params_percentiles(self, async_client: AsyncCloudflare) -> N await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `test_id` but received ''"): await async_client.zero_trust.dex.traceroute_tests.with_raw_response.percentiles( "", account_id="01a7362d577a6c3019a474fd6f485823", - time_end="2023-09-20T17:00:00Z", - time_start="2023-09-20T17:00:00Z", + from_="2023-09-20T17:00:00Z", + to="2023-09-20T17:00:00Z", ) From 2e9a76c81512a90954d441c12f8feafd2039d099 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 23:22:13 +0000 Subject: [PATCH 273/532] feat(api): OpenAPI spec update via Stainless API (#754) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 62a18d0f9d3..f1f18364bfe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7080386fb1d04dafc80523803a44e41bab56e2907c13694ced938d02a3abb9d5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml From adfc559082bf2dbde589d71408de48de2eb788a9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 23:43:34 +0000 Subject: [PATCH 274/532] feat(api): OpenAPI spec update via Stainless API (#755) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f1f18364bfe..62a18d0f9d3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7080386fb1d04dafc80523803a44e41bab56e2907c13694ced938d02a3abb9d5.yml From 2824161b0c8049803c8d94568aeb13b0902e6356 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 23:45:38 +0000 Subject: [PATCH 275/532] feat(api): OpenAPI spec update via Stainless API (#756) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 62a18d0f9d3..f1f18364bfe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7080386fb1d04dafc80523803a44e41bab56e2907c13694ced938d02a3abb9d5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml From 04ed5f6617139752d3443b9d367a5134865cc358 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 1 Jun 2024 03:22:16 +0000 Subject: [PATCH 276/532] feat(api): OpenAPI spec update via Stainless API (#757) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index f1f18364bfe..8c596fd14ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58442197b639c81df6c79a12d873505a3be89908ae4a4567c1ac1a63e4c9309.yml diff --git a/api.md b/api.md index 8d42917a9ec..b961effc2c3 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 509db710e5b72e08a77e67876e07892cfd3ed6f5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 09:26:34 +0000 Subject: [PATCH 277/532] feat(api): OpenAPI spec update via Stainless API (#758) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8c596fd14ff..f1f18364bfe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58442197b639c81df6c79a12d873505a3be89908ae4a4567c1ac1a63e4c9309.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml diff --git a/api.md b/api.md index b961effc2c3..8d42917a9ec 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 926996cd10c584ea6f0d8a5a52804159f310a9df Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:45:03 +0000 Subject: [PATCH 278/532] feat(api): OpenAPI spec update via Stainless API (#759) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f1f18364bfe..62a18d0f9d3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7080386fb1d04dafc80523803a44e41bab56e2907c13694ced938d02a3abb9d5.yml From 8600f31343c576979ea0f5ae21ec92dc463bbb0c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 14:16:17 +0000 Subject: [PATCH 279/532] feat(api): OpenAPI spec update via Stainless API (#760) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 62a18d0f9d3..f1f18364bfe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7080386fb1d04dafc80523803a44e41bab56e2907c13694ced938d02a3abb9d5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml From 69ec7516745c71b2443fc365da060f3214e795ed Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:23:58 +0000 Subject: [PATCH 280/532] feat(api): OpenAPI spec update via Stainless API (#761) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index f1f18364bfe..8c596fd14ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58442197b639c81df6c79a12d873505a3be89908ae4a4567c1ac1a63e4c9309.yml diff --git a/api.md b/api.md index 8d42917a9ec..b961effc2c3 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From 9ba0f1bb8345b87b71c1403ee6d24760603fd3fd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:26:07 +0000 Subject: [PATCH 281/532] feat(api): OpenAPI spec update via Stainless API (#762) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8c596fd14ff..f1f18364bfe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58442197b639c81df6c79a12d873505a3be89908ae4a4567c1ac1a63e4c9309.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml diff --git a/api.md b/api.md index b961effc2c3..8d42917a9ec 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From 9d24609073cad5ba379c97cb0eae4c75a814d997 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:34:51 +0000 Subject: [PATCH 282/532] feat(api): OpenAPI spec update via Stainless API (#763) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index f1f18364bfe..8c596fd14ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58442197b639c81df6c79a12d873505a3be89908ae4a4567c1ac1a63e4c9309.yml diff --git a/api.md b/api.md index 8d42917a9ec..b961effc2c3 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From d722b7b5b364041dfceec62e54f70cb7a79b1b20 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:36:58 +0000 Subject: [PATCH 283/532] feat(api): OpenAPI spec update via Stainless API (#764) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8c596fd14ff..cc9f4c6f06d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e58442197b639c81df6c79a12d873505a3be89908ae4a4567c1ac1a63e4c9309.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-37d415099ac13348abf3f668e8a0a6817df7b8a481b26b98599af519074d86f8.yml From 325e2cc40a11554b2011d69a947edcfc55258253 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:39:02 +0000 Subject: [PATCH 284/532] feat(api): OpenAPI spec update via Stainless API (#765) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++++----- .../cloudforce_one/requests/priority.py | 88 ++++++++------ .../cloudforce_one/requests/requests.py | 112 ++++++++++-------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 +-- .../requests/message_delete_response.py | 15 +-- .../requests/priority_delete_response.py | 15 +-- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 293 insertions(+), 272 deletions(-) diff --git a/.stats.yml b/.stats.yml index cc9f4c6f06d..f1f18364bfe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-37d415099ac13348abf3f668e8a0a6817df7b8a481b26b98599af519074d86f8.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml diff --git a/api.md b/api.md index b961effc2c3..8d42917a9ec 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> Optional +- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> Optional -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.quota(account_identifier) -> Optional -- client.cloudforce_one.requests.types(account_identifier) -> Optional +- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item +- client.cloudforce_one.requests.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index 177e2c5b099..eaea1a987b6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) def delete( @@ -195,12 +195,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) def get( @@ -220,7 +229,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -271,9 +280,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) @@ -298,7 +307,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -331,9 +340,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def update( @@ -353,7 +362,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Message]: + ) -> Message: """ Update a Request Message @@ -401,9 +410,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Message]]._unwrapper, + post_parser=ResultWrapper[Message]._unwrapper, ), - cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), + cast_to=cast(Type[Message], ResultWrapper[Message]), ) async def delete( @@ -439,12 +448,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + MessageDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[MessageDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=MessageDeleteResponse, ) async def get( @@ -464,7 +482,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[MessageGetResponse]: + ) -> MessageGetResponse: """ List Request Messages @@ -515,9 +533,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, + post_parser=ResultWrapper[MessageGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 243e43f789b..0f1d6795a40 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Any, List, Type, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def delete( @@ -200,12 +200,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) def get( @@ -219,7 +228,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -247,9 +256,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -262,7 +271,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -286,9 +295,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) @@ -315,7 +324,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Priority]: + ) -> Priority: """ Create a New Priority Requirement @@ -356,9 +365,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Priority]]._unwrapper, + post_parser=ResultWrapper[Priority]._unwrapper, ), - cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), + cast_to=cast(Type[Priority], ResultWrapper[Priority]), ) async def update( @@ -376,7 +385,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Update a Priority Intelligence Requirement @@ -421,9 +430,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def delete( @@ -458,12 +467,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + PriorityDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[PriorityDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=PriorityDeleteResponse, ) async def get( @@ -477,7 +495,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Priority Intelligence Requirement @@ -505,9 +523,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -520,7 +538,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Priority Intelligence Requirement Quota @@ -544,9 +562,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 267e04595d6..61a739aaa7c 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Union, Optional, cast +from typing import Any, Type, Union, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -323,12 +323,21 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) def constants( @@ -341,7 +350,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -365,9 +374,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) def get( @@ -381,7 +390,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -409,9 +418,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def quota( @@ -424,7 +433,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -448,9 +457,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) def types( @@ -463,7 +472,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -487,9 +496,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) @@ -525,7 +534,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -571,9 +580,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def update( @@ -592,7 +601,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -643,9 +652,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) def list( @@ -762,12 +771,21 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + return cast( + RequestDeleteResponse, + await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RequestDeleteResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=RequestDeleteResponse, ) async def constants( @@ -780,7 +798,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestConstants]: + ) -> RequestConstants: """ Get Request Priority, Status, and TLP constants @@ -804,9 +822,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, + post_parser=ResultWrapper[RequestConstants]._unwrapper, ), - cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), + cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), ) async def get( @@ -820,7 +838,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Item]: + ) -> Item: """ Get a Request @@ -848,9 +866,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Item]]._unwrapper, + post_parser=ResultWrapper[Item]._unwrapper, ), - cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), + cast_to=cast(Type[Item], ResultWrapper[Item]), ) async def quota( @@ -863,7 +881,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[Quota]: + ) -> Quota: """ Get Request Quota @@ -887,9 +905,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[Quota]]._unwrapper, + post_parser=ResultWrapper[Quota]._unwrapper, ), - cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), + cast_to=cast(Type[Quota], ResultWrapper[Quota]), ) async def types( @@ -902,7 +920,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[RequestTypes]: + ) -> RequestTypes: """ Get Request Types @@ -926,9 +944,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, + post_parser=ResultWrapper[RequestTypes]._unwrapper, ), - cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), + cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index d8f2efe389c..050da13d396 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WhoisGetResponse]: + ) -> WhoisGetResponse: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, + post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, ), - cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index b7ed5ffbe10..f6dca1edb3f 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["RequestDeleteResponse"] - -class RequestDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +RequestDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index a0d45a64036..eaadbea2ab5 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["MessageDeleteResponse"] - -class MessageDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +MessageDeleteResponse = Union[List[object], str, object] diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index ee172239bfe..60bd9aae8bd 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,18 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List -from typing_extensions import Literal - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo +from typing import List, Union __all__ = ["PriorityDeleteResponse"] - -class PriorityDeleteResponse(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - success: Literal[True] - """Whether the API call was successful""" +PriorityDeleteResponse = Union[List[object], str, object] diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index e804d3ab846..cae9250892e 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[Message], message, path=["response"]) + assert_matches_type(Message, message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) + assert_matches_type(MessageGetResponse, message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 012e01b34cf..46276ab9dcf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Priority], priority, path=["response"]) + assert_matches_type(Priority, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Item], priority, path=["response"]) + assert_matches_type(Item, priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Optional[Quota], priority, path=["response"]) + assert_matches_type(Quota, priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 9e43e1a22b2..327ae61c1bb 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestConstants], request, path=["response"]) + assert_matches_type(RequestConstants, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Item], request, path=["response"]) + assert_matches_type(Item, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[Quota], request, path=["response"]) + assert_matches_type(Quota, request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Optional[RequestTypes], request, path=["response"]) + assert_matches_type(RequestTypes, request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index c8f0f4035df..215bb9b2e3f 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) + assert_matches_type(WhoisGetResponse, whois, path=["response"]) assert cast(Any, response.is_closed) is True From edb1fc53ce83225353d5ba27c8253b18b0b56aa8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:41:15 +0000 Subject: [PATCH 285/532] feat(api): OpenAPI spec update via Stainless API (#766) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f1f18364bfe..0388cd2ff81 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b8c414b18922a386e73932ac947fcbc82fe780da9cdcd5212e3224ebbf6c4b4e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-16683743b1ebefab596c0a119ad133113f5ce61fbf58de4f5f734244ca6e4a42.yml From 3238c36d41f544ebc562c560b5c17a5efb0a8b47 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:32:27 +0000 Subject: [PATCH 286/532] feat(api): OpenAPI spec update via Stainless API (#767) --- .stats.yml | 2 +- api.md | 28 ++--- .../cloudforce_one/requests/message.py | 76 +++++------- .../cloudforce_one/requests/priority.py | 88 ++++++-------- .../cloudforce_one/requests/requests.py | 112 ++++++++---------- src/cloudflare/resources/intel/whois.py | 14 +-- .../cloudforce_one/request_delete_response.py | 15 ++- .../requests/message_delete_response.py | 15 ++- .../requests/priority_delete_response.py | 15 ++- .../cloudforce_one/requests/test_message.py | 50 ++++---- .../cloudforce_one/requests/test_priority.py | 50 ++++---- .../cloudforce_one/test_requests.py | 82 ++++++------- tests/api_resources/intel/test_whois.py | 18 +-- 13 files changed, 272 insertions(+), 293 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0388cd2ff81..f158bfce94e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-16683743b1ebefab596c0a119ad133113f5ce61fbf58de4f5f734244ca6e4a42.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ea05ad3e371ed604d6458ca4465044806be7e860ab44c6c7ddc24dc4a778bad7.yml diff --git a/api.md b/api.md index 8d42917a9ec..b961effc2c3 100644 --- a/api.md +++ b/api.md @@ -3795,7 +3795,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7643,14 +7643,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7666,10 +7666,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7686,11 +7686,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications diff --git a/src/cloudflare/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ 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" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ 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" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ 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" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ 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" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ 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" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ 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" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ 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" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ 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" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True From fbc645eb9fce79a16c0c0b3774f235698bf5bac2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:36:02 +0000 Subject: [PATCH 287/532] feat(api): OpenAPI spec update via Stainless API (#768) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f158bfce94e..eeba1c5bbd4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ea05ad3e371ed604d6458ca4465044806be7e860ab44c6c7ddc24dc4a778bad7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-308736efdeaf86206b8eaa2fbb4612d7f8762e86e58e795c3c6168f2976d27dd.yml From 563d2ccc1d5d45d7bca7b8944d258461ac742a35 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:38:12 +0000 Subject: [PATCH 288/532] feat(api): OpenAPI spec update via Stainless API (#769) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index eeba1c5bbd4..f158bfce94e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-308736efdeaf86206b8eaa2fbb4612d7f8762e86e58e795c3c6168f2976d27dd.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ea05ad3e371ed604d6458ca4465044806be7e860ab44c6c7ddc24dc4a778bad7.yml From 16f2024592b07624378ae6f584b7be64edb38762 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 17:01:52 +0000 Subject: [PATCH 289/532] feat(api): OpenAPI spec update via Stainless API (#770) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f158bfce94e..542148c66a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ea05ad3e371ed604d6458ca4465044806be7e860ab44c6c7ddc24dc4a778bad7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-37f8ef45564cc53a10e9cf5077b50db2e28318175f0920357a687f0f38c9f56b.yml From 1aca60697f409eabe0813e6ff09a888dbecdc832 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:15:59 +0000 Subject: [PATCH 290/532] feat(api): OpenAPI spec update via Stainless API (#771) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 542148c66a8..c690d87695a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-37f8ef45564cc53a10e9cf5077b50db2e28318175f0920357a687f0f38c9f56b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ac33a501d722d88a0ebf590d74e32c77066a57b327cb3a2fae156558b6e7b75c.yml From 3cfe2ab9c306db44b0d14461adef8b855310b598 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:06:10 +0000 Subject: [PATCH 291/532] feat(api): OpenAPI spec update via Stainless API (#772) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c690d87695a..adcfcc1753b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ac33a501d722d88a0ebf590d74e32c77066a57b327cb3a2fae156558b6e7b75c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-43fc0da59774d780049ce01bf912d858e1cae3e870568caba48a27759aac198c.yml From 129cd128f6c2bc7404bc413feb0f99917be5f140 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 20:42:36 +0000 Subject: [PATCH 292/532] feat(api): OpenAPI spec update via Stainless API (#773) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index adcfcc1753b..c690d87695a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-43fc0da59774d780049ce01bf912d858e1cae3e870568caba48a27759aac198c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ac33a501d722d88a0ebf590d74e32c77066a57b327cb3a2fae156558b6e7b75c.yml From be4677a1dd37a8422eb8b7277e8b41451267c924 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:01:57 +0000 Subject: [PATCH 293/532] feat(api): OpenAPI spec update via Stainless API (#774) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c690d87695a..0dc472c0233 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ac33a501d722d88a0ebf590d74e32c77066a57b327cb3a2fae156558b6e7b75c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml From c8f72ed706ea5af7bade55a7277ce7f7867ec43a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:34:34 +0000 Subject: [PATCH 294/532] feat(api): update via SDK Studio (#775) --- .stats.yml | 4 +- api.md | 76 + .../resources/addressing/__init__.py | 14 + .../resources/addressing/addressing.py | 33 + .../addressing/regional_hostnames/__init__.py | 33 + .../regional_hostnames/regional_hostnames.py | 633 ++++++++ .../addressing/regional_hostnames/regions.py | 151 ++ .../resources/magic_transit/__init__.py | 14 + .../resources/magic_transit/apps.py | 777 ++++++++++ .../resources/magic_transit/magic_transit.py | 32 + .../resources/magic_transit/sites/sites.py | 33 + .../magic_transit/sites/sites/__init__.py | 33 + .../sites/sites/app_configuration.py | 1049 ++++++++++++++ .../magic_transit/sites/sites/sites.py | 80 ++ src/cloudflare/types/addressing/__init__.py | 7 + .../regional_hostname_create_params.py | 21 + .../regional_hostname_create_response.py | 21 + .../regional_hostname_delete_response.py | 18 + .../regional_hostname_edit_params.py | 15 + .../regional_hostname_edit_response.py | 21 + .../regional_hostname_get_response.py | 21 + .../regional_hostname_list_response.py | 21 + .../addressing/regional_hostnames/__init__.py | 5 + .../region_list_response.py | 15 + .../types/magic_transit/__init__.py | 6 + .../types/magic_transit/app_create_params.py | 25 + .../magic_transit/app_create_response.py | 24 + .../magic_transit/app_delete_response.py | 24 + .../types/magic_transit/app_list_response.py | 44 + .../types/magic_transit/app_update_params.py | 39 + .../magic_transit/app_update_response.py | 24 + .../magic_transit/sites/sites/__init__.py | 10 + .../sites/app_configuration_create_params.py | 27 + .../app_configuration_create_response.py | 28 + .../app_configuration_delete_response.py | 28 + .../sites/app_configuration_list_response.py | 28 + .../sites/app_configuration_update_params.py | 96 ++ .../app_configuration_update_response.py | 28 + .../addressing/regional_hostnames/__init__.py | 1 + .../regional_hostnames/test_regions.py | 99 ++ .../addressing/test_regional_hostnames.py | 495 +++++++ .../magic_transit/sites/sites/__init__.py | 1 + .../sites/sites/test_app_configuration.py | 1272 +++++++++++++++++ .../api_resources/magic_transit/test_apps.py | 792 ++++++++++ 44 files changed, 6216 insertions(+), 2 deletions(-) create mode 100644 src/cloudflare/resources/addressing/regional_hostnames/__init__.py create mode 100644 src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py create mode 100644 src/cloudflare/resources/addressing/regional_hostnames/regions.py create mode 100644 src/cloudflare/resources/magic_transit/apps.py create mode 100644 src/cloudflare/resources/magic_transit/sites/sites/__init__.py create mode 100644 src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py create mode 100644 src/cloudflare/resources/magic_transit/sites/sites/sites.py create mode 100644 src/cloudflare/types/addressing/regional_hostname_create_params.py create mode 100644 src/cloudflare/types/addressing/regional_hostname_create_response.py create mode 100644 src/cloudflare/types/addressing/regional_hostname_delete_response.py create mode 100644 src/cloudflare/types/addressing/regional_hostname_edit_params.py create mode 100644 src/cloudflare/types/addressing/regional_hostname_edit_response.py create mode 100644 src/cloudflare/types/addressing/regional_hostname_get_response.py create mode 100644 src/cloudflare/types/addressing/regional_hostname_list_response.py create mode 100644 src/cloudflare/types/addressing/regional_hostnames/__init__.py create mode 100644 src/cloudflare/types/addressing/regional_hostnames/region_list_response.py create mode 100644 src/cloudflare/types/magic_transit/app_create_params.py create mode 100644 src/cloudflare/types/magic_transit/app_create_response.py create mode 100644 src/cloudflare/types/magic_transit/app_delete_response.py create mode 100644 src/cloudflare/types/magic_transit/app_list_response.py create mode 100644 src/cloudflare/types/magic_transit/app_update_params.py create mode 100644 src/cloudflare/types/magic_transit/app_update_response.py create mode 100644 src/cloudflare/types/magic_transit/sites/sites/__init__.py create mode 100644 src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py create mode 100644 src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py create mode 100644 src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py create mode 100644 src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py create mode 100644 src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py create mode 100644 src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py create mode 100644 tests/api_resources/addressing/regional_hostnames/__init__.py create mode 100644 tests/api_resources/addressing/regional_hostnames/test_regions.py create mode 100644 tests/api_resources/addressing/test_regional_hostnames.py create mode 100644 tests/api_resources/magic_transit/sites/sites/__init__.py create mode 100644 tests/api_resources/magic_transit/sites/sites/test_app_configuration.py create mode 100644 tests/api_resources/magic_transit/test_apps.py diff --git a/.stats.yml b/.stats.yml index 0dc472c0233..b1ee01299ac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1321 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml +configured_endpoints: 1335 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ac33a501d722d88a0ebf590d74e32c77066a57b327cb3a2fae156558b6e7b75c.yml diff --git a/api.md b/api.md index b961effc2c3..59465cfbc9f 100644 --- a/api.md +++ b/api.md @@ -3361,6 +3361,40 @@ Methods: # Addressing +## RegionalHostnames + +Types: + +```python +from cloudflare.types.addressing import ( + RegionalHostnameCreateResponse, + RegionalHostnameListResponse, + RegionalHostnameDeleteResponse, + RegionalHostnameEditResponse, + RegionalHostnameGetResponse, +) +``` + +Methods: + +- client.addressing.regional_hostnames.create(\*, zone_id, \*\*params) -> Optional +- client.addressing.regional_hostnames.list(\*, zone_id) -> SyncSinglePage[RegionalHostnameListResponse] +- client.addressing.regional_hostnames.delete(hostname, \*, zone_id) -> RegionalHostnameDeleteResponse +- client.addressing.regional_hostnames.edit(hostname, \*, zone_id, \*\*params) -> Optional +- client.addressing.regional_hostnames.get(hostname, \*, zone_id) -> Optional + +### Regions + +Types: + +```python +from cloudflare.types.addressing.regional_hostnames import RegionListResponse +``` + +Methods: + +- client.addressing.regional_hostnames.regions.list(\*, account_id) -> SyncSinglePage[RegionListResponse] + ## Services Types: @@ -3907,6 +3941,26 @@ Types: from cloudflare.types.magic_transit import HealthCheck, HealthCheckRate, HealthCheckType ``` +## Apps + +Types: + +```python +from cloudflare.types.magic_transit import ( + AppCreateResponse, + AppUpdateResponse, + AppListResponse, + AppDeleteResponse, +) +``` + +Methods: + +- client.magic_transit.apps.create(\*, account_id, \*\*params) -> Optional +- client.magic_transit.apps.update(account_app_id, \*, account_id, \*\*params) -> Optional +- client.magic_transit.apps.list(\*, account_id) -> SyncSinglePage[AppListResponse] +- client.magic_transit.apps.delete(account_app_id, \*, account_id) -> Optional + ## CfInterconnects Types: @@ -4073,6 +4127,28 @@ Methods: - client.magic_transit.sites.wans.edit(wan_id, \*, account_id, site_id, \*\*params) -> WAN - client.magic_transit.sites.wans.get(wan_id, \*, account_id, site_id) -> WAN +### Sites + +#### AppConfiguration + +Types: + +```python +from cloudflare.types.magic_transit.sites.sites import ( + AppConfigurationCreateResponse, + AppConfigurationUpdateResponse, + AppConfigurationListResponse, + AppConfigurationDeleteResponse, +) +``` + +Methods: + +- client.magic_transit.sites.sites.app_configuration.create(site_id, \*, account_id, \*\*params) -> Optional +- client.magic_transit.sites.sites.app_configuration.update(app_config_id, \*, account_id, site_id, \*\*params) -> Optional +- client.magic_transit.sites.sites.app_configuration.list(site_id, \*, account_id) -> SyncSinglePage[AppConfigurationListResponse] +- client.magic_transit.sites.sites.app_configuration.delete(app_config_id, \*, account_id, site_id) -> Optional + ## Connectors Types: diff --git a/src/cloudflare/resources/addressing/__init__.py b/src/cloudflare/resources/addressing/__init__.py index 662ac0127d3..7abbb395744 100644 --- a/src/cloudflare/resources/addressing/__init__.py +++ b/src/cloudflare/resources/addressing/__init__.py @@ -40,8 +40,22 @@ LOADocumentsResourceWithStreamingResponse, AsyncLOADocumentsResourceWithStreamingResponse, ) +from .regional_hostnames import ( + RegionalHostnamesResource, + AsyncRegionalHostnamesResource, + RegionalHostnamesResourceWithRawResponse, + AsyncRegionalHostnamesResourceWithRawResponse, + RegionalHostnamesResourceWithStreamingResponse, + AsyncRegionalHostnamesResourceWithStreamingResponse, +) __all__ = [ + "RegionalHostnamesResource", + "AsyncRegionalHostnamesResource", + "RegionalHostnamesResourceWithRawResponse", + "AsyncRegionalHostnamesResourceWithRawResponse", + "RegionalHostnamesResourceWithStreamingResponse", + "AsyncRegionalHostnamesResourceWithStreamingResponse", "ServicesResource", "AsyncServicesResource", "ServicesResourceWithRawResponse", diff --git a/src/cloudflare/resources/addressing/addressing.py b/src/cloudflare/resources/addressing/addressing.py index c0e0cd3b374..8157035d32f 100644 --- a/src/cloudflare/resources/addressing/addressing.py +++ b/src/cloudflare/resources/addressing/addressing.py @@ -37,13 +37,26 @@ AsyncLOADocumentsResourceWithStreamingResponse, ) from .prefixes.prefixes import PrefixesResource, AsyncPrefixesResource +from .regional_hostnames import ( + RegionalHostnamesResource, + AsyncRegionalHostnamesResource, + RegionalHostnamesResourceWithRawResponse, + AsyncRegionalHostnamesResourceWithRawResponse, + RegionalHostnamesResourceWithStreamingResponse, + AsyncRegionalHostnamesResourceWithStreamingResponse, +) from .address_maps.address_maps import AddressMapsResource, AsyncAddressMapsResource from .loa_documents.loa_documents import LOADocumentsResource, AsyncLOADocumentsResource +from .regional_hostnames.regional_hostnames import RegionalHostnamesResource, AsyncRegionalHostnamesResource __all__ = ["AddressingResource", "AsyncAddressingResource"] class AddressingResource(SyncAPIResource): + @cached_property + def regional_hostnames(self) -> RegionalHostnamesResource: + return RegionalHostnamesResource(self._client) + @cached_property def services(self) -> ServicesResource: return ServicesResource(self._client) @@ -70,6 +83,10 @@ def with_streaming_response(self) -> AddressingResourceWithStreamingResponse: class AsyncAddressingResource(AsyncAPIResource): + @cached_property + def regional_hostnames(self) -> AsyncRegionalHostnamesResource: + return AsyncRegionalHostnamesResource(self._client) + @cached_property def services(self) -> AsyncServicesResource: return AsyncServicesResource(self._client) @@ -99,6 +116,10 @@ class AddressingResourceWithRawResponse: def __init__(self, addressing: AddressingResource) -> None: self._addressing = addressing + @cached_property + def regional_hostnames(self) -> RegionalHostnamesResourceWithRawResponse: + return RegionalHostnamesResourceWithRawResponse(self._addressing.regional_hostnames) + @cached_property def services(self) -> ServicesResourceWithRawResponse: return ServicesResourceWithRawResponse(self._addressing.services) @@ -120,6 +141,10 @@ class AsyncAddressingResourceWithRawResponse: def __init__(self, addressing: AsyncAddressingResource) -> None: self._addressing = addressing + @cached_property + def regional_hostnames(self) -> AsyncRegionalHostnamesResourceWithRawResponse: + return AsyncRegionalHostnamesResourceWithRawResponse(self._addressing.regional_hostnames) + @cached_property def services(self) -> AsyncServicesResourceWithRawResponse: return AsyncServicesResourceWithRawResponse(self._addressing.services) @@ -141,6 +166,10 @@ class AddressingResourceWithStreamingResponse: def __init__(self, addressing: AddressingResource) -> None: self._addressing = addressing + @cached_property + def regional_hostnames(self) -> RegionalHostnamesResourceWithStreamingResponse: + return RegionalHostnamesResourceWithStreamingResponse(self._addressing.regional_hostnames) + @cached_property def services(self) -> ServicesResourceWithStreamingResponse: return ServicesResourceWithStreamingResponse(self._addressing.services) @@ -162,6 +191,10 @@ class AsyncAddressingResourceWithStreamingResponse: def __init__(self, addressing: AsyncAddressingResource) -> None: self._addressing = addressing + @cached_property + def regional_hostnames(self) -> AsyncRegionalHostnamesResourceWithStreamingResponse: + return AsyncRegionalHostnamesResourceWithStreamingResponse(self._addressing.regional_hostnames) + @cached_property def services(self) -> AsyncServicesResourceWithStreamingResponse: return AsyncServicesResourceWithStreamingResponse(self._addressing.services) diff --git a/src/cloudflare/resources/addressing/regional_hostnames/__init__.py b/src/cloudflare/resources/addressing/regional_hostnames/__init__.py new file mode 100644 index 00000000000..b81e8f7c300 --- /dev/null +++ b/src/cloudflare/resources/addressing/regional_hostnames/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .regions import ( + RegionsResource, + AsyncRegionsResource, + RegionsResourceWithRawResponse, + AsyncRegionsResourceWithRawResponse, + RegionsResourceWithStreamingResponse, + AsyncRegionsResourceWithStreamingResponse, +) +from .regional_hostnames import ( + RegionalHostnamesResource, + AsyncRegionalHostnamesResource, + RegionalHostnamesResourceWithRawResponse, + AsyncRegionalHostnamesResourceWithRawResponse, + RegionalHostnamesResourceWithStreamingResponse, + AsyncRegionalHostnamesResourceWithStreamingResponse, +) + +__all__ = [ + "RegionsResource", + "AsyncRegionsResource", + "RegionsResourceWithRawResponse", + "AsyncRegionsResourceWithRawResponse", + "RegionsResourceWithStreamingResponse", + "AsyncRegionsResourceWithStreamingResponse", + "RegionalHostnamesResource", + "AsyncRegionalHostnamesResource", + "RegionalHostnamesResourceWithRawResponse", + "AsyncRegionalHostnamesResourceWithRawResponse", + "RegionalHostnamesResourceWithStreamingResponse", + "AsyncRegionalHostnamesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py b/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py new file mode 100644 index 00000000000..1524d3e06bc --- /dev/null +++ b/src/cloudflare/resources/addressing/regional_hostnames/regional_hostnames.py @@ -0,0 +1,633 @@ +# 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 .regions import ( + RegionsResource, + AsyncRegionsResource, + RegionsResourceWithRawResponse, + AsyncRegionsResourceWithRawResponse, + RegionsResourceWithStreamingResponse, + AsyncRegionsResourceWithStreamingResponse, +) +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 ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.addressing import regional_hostname_edit_params, regional_hostname_create_params +from ....types.addressing.regional_hostname_get_response import RegionalHostnameGetResponse +from ....types.addressing.regional_hostname_edit_response import RegionalHostnameEditResponse +from ....types.addressing.regional_hostname_list_response import RegionalHostnameListResponse +from ....types.addressing.regional_hostname_create_response import RegionalHostnameCreateResponse +from ....types.addressing.regional_hostname_delete_response import RegionalHostnameDeleteResponse + +__all__ = ["RegionalHostnamesResource", "AsyncRegionalHostnamesResource"] + + +class RegionalHostnamesResource(SyncAPIResource): + @cached_property + def regions(self) -> RegionsResource: + return RegionsResource(self._client) + + @cached_property + def with_raw_response(self) -> RegionalHostnamesResourceWithRawResponse: + return RegionalHostnamesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RegionalHostnamesResourceWithStreamingResponse: + return RegionalHostnamesResourceWithStreamingResponse(self) + + def create( + self, + *, + zone_id: str, + hostname: str, + region_key: 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[RegionalHostnameCreateResponse]: + """Create a new Regional Hostname entry. + + Cloudflare will only use data centers that + are physically located within the chosen region to decrypt and service HTTPS + traffic. Learn more about + [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + region_key: Identifying key for the region + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._post( + f"/zones/{zone_id}/addressing/regional_hostnames", + body=maybe_transform( + { + "hostname": hostname, + "region_key": region_key, + }, + regional_hostname_create_params.RegionalHostnameCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameCreateResponse]], ResultWrapper[RegionalHostnameCreateResponse]), + ) + + def list( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[RegionalHostnameListResponse]: + """ + List all Regional Hostnames within a zone. + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/addressing/regional_hostnames", + page=SyncSinglePage[RegionalHostnameListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RegionalHostnameListResponse, + ) + + def delete( + self, + hostname: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RegionalHostnameDeleteResponse: + """ + Delete the region configuration for a specific Regional Hostname. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return self._delete( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RegionalHostnameDeleteResponse, + ) + + def edit( + self, + hostname: str, + *, + zone_id: str, + region_key: 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[RegionalHostnameEditResponse]: + """Update the configuration for a specific Regional Hostname. + + Only the region_key + of a hostname is mutable. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + region_key: Identifying key for the region + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return self._patch( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + body=maybe_transform({"region_key": region_key}, regional_hostname_edit_params.RegionalHostnameEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameEditResponse]], ResultWrapper[RegionalHostnameEditResponse]), + ) + + def get( + self, + hostname: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[RegionalHostnameGetResponse]: + """ + Fetch the configuration for a specific Regional Hostname, within a zone. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return self._get( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameGetResponse]], ResultWrapper[RegionalHostnameGetResponse]), + ) + + +class AsyncRegionalHostnamesResource(AsyncAPIResource): + @cached_property + def regions(self) -> AsyncRegionsResource: + return AsyncRegionsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncRegionalHostnamesResourceWithRawResponse: + return AsyncRegionalHostnamesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRegionalHostnamesResourceWithStreamingResponse: + return AsyncRegionalHostnamesResourceWithStreamingResponse(self) + + async def create( + self, + *, + zone_id: str, + hostname: str, + region_key: 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[RegionalHostnameCreateResponse]: + """Create a new Regional Hostname entry. + + Cloudflare will only use data centers that + are physically located within the chosen region to decrypt and service HTTPS + traffic. Learn more about + [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + region_key: Identifying key for the region + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._post( + f"/zones/{zone_id}/addressing/regional_hostnames", + body=await async_maybe_transform( + { + "hostname": hostname, + "region_key": region_key, + }, + regional_hostname_create_params.RegionalHostnameCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameCreateResponse]], ResultWrapper[RegionalHostnameCreateResponse]), + ) + + def list( + self, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[RegionalHostnameListResponse, AsyncSinglePage[RegionalHostnameListResponse]]: + """ + List all Regional Hostnames within a zone. + + Args: + zone_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/addressing/regional_hostnames", + page=AsyncSinglePage[RegionalHostnameListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RegionalHostnameListResponse, + ) + + async def delete( + self, + hostname: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RegionalHostnameDeleteResponse: + """ + Delete the region configuration for a specific Regional Hostname. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return await self._delete( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RegionalHostnameDeleteResponse, + ) + + async def edit( + self, + hostname: str, + *, + zone_id: str, + region_key: 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[RegionalHostnameEditResponse]: + """Update the configuration for a specific Regional Hostname. + + Only the region_key + of a hostname is mutable. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + region_key: Identifying key for the region + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return await self._patch( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + body=await async_maybe_transform( + {"region_key": region_key}, regional_hostname_edit_params.RegionalHostnameEditParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameEditResponse]], ResultWrapper[RegionalHostnameEditResponse]), + ) + + async def get( + self, + hostname: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[RegionalHostnameGetResponse]: + """ + Fetch the configuration for a specific Regional Hostname, within a zone. + + Args: + zone_id: Identifier + + hostname: DNS hostname to be regionalized, must be a subdomain of the zone. Wildcards are + supported for one level, e.g `*.example.com` + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not hostname: + raise ValueError(f"Expected a non-empty value for `hostname` but received {hostname!r}") + return await self._get( + f"/zones/{zone_id}/addressing/regional_hostnames/{hostname}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[RegionalHostnameGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[RegionalHostnameGetResponse]], ResultWrapper[RegionalHostnameGetResponse]), + ) + + +class RegionalHostnamesResourceWithRawResponse: + def __init__(self, regional_hostnames: RegionalHostnamesResource) -> None: + self._regional_hostnames = regional_hostnames + + self.create = to_raw_response_wrapper( + regional_hostnames.create, + ) + self.list = to_raw_response_wrapper( + regional_hostnames.list, + ) + self.delete = to_raw_response_wrapper( + regional_hostnames.delete, + ) + self.edit = to_raw_response_wrapper( + regional_hostnames.edit, + ) + self.get = to_raw_response_wrapper( + regional_hostnames.get, + ) + + @cached_property + def regions(self) -> RegionsResourceWithRawResponse: + return RegionsResourceWithRawResponse(self._regional_hostnames.regions) + + +class AsyncRegionalHostnamesResourceWithRawResponse: + def __init__(self, regional_hostnames: AsyncRegionalHostnamesResource) -> None: + self._regional_hostnames = regional_hostnames + + self.create = async_to_raw_response_wrapper( + regional_hostnames.create, + ) + self.list = async_to_raw_response_wrapper( + regional_hostnames.list, + ) + self.delete = async_to_raw_response_wrapper( + regional_hostnames.delete, + ) + self.edit = async_to_raw_response_wrapper( + regional_hostnames.edit, + ) + self.get = async_to_raw_response_wrapper( + regional_hostnames.get, + ) + + @cached_property + def regions(self) -> AsyncRegionsResourceWithRawResponse: + return AsyncRegionsResourceWithRawResponse(self._regional_hostnames.regions) + + +class RegionalHostnamesResourceWithStreamingResponse: + def __init__(self, regional_hostnames: RegionalHostnamesResource) -> None: + self._regional_hostnames = regional_hostnames + + self.create = to_streamed_response_wrapper( + regional_hostnames.create, + ) + self.list = to_streamed_response_wrapper( + regional_hostnames.list, + ) + self.delete = to_streamed_response_wrapper( + regional_hostnames.delete, + ) + self.edit = to_streamed_response_wrapper( + regional_hostnames.edit, + ) + self.get = to_streamed_response_wrapper( + regional_hostnames.get, + ) + + @cached_property + def regions(self) -> RegionsResourceWithStreamingResponse: + return RegionsResourceWithStreamingResponse(self._regional_hostnames.regions) + + +class AsyncRegionalHostnamesResourceWithStreamingResponse: + def __init__(self, regional_hostnames: AsyncRegionalHostnamesResource) -> None: + self._regional_hostnames = regional_hostnames + + self.create = async_to_streamed_response_wrapper( + regional_hostnames.create, + ) + self.list = async_to_streamed_response_wrapper( + regional_hostnames.list, + ) + self.delete = async_to_streamed_response_wrapper( + regional_hostnames.delete, + ) + self.edit = async_to_streamed_response_wrapper( + regional_hostnames.edit, + ) + self.get = async_to_streamed_response_wrapper( + regional_hostnames.get, + ) + + @cached_property + def regions(self) -> AsyncRegionsResourceWithStreamingResponse: + return AsyncRegionsResourceWithStreamingResponse(self._regional_hostnames.regions) diff --git a/src/cloudflare/resources/addressing/regional_hostnames/regions.py b/src/cloudflare/resources/addressing/regional_hostnames/regions.py new file mode 100644 index 00000000000..7340ffab77f --- /dev/null +++ b/src/cloudflare/resources/addressing/regional_hostnames/regions.py @@ -0,0 +1,151 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +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 ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.addressing.regional_hostnames.region_list_response import RegionListResponse + +__all__ = ["RegionsResource", "AsyncRegionsResource"] + + +class RegionsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RegionsResourceWithRawResponse: + return RegionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RegionsResourceWithStreamingResponse: + return RegionsResourceWithStreamingResponse(self) + + 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[RegionListResponse]: + """ + List all Regional Services regions available for use by this account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/addressing/regional_hostnames/regions", + page=SyncSinglePage[RegionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RegionListResponse, + ) + + +class AsyncRegionsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRegionsResourceWithRawResponse: + return AsyncRegionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRegionsResourceWithStreamingResponse: + return AsyncRegionsResourceWithStreamingResponse(self) + + 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[RegionListResponse, AsyncSinglePage[RegionListResponse]]: + """ + List all Regional Services regions available for use by this account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/addressing/regional_hostnames/regions", + page=AsyncSinglePage[RegionListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=RegionListResponse, + ) + + +class RegionsResourceWithRawResponse: + def __init__(self, regions: RegionsResource) -> None: + self._regions = regions + + self.list = to_raw_response_wrapper( + regions.list, + ) + + +class AsyncRegionsResourceWithRawResponse: + def __init__(self, regions: AsyncRegionsResource) -> None: + self._regions = regions + + self.list = async_to_raw_response_wrapper( + regions.list, + ) + + +class RegionsResourceWithStreamingResponse: + def __init__(self, regions: RegionsResource) -> None: + self._regions = regions + + self.list = to_streamed_response_wrapper( + regions.list, + ) + + +class AsyncRegionsResourceWithStreamingResponse: + def __init__(self, regions: AsyncRegionsResource) -> None: + self._regions = regions + + self.list = async_to_streamed_response_wrapper( + regions.list, + ) diff --git a/src/cloudflare/resources/magic_transit/__init__.py b/src/cloudflare/resources/magic_transit/__init__.py index 842f6cfd86a..db6f2e65c99 100644 --- a/src/cloudflare/resources/magic_transit/__init__.py +++ b/src/cloudflare/resources/magic_transit/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .apps import ( + AppsResource, + AsyncAppsResource, + AppsResourceWithRawResponse, + AsyncAppsResourceWithRawResponse, + AppsResourceWithStreamingResponse, + AsyncAppsResourceWithStreamingResponse, +) from .sites import ( SitesResource, AsyncSitesResource, @@ -58,6 +66,12 @@ ) __all__ = [ + "AppsResource", + "AsyncAppsResource", + "AppsResourceWithRawResponse", + "AsyncAppsResourceWithRawResponse", + "AppsResourceWithStreamingResponse", + "AsyncAppsResourceWithStreamingResponse", "CfInterconnectsResource", "AsyncCfInterconnectsResource", "CfInterconnectsResourceWithRawResponse", diff --git a/src/cloudflare/resources/magic_transit/apps.py b/src/cloudflare/resources/magic_transit/apps.py new file mode 100644 index 00000000000..c0e9b974eec --- /dev/null +++ b/src/cloudflare/resources/magic_transit/apps.py @@ -0,0 +1,777 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, Type, Optional, cast, overload + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + required_args, + 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 ..._base_client import ( + AsyncPaginator, + make_request_options, +) +from ...types.magic_transit import app_create_params, app_update_params +from ...types.magic_transit.app_list_response import AppListResponse +from ...types.magic_transit.app_create_response import AppCreateResponse +from ...types.magic_transit.app_delete_response import AppDeleteResponse +from ...types.magic_transit.app_update_response import AppUpdateResponse + +__all__ = ["AppsResource", "AsyncAppsResource"] + + +class AppsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AppsResourceWithRawResponse: + return AppsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AppsResourceWithStreamingResponse: + return AppsResourceWithStreamingResponse(self) + + @overload + def create( + self, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppCreateResponse]: + """ + Creates a new App for an account + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppCreateResponse]: + """ + Creates a new App for an account + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["account_id", "body"]) + def create( + self, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppCreateResponse]: + 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}/magic/apps", + body=maybe_transform(body, app_create_params.AppCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppCreateResponse]], ResultWrapper[AppCreateResponse]), + ) + + @overload + def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["account_id", "body"]) + def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not account_app_id: + raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") + return self._put( + f"/accounts/{account_id}/magic/apps/{account_app_id}", + body=maybe_transform(body, app_update_params.AppUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppUpdateResponse]], ResultWrapper[AppUpdateResponse]), + ) + + 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[AppListResponse]: + """ + Lists Apps associated with an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/magic/apps", + page=SyncSinglePage[AppListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=cast(Any, AppListResponse), # Union types cannot be passed in as arguments in the type system + ) + + def delete( + self, + account_app_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[AppDeleteResponse]: + """ + Deletes specific Account App. + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not account_app_id: + raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/apps/{account_app_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppDeleteResponse]], ResultWrapper[AppDeleteResponse]), + ) + + +class AsyncAppsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAppsResourceWithRawResponse: + return AsyncAppsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAppsResourceWithStreamingResponse: + return AsyncAppsResourceWithStreamingResponse(self) + + @overload + async def create( + self, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppCreateResponse]: + """ + Creates a new App for an account + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppCreateResponse]: + """ + Creates a new App for an account + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["account_id", "body"]) + async def create( + self, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppCreateResponse]: + 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}/magic/apps", + body=await async_maybe_transform(body, app_create_params.AppCreateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppCreateResponse]], ResultWrapper[AppCreateResponse]), + ) + + @overload + async def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + """ + Updates an Account App + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["account_id", "body"]) + async def update( + self, + account_app_id: str, + *, + account_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not account_app_id: + raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/apps/{account_app_id}", + body=await async_maybe_transform(body, app_update_params.AppUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppUpdateResponse]], ResultWrapper[AppUpdateResponse]), + ) + + 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[AppListResponse, AsyncSinglePage[AppListResponse]]: + """ + Lists Apps associated with an account. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/magic/apps", + page=AsyncSinglePage[AppListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=cast(Any, AppListResponse), # Union types cannot be passed in as arguments in the type system + ) + + async def delete( + self, + account_app_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[AppDeleteResponse]: + """ + Deletes specific Account App. + + Args: + account_id: Identifier + + account_app_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not account_app_id: + raise ValueError(f"Expected a non-empty value for `account_app_id` but received {account_app_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/apps/{account_app_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppDeleteResponse]], ResultWrapper[AppDeleteResponse]), + ) + + +class AppsResourceWithRawResponse: + def __init__(self, apps: AppsResource) -> None: + self._apps = apps + + self.create = to_raw_response_wrapper( + apps.create, + ) + self.update = to_raw_response_wrapper( + apps.update, + ) + self.list = to_raw_response_wrapper( + apps.list, + ) + self.delete = to_raw_response_wrapper( + apps.delete, + ) + + +class AsyncAppsResourceWithRawResponse: + def __init__(self, apps: AsyncAppsResource) -> None: + self._apps = apps + + self.create = async_to_raw_response_wrapper( + apps.create, + ) + self.update = async_to_raw_response_wrapper( + apps.update, + ) + self.list = async_to_raw_response_wrapper( + apps.list, + ) + self.delete = async_to_raw_response_wrapper( + apps.delete, + ) + + +class AppsResourceWithStreamingResponse: + def __init__(self, apps: AppsResource) -> None: + self._apps = apps + + self.create = to_streamed_response_wrapper( + apps.create, + ) + self.update = to_streamed_response_wrapper( + apps.update, + ) + self.list = to_streamed_response_wrapper( + apps.list, + ) + self.delete = to_streamed_response_wrapper( + apps.delete, + ) + + +class AsyncAppsResourceWithStreamingResponse: + def __init__(self, apps: AsyncAppsResource) -> None: + self._apps = apps + + self.create = async_to_streamed_response_wrapper( + apps.create, + ) + self.update = async_to_streamed_response_wrapper( + apps.update, + ) + self.list = async_to_streamed_response_wrapper( + apps.list, + ) + self.delete = async_to_streamed_response_wrapper( + apps.delete, + ) diff --git a/src/cloudflare/resources/magic_transit/magic_transit.py b/src/cloudflare/resources/magic_transit/magic_transit.py index 26c772232f2..7eeb84551cf 100644 --- a/src/cloudflare/resources/magic_transit/magic_transit.py +++ b/src/cloudflare/resources/magic_transit/magic_transit.py @@ -2,6 +2,14 @@ from __future__ import annotations +from .apps import ( + AppsResource, + AsyncAppsResource, + AppsResourceWithRawResponse, + AsyncAppsResourceWithRawResponse, + AppsResourceWithStreamingResponse, + AsyncAppsResourceWithStreamingResponse, +) from .sites import ( SitesResource, AsyncSitesResource, @@ -58,6 +66,10 @@ class MagicTransitResource(SyncAPIResource): + @cached_property + def apps(self) -> AppsResource: + return AppsResource(self._client) + @cached_property def cf_interconnects(self) -> CfInterconnectsResource: return CfInterconnectsResource(self._client) @@ -92,6 +104,10 @@ def with_streaming_response(self) -> MagicTransitResourceWithStreamingResponse: class AsyncMagicTransitResource(AsyncAPIResource): + @cached_property + def apps(self) -> AsyncAppsResource: + return AsyncAppsResource(self._client) + @cached_property def cf_interconnects(self) -> AsyncCfInterconnectsResource: return AsyncCfInterconnectsResource(self._client) @@ -129,6 +145,10 @@ class MagicTransitResourceWithRawResponse: def __init__(self, magic_transit: MagicTransitResource) -> None: self._magic_transit = magic_transit + @cached_property + def apps(self) -> AppsResourceWithRawResponse: + return AppsResourceWithRawResponse(self._magic_transit.apps) + @cached_property def cf_interconnects(self) -> CfInterconnectsResourceWithRawResponse: return CfInterconnectsResourceWithRawResponse(self._magic_transit.cf_interconnects) @@ -158,6 +178,10 @@ class AsyncMagicTransitResourceWithRawResponse: def __init__(self, magic_transit: AsyncMagicTransitResource) -> None: self._magic_transit = magic_transit + @cached_property + def apps(self) -> AsyncAppsResourceWithRawResponse: + return AsyncAppsResourceWithRawResponse(self._magic_transit.apps) + @cached_property def cf_interconnects(self) -> AsyncCfInterconnectsResourceWithRawResponse: return AsyncCfInterconnectsResourceWithRawResponse(self._magic_transit.cf_interconnects) @@ -187,6 +211,10 @@ class MagicTransitResourceWithStreamingResponse: def __init__(self, magic_transit: MagicTransitResource) -> None: self._magic_transit = magic_transit + @cached_property + def apps(self) -> AppsResourceWithStreamingResponse: + return AppsResourceWithStreamingResponse(self._magic_transit.apps) + @cached_property def cf_interconnects(self) -> CfInterconnectsResourceWithStreamingResponse: return CfInterconnectsResourceWithStreamingResponse(self._magic_transit.cf_interconnects) @@ -216,6 +244,10 @@ class AsyncMagicTransitResourceWithStreamingResponse: def __init__(self, magic_transit: AsyncMagicTransitResource) -> None: self._magic_transit = magic_transit + @cached_property + def apps(self) -> AsyncAppsResourceWithStreamingResponse: + return AsyncAppsResourceWithStreamingResponse(self._magic_transit.apps) + @cached_property def cf_interconnects(self) -> AsyncCfInterconnectsResourceWithStreamingResponse: return AsyncCfInterconnectsResourceWithStreamingResponse(self._magic_transit.cf_interconnects) diff --git a/src/cloudflare/resources/magic_transit/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites.py index 67c24a85c6f..c8a502834c7 100644 --- a/src/cloudflare/resources/magic_transit/sites/sites.py +++ b/src/cloudflare/resources/magic_transit/sites/sites.py @@ -30,6 +30,15 @@ WANsResourceWithStreamingResponse, AsyncWANsResourceWithStreamingResponse, ) +from .sites import ( + SitesResource, + AsyncSitesResource, + SitesResourceWithRawResponse, + AsyncSitesResourceWithRawResponse, + SitesResourceWithStreamingResponse, + AsyncSitesResourceWithStreamingResponse, + sites, +) from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ...._utils import ( maybe_transform, @@ -74,6 +83,10 @@ def lans(self) -> LANsResource: def wans(self) -> WANsResource: return WANsResource(self._client) + @cached_property + def sites(self) -> sites.SitesResource: + return SitesResource(self._client) + @cached_property def with_raw_response(self) -> SitesResourceWithRawResponse: return SitesResourceWithRawResponse(self) @@ -431,6 +444,10 @@ def lans(self) -> AsyncLANsResource: def wans(self) -> AsyncWANsResource: return AsyncWANsResource(self._client) + @cached_property + def sites(self) -> sites.AsyncSitesResource: + return AsyncSitesResource(self._client) + @cached_property def with_raw_response(self) -> AsyncSitesResourceWithRawResponse: return AsyncSitesResourceWithRawResponse(self) @@ -810,6 +827,10 @@ def lans(self) -> LANsResourceWithRawResponse: def wans(self) -> WANsResourceWithRawResponse: return WANsResourceWithRawResponse(self._sites.wans) + @cached_property + def sites(self) -> SitesResourceWithRawResponse: + return SitesResourceWithRawResponse(self._sites.sites) + class AsyncSitesResourceWithRawResponse: def __init__(self, sites: AsyncSitesResource) -> None: @@ -846,6 +867,10 @@ def lans(self) -> AsyncLANsResourceWithRawResponse: def wans(self) -> AsyncWANsResourceWithRawResponse: return AsyncWANsResourceWithRawResponse(self._sites.wans) + @cached_property + def sites(self) -> AsyncSitesResourceWithRawResponse: + return AsyncSitesResourceWithRawResponse(self._sites.sites) + class SitesResourceWithStreamingResponse: def __init__(self, sites: SitesResource) -> None: @@ -882,6 +907,10 @@ def lans(self) -> LANsResourceWithStreamingResponse: def wans(self) -> WANsResourceWithStreamingResponse: return WANsResourceWithStreamingResponse(self._sites.wans) + @cached_property + def sites(self) -> SitesResourceWithStreamingResponse: + return SitesResourceWithStreamingResponse(self._sites.sites) + class AsyncSitesResourceWithStreamingResponse: def __init__(self, sites: AsyncSitesResource) -> None: @@ -917,3 +946,7 @@ def lans(self) -> AsyncLANsResourceWithStreamingResponse: @cached_property def wans(self) -> AsyncWANsResourceWithStreamingResponse: return AsyncWANsResourceWithStreamingResponse(self._sites.wans) + + @cached_property + def sites(self) -> AsyncSitesResourceWithStreamingResponse: + return AsyncSitesResourceWithStreamingResponse(self._sites.sites) diff --git a/src/cloudflare/resources/magic_transit/sites/sites/__init__.py b/src/cloudflare/resources/magic_transit/sites/sites/__init__.py new file mode 100644 index 00000000000..01aea158619 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/sites/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .sites import ( + SitesResource, + AsyncSitesResource, + SitesResourceWithRawResponse, + AsyncSitesResourceWithRawResponse, + SitesResourceWithStreamingResponse, + AsyncSitesResourceWithStreamingResponse, +) +from .app_configuration import ( + AppConfigurationResource, + AsyncAppConfigurationResource, + AppConfigurationResourceWithRawResponse, + AsyncAppConfigurationResourceWithRawResponse, + AppConfigurationResourceWithStreamingResponse, + AsyncAppConfigurationResourceWithStreamingResponse, +) + +__all__ = [ + "AppConfigurationResource", + "AsyncAppConfigurationResource", + "AppConfigurationResourceWithRawResponse", + "AsyncAppConfigurationResourceWithRawResponse", + "AppConfigurationResourceWithStreamingResponse", + "AsyncAppConfigurationResourceWithStreamingResponse", + "SitesResource", + "AsyncSitesResource", + "SitesResourceWithRawResponse", + "AsyncSitesResourceWithRawResponse", + "SitesResourceWithStreamingResponse", + "AsyncSitesResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py b/src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py new file mode 100644 index 00000000000..7e61a793203 --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py @@ -0,0 +1,1049 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast, overload + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + required_args, + 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 ....._base_client import ( + AsyncPaginator, + make_request_options, +) +from .....types.magic_transit.sites.sites import app_configuration_create_params, app_configuration_update_params +from .....types.magic_transit.sites.sites.app_configuration_list_response import AppConfigurationListResponse +from .....types.magic_transit.sites.sites.app_configuration_create_response import AppConfigurationCreateResponse +from .....types.magic_transit.sites.sites.app_configuration_delete_response import AppConfigurationDeleteResponse +from .....types.magic_transit.sites.sites.app_configuration_update_response import AppConfigurationUpdateResponse + +__all__ = ["AppConfigurationResource", "AsyncAppConfigurationResource"] + + +class AppConfigurationResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AppConfigurationResourceWithRawResponse: + return AppConfigurationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AppConfigurationResourceWithStreamingResponse: + return AppConfigurationResourceWithStreamingResponse(self) + + @overload + def create( + self, + site_id: str, + *, + account_id: str, + account_app_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[AppConfigurationCreateResponse]: + """ + Creates a new App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + account_app_id: Magic account app 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 + """ + ... + + @overload + def create( + self, + site_id: str, + *, + account_id: str, + managed_app_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[AppConfigurationCreateResponse]: + """ + Creates a new App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + managed_app_id: Managed app 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 + """ + ... + + @required_args(["account_id", "account_app_id"], ["account_id", "managed_app_id"]) + def create( + self, + site_id: str, + *, + account_id: str, + account_app_id: str | NotGiven = NOT_GIVEN, + managed_app_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppConfigurationCreateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", + body=maybe_transform( + { + "account_app_id": account_app_id, + "managed_app_id": managed_app_id, + }, + app_configuration_create_params.AppConfigurationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationCreateResponse]], ResultWrapper[AppConfigurationCreateResponse]), + ) + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: Magic account app 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 + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + managed_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + managed_app_id: Managed app 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 + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_id: str, + managed_app_id: Optional[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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: Magic account app ID. + + managed_app_id: **Must be set to null** + + 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 + """ + ... + + @overload + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_id: Optional[str], + managed_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: **Must be set to null** + + managed_app_id: Managed app 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 + """ + ... + + @required_args( + ["account_id", "site_id", "body"], + ["account_id", "site_id", "account_app_id"], + ["account_id", "site_id", "managed_app_id"], + ["account_id", "site_id", "account_app_id", "managed_app_id"], + ) + def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + body: object | NotGiven = NOT_GIVEN, + account_app_id: str | None | NotGiven = NOT_GIVEN, + managed_app_id: str | None | 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[AppConfigurationUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not app_config_id: + raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") + return self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", + body=maybe_transform(body, app_configuration_update_params.AppConfigurationUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationUpdateResponse]], ResultWrapper[AppConfigurationUpdateResponse]), + ) + + def list( + self, + site_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, + ) -> SyncSinglePage[AppConfigurationListResponse]: + """ + Lists App Configs associated with a site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", + page=SyncSinglePage[AppConfigurationListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=AppConfigurationListResponse, + ) + + def delete( + self, + app_config_id: str, + *, + account_id: str, + site_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[AppConfigurationDeleteResponse]: + """ + Deletes specific App Config associated with a site. + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not app_config_id: + raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") + return self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationDeleteResponse]], ResultWrapper[AppConfigurationDeleteResponse]), + ) + + +class AsyncAppConfigurationResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAppConfigurationResourceWithRawResponse: + return AsyncAppConfigurationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAppConfigurationResourceWithStreamingResponse: + return AsyncAppConfigurationResourceWithStreamingResponse(self) + + @overload + async def create( + self, + site_id: str, + *, + account_id: str, + account_app_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[AppConfigurationCreateResponse]: + """ + Creates a new App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + account_app_id: Magic account app 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 + """ + ... + + @overload + async def create( + self, + site_id: str, + *, + account_id: str, + managed_app_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[AppConfigurationCreateResponse]: + """ + Creates a new App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + managed_app_id: Managed app 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 + """ + ... + + @required_args(["account_id", "account_app_id"], ["account_id", "managed_app_id"]) + async def create( + self, + site_id: str, + *, + account_id: str, + account_app_id: str | NotGiven = NOT_GIVEN, + managed_app_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppConfigurationCreateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return await self._post( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", + body=await async_maybe_transform( + { + "account_app_id": account_app_id, + "managed_app_id": managed_app_id, + }, + app_configuration_create_params.AppConfigurationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationCreateResponse]], ResultWrapper[AppConfigurationCreateResponse]), + ) + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + body: object, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: Magic account app 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 + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + managed_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + managed_app_id: Managed app 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 + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_id: str, + managed_app_id: Optional[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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: Magic account app ID. + + managed_app_id: **Must be set to null** + + 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 + """ + ... + + @overload + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + account_app_id: Optional[str], + managed_app_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[AppConfigurationUpdateResponse]: + """ + Updates an App Config for a site + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + account_app_id: **Must be set to null** + + managed_app_id: Managed app 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 + """ + ... + + @required_args( + ["account_id", "site_id", "body"], + ["account_id", "site_id", "account_app_id"], + ["account_id", "site_id", "managed_app_id"], + ["account_id", "site_id", "account_app_id", "managed_app_id"], + ) + async def update( + self, + app_config_id: str, + *, + account_id: str, + site_id: str, + body: object | NotGiven = NOT_GIVEN, + account_app_id: str | None | NotGiven = NOT_GIVEN, + managed_app_id: str | None | 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[AppConfigurationUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not app_config_id: + raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") + return await self._put( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", + body=await async_maybe_transform(body, app_configuration_update_params.AppConfigurationUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationUpdateResponse]], ResultWrapper[AppConfigurationUpdateResponse]), + ) + + def list( + self, + site_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, + ) -> AsyncPaginator[AppConfigurationListResponse, AsyncSinglePage[AppConfigurationListResponse]]: + """ + Lists App Configs associated with a site. + + Args: + account_id: Identifier + + site_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", + page=AsyncSinglePage[AppConfigurationListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=AppConfigurationListResponse, + ) + + async def delete( + self, + app_config_id: str, + *, + account_id: str, + site_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[AppConfigurationDeleteResponse]: + """ + Deletes specific App Config associated with a site. + + Args: + account_id: Identifier + + site_id: Identifier + + app_config_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not site_id: + raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") + if not app_config_id: + raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") + return await self._delete( + f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AppConfigurationDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AppConfigurationDeleteResponse]], ResultWrapper[AppConfigurationDeleteResponse]), + ) + + +class AppConfigurationResourceWithRawResponse: + def __init__(self, app_configuration: AppConfigurationResource) -> None: + self._app_configuration = app_configuration + + self.create = to_raw_response_wrapper( + app_configuration.create, + ) + self.update = to_raw_response_wrapper( + app_configuration.update, + ) + self.list = to_raw_response_wrapper( + app_configuration.list, + ) + self.delete = to_raw_response_wrapper( + app_configuration.delete, + ) + + +class AsyncAppConfigurationResourceWithRawResponse: + def __init__(self, app_configuration: AsyncAppConfigurationResource) -> None: + self._app_configuration = app_configuration + + self.create = async_to_raw_response_wrapper( + app_configuration.create, + ) + self.update = async_to_raw_response_wrapper( + app_configuration.update, + ) + self.list = async_to_raw_response_wrapper( + app_configuration.list, + ) + self.delete = async_to_raw_response_wrapper( + app_configuration.delete, + ) + + +class AppConfigurationResourceWithStreamingResponse: + def __init__(self, app_configuration: AppConfigurationResource) -> None: + self._app_configuration = app_configuration + + self.create = to_streamed_response_wrapper( + app_configuration.create, + ) + self.update = to_streamed_response_wrapper( + app_configuration.update, + ) + self.list = to_streamed_response_wrapper( + app_configuration.list, + ) + self.delete = to_streamed_response_wrapper( + app_configuration.delete, + ) + + +class AsyncAppConfigurationResourceWithStreamingResponse: + def __init__(self, app_configuration: AsyncAppConfigurationResource) -> None: + self._app_configuration = app_configuration + + self.create = async_to_streamed_response_wrapper( + app_configuration.create, + ) + self.update = async_to_streamed_response_wrapper( + app_configuration.update, + ) + self.list = async_to_streamed_response_wrapper( + app_configuration.list, + ) + self.delete = async_to_streamed_response_wrapper( + app_configuration.delete, + ) diff --git a/src/cloudflare/resources/magic_transit/sites/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites/sites.py new file mode 100644 index 00000000000..04377a5750e --- /dev/null +++ b/src/cloudflare/resources/magic_transit/sites/sites/sites.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from .app_configuration import ( + AppConfigurationResource, + AsyncAppConfigurationResource, + AppConfigurationResourceWithRawResponse, + AsyncAppConfigurationResourceWithRawResponse, + AppConfigurationResourceWithStreamingResponse, + AsyncAppConfigurationResourceWithStreamingResponse, +) + +__all__ = ["SitesResource", "AsyncSitesResource"] + + +class SitesResource(SyncAPIResource): + @cached_property + def app_configuration(self) -> AppConfigurationResource: + return AppConfigurationResource(self._client) + + @cached_property + def with_raw_response(self) -> SitesResourceWithRawResponse: + return SitesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SitesResourceWithStreamingResponse: + return SitesResourceWithStreamingResponse(self) + + +class AsyncSitesResource(AsyncAPIResource): + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResource: + return AsyncAppConfigurationResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSitesResourceWithRawResponse: + return AsyncSitesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSitesResourceWithStreamingResponse: + return AsyncSitesResourceWithStreamingResponse(self) + + +class SitesResourceWithRawResponse: + def __init__(self, sites: SitesResource) -> None: + self._sites = sites + + @cached_property + def app_configuration(self) -> AppConfigurationResourceWithRawResponse: + return AppConfigurationResourceWithRawResponse(self._sites.app_configuration) + + +class AsyncSitesResourceWithRawResponse: + def __init__(self, sites: AsyncSitesResource) -> None: + self._sites = sites + + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResourceWithRawResponse: + return AsyncAppConfigurationResourceWithRawResponse(self._sites.app_configuration) + + +class SitesResourceWithStreamingResponse: + def __init__(self, sites: SitesResource) -> None: + self._sites = sites + + @cached_property + def app_configuration(self) -> AppConfigurationResourceWithStreamingResponse: + return AppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) + + +class AsyncSitesResourceWithStreamingResponse: + def __init__(self, sites: AsyncSitesResource) -> None: + self._sites = sites + + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResourceWithStreamingResponse: + return AsyncAppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) diff --git a/src/cloudflare/types/addressing/__init__.py b/src/cloudflare/types/addressing/__init__.py index 2ea66f6d7f8..1c96d654c50 100644 --- a/src/cloudflare/types/addressing/__init__.py +++ b/src/cloudflare/types/addressing/__init__.py @@ -16,3 +16,10 @@ from .address_map_create_response import AddressMapCreateResponse as AddressMapCreateResponse from .address_map_delete_response import AddressMapDeleteResponse as AddressMapDeleteResponse from .loa_document_create_response import LOADocumentCreateResponse as LOADocumentCreateResponse +from .regional_hostname_edit_params import RegionalHostnameEditParams as RegionalHostnameEditParams +from .regional_hostname_get_response import RegionalHostnameGetResponse as RegionalHostnameGetResponse +from .regional_hostname_create_params import RegionalHostnameCreateParams as RegionalHostnameCreateParams +from .regional_hostname_edit_response import RegionalHostnameEditResponse as RegionalHostnameEditResponse +from .regional_hostname_list_response import RegionalHostnameListResponse as RegionalHostnameListResponse +from .regional_hostname_create_response import RegionalHostnameCreateResponse as RegionalHostnameCreateResponse +from .regional_hostname_delete_response import RegionalHostnameDeleteResponse as RegionalHostnameDeleteResponse diff --git a/src/cloudflare/types/addressing/regional_hostname_create_params.py b/src/cloudflare/types/addressing/regional_hostname_create_params.py new file mode 100644 index 00000000000..630c2f0bed3 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_create_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["RegionalHostnameCreateParams"] + + +class RegionalHostnameCreateParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + hostname: Required[str] + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: Required[str] + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_create_response.py b/src/cloudflare/types/addressing/regional_hostname_create_response.py new file mode 100644 index 00000000000..f2717ccf6ed --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_create_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RegionalHostnameCreateResponse"] + + +class RegionalHostnameCreateResponse(BaseModel): + created_on: datetime + """When the regional hostname was created""" + + hostname: str + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: str + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_delete_response.py b/src/cloudflare/types/addressing/regional_hostname_delete_response.py new file mode 100644 index 00000000000..1031166663d --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_delete_response.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo + +__all__ = ["RegionalHostnameDeleteResponse"] + + +class RegionalHostnameDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/addressing/regional_hostname_edit_params.py b/src/cloudflare/types/addressing/regional_hostname_edit_params.py new file mode 100644 index 00000000000..a205f2de604 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_edit_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["RegionalHostnameEditParams"] + + +class RegionalHostnameEditParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + region_key: Required[str] + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_edit_response.py b/src/cloudflare/types/addressing/regional_hostname_edit_response.py new file mode 100644 index 00000000000..06a760610de --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_edit_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RegionalHostnameEditResponse"] + + +class RegionalHostnameEditResponse(BaseModel): + created_on: datetime + """When the regional hostname was created""" + + hostname: str + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: str + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_get_response.py b/src/cloudflare/types/addressing/regional_hostname_get_response.py new file mode 100644 index 00000000000..24fe021f2fe --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_get_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RegionalHostnameGetResponse"] + + +class RegionalHostnameGetResponse(BaseModel): + created_on: datetime + """When the regional hostname was created""" + + hostname: str + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: str + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostname_list_response.py b/src/cloudflare/types/addressing/regional_hostname_list_response.py new file mode 100644 index 00000000000..fe454021dc0 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostname_list_response.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["RegionalHostnameListResponse"] + + +class RegionalHostnameListResponse(BaseModel): + created_on: datetime + """When the regional hostname was created""" + + hostname: str + """DNS hostname to be regionalized, must be a subdomain of the zone. + + Wildcards are supported for one level, e.g `*.example.com` + """ + + region_key: str + """Identifying key for the region""" diff --git a/src/cloudflare/types/addressing/regional_hostnames/__init__.py b/src/cloudflare/types/addressing/regional_hostnames/__init__.py new file mode 100644 index 00000000000..cf8fe425ff5 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostnames/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .region_list_response import RegionListResponse as RegionListResponse diff --git a/src/cloudflare/types/addressing/regional_hostnames/region_list_response.py b/src/cloudflare/types/addressing/regional_hostnames/region_list_response.py new file mode 100644 index 00000000000..d17c6577e43 --- /dev/null +++ b/src/cloudflare/types/addressing/regional_hostnames/region_list_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["RegionListResponse"] + + +class RegionListResponse(BaseModel): + key: Optional[str] = None + """Identifying key for the region""" + + label: Optional[str] = None + """Human-readable text label for the region""" diff --git a/src/cloudflare/types/magic_transit/__init__.py b/src/cloudflare/types/magic_transit/__init__.py index 298acb27b50..ad2327c5724 100644 --- a/src/cloudflare/types/magic_transit/__init__.py +++ b/src/cloudflare/types/magic_transit/__init__.py @@ -10,12 +10,18 @@ from .site_location import SiteLocation as SiteLocation from .site_edit_params import SiteEditParams as SiteEditParams from .site_list_params import SiteListParams as SiteListParams +from .app_create_params import AppCreateParams as AppCreateParams +from .app_list_response import AppListResponse as AppListResponse +from .app_update_params import AppUpdateParams as AppUpdateParams from .health_check_rate import HealthCheckRate as HealthCheckRate from .health_check_type import HealthCheckType as HealthCheckType from .health_check_param import HealthCheckParam as HealthCheckParam from .route_get_response import RouteGetResponse as RouteGetResponse from .site_create_params import SiteCreateParams as SiteCreateParams from .site_update_params import SiteUpdateParams as SiteUpdateParams +from .app_create_response import AppCreateResponse as AppCreateResponse +from .app_delete_response import AppDeleteResponse as AppDeleteResponse +from .app_update_response import AppUpdateResponse as AppUpdateResponse from .route_create_params import RouteCreateParams as RouteCreateParams from .route_list_response import RouteListResponse as RouteListResponse from .route_update_params import RouteUpdateParams as RouteUpdateParams diff --git a/src/cloudflare/types/magic_transit/app_create_params.py b/src/cloudflare/types/magic_transit/app_create_params.py new file mode 100644 index 00000000000..663405d69c1 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_create_params.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Required, TypedDict + +__all__ = ["AppCreateParams", "Hostnames", "Subnets"] + + +class Hostnames(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +class Subnets(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +AppCreateParams = Union[Hostnames, Subnets] diff --git a/src/cloudflare/types/magic_transit/app_create_response.py b/src/cloudflare/types/magic_transit/app_create_response.py new file mode 100644 index 00000000000..109887e4753 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_create_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["AppCreateResponse"] + + +class AppCreateResponse(BaseModel): + account_app_id: str + """Magic account app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_delete_response.py b/src/cloudflare/types/magic_transit/app_delete_response.py new file mode 100644 index 00000000000..0eafc15562c --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_delete_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["AppDeleteResponse"] + + +class AppDeleteResponse(BaseModel): + account_app_id: str + """Magic account app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_list_response.py b/src/cloudflare/types/magic_transit/app_list_response.py new file mode 100644 index 00000000000..a7ef5d8cbd3 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_list_response.py @@ -0,0 +1,44 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional + +from ..._models import BaseModel + +__all__ = ["AppListResponse", "MagicAccountApp", "MagicManagedApp"] + + +class MagicAccountApp(BaseModel): + account_app_id: str + """Magic account app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" + + +class MagicManagedApp(BaseModel): + managed_app_id: str + """Managed app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" + + +AppListResponse = Union[MagicAccountApp, MagicManagedApp] diff --git a/src/cloudflare/types/magic_transit/app_update_params.py b/src/cloudflare/types/magic_transit/app_update_params.py new file mode 100644 index 00000000000..4aa43a96678 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_update_params.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Required, TypedDict + +__all__ = ["AppUpdateParams", "UpdateAppName", "UpdateAppType", "UpdateAppHostnames", "UpdateAppSubnets"] + + +class UpdateAppName(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +class UpdateAppType(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +class UpdateAppHostnames(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +class UpdateAppSubnets(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + body: Required[object] + + +AppUpdateParams = Union[UpdateAppName, UpdateAppType, UpdateAppHostnames, UpdateAppSubnets] diff --git a/src/cloudflare/types/magic_transit/app_update_response.py b/src/cloudflare/types/magic_transit/app_update_response.py new file mode 100644 index 00000000000..fb98877f021 --- /dev/null +++ b/src/cloudflare/types/magic_transit/app_update_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["AppUpdateResponse"] + + +class AppUpdateResponse(BaseModel): + account_app_id: str + """Magic account app ID.""" + + hostnames: Optional[List[str]] = None + """FQDNs to associate with traffic decisions.""" + + ip_subnets: Optional[List[str]] = None + """CIDRs to associate with traffic decisions.""" + + name: Optional[str] = None + """Display name for the app.""" + + type: Optional[str] = None + """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/sites/sites/__init__.py b/src/cloudflare/types/magic_transit/sites/sites/__init__.py new file mode 100644 index 00000000000..4b8fd25c1d0 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/__init__.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .app_configuration_create_params import AppConfigurationCreateParams as AppConfigurationCreateParams +from .app_configuration_list_response import AppConfigurationListResponse as AppConfigurationListResponse +from .app_configuration_update_params import AppConfigurationUpdateParams as AppConfigurationUpdateParams +from .app_configuration_create_response import AppConfigurationCreateResponse as AppConfigurationCreateResponse +from .app_configuration_delete_response import AppConfigurationDeleteResponse as AppConfigurationDeleteResponse +from .app_configuration_update_response import AppConfigurationUpdateResponse as AppConfigurationUpdateResponse diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py new file mode 100644 index 00000000000..e5293390127 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Required, TypedDict + +__all__ = ["AppConfigurationCreateParams", "AccountApp", "ManagedApp"] + + +class AccountApp(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + account_app_id: Required[str] + """Magic account app ID.""" + + +class ManagedApp(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + managed_app_id: Required[str] + """Managed app ID.""" + + +AppConfigurationCreateParams = Union[AccountApp, ManagedApp] diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py new file mode 100644 index 00000000000..3b1c31a4251 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["AppConfigurationCreateResponse"] + + +class AppConfigurationCreateResponse(BaseModel): + id: str + """Identifier""" + + site_id: str + """Identifier""" + + breakout: Optional[bool] = None + """Whether to breakout traffic to the app's endpoints directly. + + Null preserves default behavior. + """ + + priority: Optional[int] = None + """Priority of traffic. + + 0 is default, anything greater is prioritized. (Currently only 0 and 1 are + supported) + """ diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py new file mode 100644 index 00000000000..1c5daf9c4fc --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["AppConfigurationDeleteResponse"] + + +class AppConfigurationDeleteResponse(BaseModel): + id: str + """Identifier""" + + site_id: str + """Identifier""" + + breakout: Optional[bool] = None + """Whether to breakout traffic to the app's endpoints directly. + + Null preserves default behavior. + """ + + priority: Optional[int] = None + """Priority of traffic. + + 0 is default, anything greater is prioritized. (Currently only 0 and 1 are + supported) + """ diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py new file mode 100644 index 00000000000..9c508e2a035 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["AppConfigurationListResponse"] + + +class AppConfigurationListResponse(BaseModel): + id: str + """Identifier""" + + site_id: str + """Identifier""" + + breakout: Optional[bool] = None + """Whether to breakout traffic to the app's endpoints directly. + + Null preserves default behavior. + """ + + priority: Optional[int] = None + """Priority of traffic. + + 0 is default, anything greater is prioritized. (Currently only 0 and 1 are + supported) + """ diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py new file mode 100644 index 00000000000..eb81278baa2 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py @@ -0,0 +1,96 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Optional +from typing_extensions import Required, TypedDict + +__all__ = [ + "AppConfigurationUpdateParams", + "ChangeBreakoutBehavior", + "ChangePriority", + "UpdateAccountAppID", + "UpdateManagedAppID", + "AccountAppManagedApp", + "ManagedAppAccountApp", +] + + +class ChangeBreakoutBehavior(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + body: Required[object] + + +class ChangePriority(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + body: Required[object] + + +class UpdateAccountAppID(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + account_app_id: Required[str] + """Magic account app ID.""" + + +class UpdateManagedAppID(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + managed_app_id: Required[str] + """Managed app ID.""" + + +class AccountAppManagedApp(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + account_app_id: Required[str] + """Magic account app ID.""" + + managed_app_id: Required[Optional[str]] + """**Must be set to null**""" + + +class ManagedAppAccountApp(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + site_id: Required[str] + """Identifier""" + + account_app_id: Required[Optional[str]] + """**Must be set to null**""" + + managed_app_id: Required[str] + """Managed app ID.""" + + +AppConfigurationUpdateParams = Union[ + ChangeBreakoutBehavior, + ChangePriority, + UpdateAccountAppID, + UpdateManagedAppID, + AccountAppManagedApp, + ManagedAppAccountApp, +] diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py new file mode 100644 index 00000000000..01ef039b4e6 --- /dev/null +++ b/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ....._models import BaseModel + +__all__ = ["AppConfigurationUpdateResponse"] + + +class AppConfigurationUpdateResponse(BaseModel): + id: str + """Identifier""" + + site_id: str + """Identifier""" + + breakout: Optional[bool] = None + """Whether to breakout traffic to the app's endpoints directly. + + Null preserves default behavior. + """ + + priority: Optional[int] = None + """Priority of traffic. + + 0 is default, anything greater is prioritized. (Currently only 0 and 1 are + supported) + """ diff --git a/tests/api_resources/addressing/regional_hostnames/__init__.py b/tests/api_resources/addressing/regional_hostnames/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/addressing/regional_hostnames/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/addressing/regional_hostnames/test_regions.py b/tests/api_resources/addressing/regional_hostnames/test_regions.py new file mode 100644 index 00000000000..5d23799e1bf --- /dev/null +++ b/tests/api_resources/addressing/regional_hostnames/test_regions.py @@ -0,0 +1,99 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.addressing.regional_hostnames import RegionListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRegions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + region = client.addressing.regional_hostnames.regions.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[RegionListResponse], region, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.regions.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + region = response.parse() + assert_matches_type(SyncSinglePage[RegionListResponse], region, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.regions.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + region = response.parse() + assert_matches_type(SyncSinglePage[RegionListResponse], region, 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.addressing.regional_hostnames.regions.with_raw_response.list( + account_id="", + ) + + +class TestAsyncRegions: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + region = await async_client.addressing.regional_hostnames.regions.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[RegionListResponse], region, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.regions.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + region = await response.parse() + assert_matches_type(AsyncSinglePage[RegionListResponse], region, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.regions.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + region = await response.parse() + assert_matches_type(AsyncSinglePage[RegionListResponse], region, 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.addressing.regional_hostnames.regions.with_raw_response.list( + account_id="", + ) diff --git a/tests/api_resources/addressing/test_regional_hostnames.py b/tests/api_resources/addressing/test_regional_hostnames.py new file mode 100644 index 00000000000..3dc5d085fba --- /dev/null +++ b/tests/api_resources/addressing/test_regional_hostnames.py @@ -0,0 +1,495 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.addressing import ( + RegionalHostnameGetResponse, + RegionalHostnameEditResponse, + RegionalHostnameListResponse, + RegionalHostnameCreateResponse, + RegionalHostnameDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRegionalHostnames: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.create( + zone_id="", + hostname="foo.example.com", + region_key="ca", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(SyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(SyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.list( + zone_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.delete( + "foo.example.com", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + client.addressing.regional_hostnames.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, 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 `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.edit( + "foo.example.com", + zone_id="", + region_key="ca", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + client.addressing.regional_hostnames.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + regional_hostname = client.addressing.regional_hostnames.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.addressing.regional_hostnames.with_raw_response.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.addressing.regional_hostnames.with_streaming_response.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = response.parse() + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.addressing.regional_hostnames.with_raw_response.get( + "foo.example.com", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + client.addressing.regional_hostnames.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncRegionalHostnames: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.create( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + hostname="foo.example.com", + region_key="ca", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameCreateResponse], regional_hostname, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.create( + zone_id="", + hostname="foo.example.com", + region_key="ca", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(AsyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(AsyncSinglePage[RegionalHostnameListResponse], regional_hostname, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.list( + zone_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.delete( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(RegionalHostnameDeleteResponse, regional_hostname, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.delete( + "foo.example.com", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.delete( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.edit( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameEditResponse], regional_hostname, 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 `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.edit( + "foo.example.com", + zone_id="", + region_key="ca", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.edit( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + region_key="ca", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + regional_hostname = await async_client.addressing.regional_hostnames.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.addressing.regional_hostnames.with_raw_response.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.addressing.regional_hostnames.with_streaming_response.get( + "foo.example.com", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + regional_hostname = await response.parse() + assert_matches_type(Optional[RegionalHostnameGetResponse], regional_hostname, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.get( + "foo.example.com", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `hostname` but received ''"): + await async_client.addressing.regional_hostnames.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/sites/sites/__init__.py b/tests/api_resources/magic_transit/sites/sites/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/magic_transit/sites/sites/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/magic_transit/sites/sites/test_app_configuration.py b/tests/api_resources/magic_transit/sites/sites/test_app_configuration.py new file mode 100644 index 00000000000..65670e86460 --- /dev/null +++ b/tests/api_resources/magic_transit/sites/sites/test_app_configuration.py @@ -0,0 +1,1272 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.magic_transit.sites.sites import ( + AppConfigurationListResponse, + AppConfigurationCreateResponse, + AppConfigurationDeleteResponse, + AppConfigurationUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAppConfiguration: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create_overload_1(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + @parametrize + def test_method_create_overload_2(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + @parametrize + def test_method_update_overload_1(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_3(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + @parametrize + def test_method_update_overload_4(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_4(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + @parametrize + def test_method_update_overload_5(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_5(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + @parametrize + def test_method_update_overload_6(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_6(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="string", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, 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.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + app_configuration = client.magic_transit.sites.sites.app_configuration.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.sites.sites.app_configuration.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = response.parse() + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, 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.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncAppConfiguration: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + @parametrize + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + ) + + @parametrize + async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + managed_app_id="cloudflare", + ) + + @parametrize + async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="ac60d3d0435248289d446cedd870bcf4", + managed_app_id="string", + ) + + @parametrize + async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + account_app_id="string", + managed_app_id="cloudflare", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + account_app_id="string", + managed_app_id="cloudflare", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, 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.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + app_configuration = await async_client.magic_transit.sites.sites.app_configuration.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app_configuration = await response.parse() + assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, 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.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): + await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + site_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/magic_transit/test_apps.py b/tests/api_resources/magic_transit/test_apps.py new file mode 100644 index 00000000000..32ba34bf644 --- /dev/null +++ b/tests/api_resources/magic_transit/test_apps.py @@ -0,0 +1,792 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.magic_transit import ( + AppListResponse, + AppCreateResponse, + AppDeleteResponse, + AppUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestApps: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create_overload_1(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.create( + account_id="", + body={}, + ) + + @parametrize + def test_method_create_overload_2(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.create( + account_id="", + body={}, + ) + + @parametrize + def test_method_update_overload_1(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_3(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_update_overload_4(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_4(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[AppListResponse], app, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(SyncSinglePage[AppListResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(SyncSinglePage[AppListResponse], app, 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.magic_transit.apps.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + app = client.magic_transit.apps.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AppDeleteResponse], app, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.magic_transit.apps.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = response.parse() + assert_matches_type(Optional[AppDeleteResponse], app, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.magic_transit.apps.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = response.parse() + assert_matches_type(Optional[AppDeleteResponse], app, 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.magic_transit.apps.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + client.magic_transit.apps.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncApps: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.create( + account_id="", + body={}, + ) + + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.create( + account_id="", + body={}, + ) + + @parametrize + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + body={}, + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[AppListResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(AsyncSinglePage[AppListResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(AsyncSinglePage[AppListResponse], app, 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.magic_transit.apps.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + app = await async_client.magic_transit.apps.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AppDeleteResponse], app, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.magic_transit.apps.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + app = await response.parse() + assert_matches_type(Optional[AppDeleteResponse], app, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.magic_transit.apps.with_streaming_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + app = await response.parse() + assert_matches_type(Optional[AppDeleteResponse], app, 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.magic_transit.apps.with_raw_response.delete( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_app_id` but received ''"): + await async_client.magic_transit.apps.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) From af6dfae184d6380d5702d575bbbf17f2b3360a65 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:46:05 +0000 Subject: [PATCH 295/532] feat(api): OpenAPI spec update via Stainless API (#776) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b1ee01299ac..036bd6a320f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ac33a501d722d88a0ebf590d74e32c77066a57b327cb3a2fae156558b6e7b75c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml From ae962684f6ce3fe43deac956713ff72c53aeab2b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:48:15 +0000 Subject: [PATCH 296/532] feat(api): OpenAPI spec update via Stainless API (#777) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 036bd6a320f..5d67bcc6bdc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5be95789763c3b4b655f44e48b2d615e059cdfb5a52d62a7e084c84ffa039fe2.yml From 5ffaecc6e0a404a3df2a65d088ab500e46027256 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:50:43 +0000 Subject: [PATCH 297/532] feat(api): update via SDK Studio (#778) --- .stats.yml | 2 +- api.md | 42 ++-- .../resources/magic_transit/sites/__init__.py | 14 ++ .../sites/{sites => }/app_configuration.py | 26 +- .../resources/magic_transit/sites/sites.py | 65 +++-- .../magic_transit/sites/sites/__init__.py | 33 --- .../magic_transit/sites/sites/sites.py | 80 ------ .../types/magic_transit/sites/__init__.py | 6 + .../app_configuration_create_params.py | 0 .../app_configuration_create_response.py | 2 +- .../app_configuration_delete_response.py | 2 +- .../app_configuration_list_response.py | 2 +- .../app_configuration_update_params.py | 0 .../app_configuration_update_response.py | 2 +- .../magic_transit/sites/sites/__init__.py | 10 - .../magic_transit/sites/sites/__init__.py | 1 - .../{sites => }/test_app_configuration.py | 230 +++++++++--------- 17 files changed, 205 insertions(+), 312 deletions(-) rename src/cloudflare/resources/magic_transit/sites/{sites => }/app_configuration.py (97%) delete mode 100644 src/cloudflare/resources/magic_transit/sites/sites/__init__.py delete mode 100644 src/cloudflare/resources/magic_transit/sites/sites/sites.py rename src/cloudflare/types/magic_transit/sites/{sites => }/app_configuration_create_params.py (100%) rename src/cloudflare/types/magic_transit/sites/{sites => }/app_configuration_create_response.py (94%) rename src/cloudflare/types/magic_transit/sites/{sites => }/app_configuration_delete_response.py (94%) rename src/cloudflare/types/magic_transit/sites/{sites => }/app_configuration_list_response.py (94%) rename src/cloudflare/types/magic_transit/sites/{sites => }/app_configuration_update_params.py (100%) rename src/cloudflare/types/magic_transit/sites/{sites => }/app_configuration_update_response.py (94%) delete mode 100644 src/cloudflare/types/magic_transit/sites/sites/__init__.py delete mode 100644 tests/api_resources/magic_transit/sites/sites/__init__.py rename tests/api_resources/magic_transit/sites/{sites => }/test_app_configuration.py (83%) diff --git a/.stats.yml b/.stats.yml index 5d67bcc6bdc..036bd6a320f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5be95789763c3b4b655f44e48b2d615e059cdfb5a52d62a7e084c84ffa039fe2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml diff --git a/api.md b/api.md index 59465cfbc9f..26ae9445536 100644 --- a/api.md +++ b/api.md @@ -4068,6 +4068,26 @@ Methods: - client.magic_transit.sites.edit(site_id, \*, account_id, \*\*params) -> Site - client.magic_transit.sites.get(site_id, \*, account_id) -> Site +### AppConfiguration + +Types: + +```python +from cloudflare.types.magic_transit.sites import ( + AppConfigurationCreateResponse, + AppConfigurationUpdateResponse, + AppConfigurationListResponse, + AppConfigurationDeleteResponse, +) +``` + +Methods: + +- client.magic_transit.sites.app_configuration.create(site_id, \*, account_id, \*\*params) -> Optional +- client.magic_transit.sites.app_configuration.update(app_config_id, \*, account_id, site_id, \*\*params) -> Optional +- client.magic_transit.sites.app_configuration.list(site_id, \*, account_id) -> SyncSinglePage[AppConfigurationListResponse] +- client.magic_transit.sites.app_configuration.delete(app_config_id, \*, account_id, site_id) -> Optional + ### ACLs Types: @@ -4127,28 +4147,6 @@ Methods: - client.magic_transit.sites.wans.edit(wan_id, \*, account_id, site_id, \*\*params) -> WAN - client.magic_transit.sites.wans.get(wan_id, \*, account_id, site_id) -> WAN -### Sites - -#### AppConfiguration - -Types: - -```python -from cloudflare.types.magic_transit.sites.sites import ( - AppConfigurationCreateResponse, - AppConfigurationUpdateResponse, - AppConfigurationListResponse, - AppConfigurationDeleteResponse, -) -``` - -Methods: - -- client.magic_transit.sites.sites.app_configuration.create(site_id, \*, account_id, \*\*params) -> Optional -- client.magic_transit.sites.sites.app_configuration.update(app_config_id, \*, account_id, site_id, \*\*params) -> Optional -- client.magic_transit.sites.sites.app_configuration.list(site_id, \*, account_id) -> SyncSinglePage[AppConfigurationListResponse] -- client.magic_transit.sites.sites.app_configuration.delete(app_config_id, \*, account_id, site_id) -> Optional - ## Connectors Types: diff --git a/src/cloudflare/resources/magic_transit/sites/__init__.py b/src/cloudflare/resources/magic_transit/sites/__init__.py index 8a2a07f48db..91db8e47261 100644 --- a/src/cloudflare/resources/magic_transit/sites/__init__.py +++ b/src/cloudflare/resources/magic_transit/sites/__init__.py @@ -32,8 +32,22 @@ SitesResourceWithStreamingResponse, AsyncSitesResourceWithStreamingResponse, ) +from .app_configuration import ( + AppConfigurationResource, + AsyncAppConfigurationResource, + AppConfigurationResourceWithRawResponse, + AsyncAppConfigurationResourceWithRawResponse, + AppConfigurationResourceWithStreamingResponse, + AsyncAppConfigurationResourceWithStreamingResponse, +) __all__ = [ + "AppConfigurationResource", + "AsyncAppConfigurationResource", + "AppConfigurationResourceWithRawResponse", + "AsyncAppConfigurationResourceWithRawResponse", + "AppConfigurationResourceWithStreamingResponse", + "AsyncAppConfigurationResourceWithStreamingResponse", "ACLsResource", "AsyncACLsResource", "ACLsResourceWithRawResponse", diff --git a/src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py b/src/cloudflare/resources/magic_transit/sites/app_configuration.py similarity index 97% rename from src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py rename to src/cloudflare/resources/magic_transit/sites/app_configuration.py index 7e61a793203..ab626ae44b5 100644 --- a/src/cloudflare/resources/magic_transit/sites/sites/app_configuration.py +++ b/src/cloudflare/resources/magic_transit/sites/app_configuration.py @@ -6,31 +6,31 @@ 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 ( required_args, 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 ( +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( AsyncPaginator, make_request_options, ) -from .....types.magic_transit.sites.sites import app_configuration_create_params, app_configuration_update_params -from .....types.magic_transit.sites.sites.app_configuration_list_response import AppConfigurationListResponse -from .....types.magic_transit.sites.sites.app_configuration_create_response import AppConfigurationCreateResponse -from .....types.magic_transit.sites.sites.app_configuration_delete_response import AppConfigurationDeleteResponse -from .....types.magic_transit.sites.sites.app_configuration_update_response import AppConfigurationUpdateResponse +from ....types.magic_transit.sites import app_configuration_create_params, app_configuration_update_params +from ....types.magic_transit.sites.app_configuration_list_response import AppConfigurationListResponse +from ....types.magic_transit.sites.app_configuration_create_response import AppConfigurationCreateResponse +from ....types.magic_transit.sites.app_configuration_delete_response import AppConfigurationDeleteResponse +from ....types.magic_transit.sites.app_configuration_update_response import AppConfigurationUpdateResponse __all__ = ["AppConfigurationResource", "AsyncAppConfigurationResource"] diff --git a/src/cloudflare/resources/magic_transit/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites.py index c8a502834c7..2c70cc30a7d 100644 --- a/src/cloudflare/resources/magic_transit/sites/sites.py +++ b/src/cloudflare/resources/magic_transit/sites/sites.py @@ -30,15 +30,6 @@ WANsResourceWithStreamingResponse, AsyncWANsResourceWithStreamingResponse, ) -from .sites import ( - SitesResource, - AsyncSitesResource, - SitesResourceWithRawResponse, - AsyncSitesResourceWithRawResponse, - SitesResourceWithStreamingResponse, - AsyncSitesResourceWithStreamingResponse, - sites, -) from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ...._utils import ( maybe_transform, @@ -58,6 +49,14 @@ AsyncPaginator, make_request_options, ) +from .app_configuration import ( + AppConfigurationResource, + AsyncAppConfigurationResource, + AppConfigurationResourceWithRawResponse, + AsyncAppConfigurationResourceWithRawResponse, + AppConfigurationResourceWithStreamingResponse, + AsyncAppConfigurationResourceWithStreamingResponse, +) from ....types.magic_transit import ( site_edit_params, site_list_params, @@ -71,6 +70,10 @@ class SitesResource(SyncAPIResource): + @cached_property + def app_configuration(self) -> AppConfigurationResource: + return AppConfigurationResource(self._client) + @cached_property def acls(self) -> ACLsResource: return ACLsResource(self._client) @@ -83,10 +86,6 @@ def lans(self) -> LANsResource: def wans(self) -> WANsResource: return WANsResource(self._client) - @cached_property - def sites(self) -> sites.SitesResource: - return SitesResource(self._client) - @cached_property def with_raw_response(self) -> SitesResourceWithRawResponse: return SitesResourceWithRawResponse(self) @@ -432,6 +431,10 @@ def get( class AsyncSitesResource(AsyncAPIResource): + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResource: + return AsyncAppConfigurationResource(self._client) + @cached_property def acls(self) -> AsyncACLsResource: return AsyncACLsResource(self._client) @@ -444,10 +447,6 @@ def lans(self) -> AsyncLANsResource: def wans(self) -> AsyncWANsResource: return AsyncWANsResource(self._client) - @cached_property - def sites(self) -> sites.AsyncSitesResource: - return AsyncSitesResource(self._client) - @cached_property def with_raw_response(self) -> AsyncSitesResourceWithRawResponse: return AsyncSitesResourceWithRawResponse(self) @@ -815,6 +814,10 @@ def __init__(self, sites: SitesResource) -> None: sites.get, ) + @cached_property + def app_configuration(self) -> AppConfigurationResourceWithRawResponse: + return AppConfigurationResourceWithRawResponse(self._sites.app_configuration) + @cached_property def acls(self) -> ACLsResourceWithRawResponse: return ACLsResourceWithRawResponse(self._sites.acls) @@ -827,10 +830,6 @@ def lans(self) -> LANsResourceWithRawResponse: def wans(self) -> WANsResourceWithRawResponse: return WANsResourceWithRawResponse(self._sites.wans) - @cached_property - def sites(self) -> SitesResourceWithRawResponse: - return SitesResourceWithRawResponse(self._sites.sites) - class AsyncSitesResourceWithRawResponse: def __init__(self, sites: AsyncSitesResource) -> None: @@ -855,6 +854,10 @@ def __init__(self, sites: AsyncSitesResource) -> None: sites.get, ) + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResourceWithRawResponse: + return AsyncAppConfigurationResourceWithRawResponse(self._sites.app_configuration) + @cached_property def acls(self) -> AsyncACLsResourceWithRawResponse: return AsyncACLsResourceWithRawResponse(self._sites.acls) @@ -867,10 +870,6 @@ def lans(self) -> AsyncLANsResourceWithRawResponse: def wans(self) -> AsyncWANsResourceWithRawResponse: return AsyncWANsResourceWithRawResponse(self._sites.wans) - @cached_property - def sites(self) -> AsyncSitesResourceWithRawResponse: - return AsyncSitesResourceWithRawResponse(self._sites.sites) - class SitesResourceWithStreamingResponse: def __init__(self, sites: SitesResource) -> None: @@ -895,6 +894,10 @@ def __init__(self, sites: SitesResource) -> None: sites.get, ) + @cached_property + def app_configuration(self) -> AppConfigurationResourceWithStreamingResponse: + return AppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) + @cached_property def acls(self) -> ACLsResourceWithStreamingResponse: return ACLsResourceWithStreamingResponse(self._sites.acls) @@ -907,10 +910,6 @@ def lans(self) -> LANsResourceWithStreamingResponse: def wans(self) -> WANsResourceWithStreamingResponse: return WANsResourceWithStreamingResponse(self._sites.wans) - @cached_property - def sites(self) -> SitesResourceWithStreamingResponse: - return SitesResourceWithStreamingResponse(self._sites.sites) - class AsyncSitesResourceWithStreamingResponse: def __init__(self, sites: AsyncSitesResource) -> None: @@ -935,6 +934,10 @@ def __init__(self, sites: AsyncSitesResource) -> None: sites.get, ) + @cached_property + def app_configuration(self) -> AsyncAppConfigurationResourceWithStreamingResponse: + return AsyncAppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) + @cached_property def acls(self) -> AsyncACLsResourceWithStreamingResponse: return AsyncACLsResourceWithStreamingResponse(self._sites.acls) @@ -946,7 +949,3 @@ def lans(self) -> AsyncLANsResourceWithStreamingResponse: @cached_property def wans(self) -> AsyncWANsResourceWithStreamingResponse: return AsyncWANsResourceWithStreamingResponse(self._sites.wans) - - @cached_property - def sites(self) -> AsyncSitesResourceWithStreamingResponse: - return AsyncSitesResourceWithStreamingResponse(self._sites.sites) diff --git a/src/cloudflare/resources/magic_transit/sites/sites/__init__.py b/src/cloudflare/resources/magic_transit/sites/sites/__init__.py deleted file mode 100644 index 01aea158619..00000000000 --- a/src/cloudflare/resources/magic_transit/sites/sites/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .sites import ( - SitesResource, - AsyncSitesResource, - SitesResourceWithRawResponse, - AsyncSitesResourceWithRawResponse, - SitesResourceWithStreamingResponse, - AsyncSitesResourceWithStreamingResponse, -) -from .app_configuration import ( - AppConfigurationResource, - AsyncAppConfigurationResource, - AppConfigurationResourceWithRawResponse, - AsyncAppConfigurationResourceWithRawResponse, - AppConfigurationResourceWithStreamingResponse, - AsyncAppConfigurationResourceWithStreamingResponse, -) - -__all__ = [ - "AppConfigurationResource", - "AsyncAppConfigurationResource", - "AppConfigurationResourceWithRawResponse", - "AsyncAppConfigurationResourceWithRawResponse", - "AppConfigurationResourceWithStreamingResponse", - "AsyncAppConfigurationResourceWithStreamingResponse", - "SitesResource", - "AsyncSitesResource", - "SitesResourceWithRawResponse", - "AsyncSitesResourceWithRawResponse", - "SitesResourceWithStreamingResponse", - "AsyncSitesResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/magic_transit/sites/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites/sites.py deleted file mode 100644 index 04377a5750e..00000000000 --- a/src/cloudflare/resources/magic_transit/sites/sites/sites.py +++ /dev/null @@ -1,80 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from .app_configuration import ( - AppConfigurationResource, - AsyncAppConfigurationResource, - AppConfigurationResourceWithRawResponse, - AsyncAppConfigurationResourceWithRawResponse, - AppConfigurationResourceWithStreamingResponse, - AsyncAppConfigurationResourceWithStreamingResponse, -) - -__all__ = ["SitesResource", "AsyncSitesResource"] - - -class SitesResource(SyncAPIResource): - @cached_property - def app_configuration(self) -> AppConfigurationResource: - return AppConfigurationResource(self._client) - - @cached_property - def with_raw_response(self) -> SitesResourceWithRawResponse: - return SitesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> SitesResourceWithStreamingResponse: - return SitesResourceWithStreamingResponse(self) - - -class AsyncSitesResource(AsyncAPIResource): - @cached_property - def app_configuration(self) -> AsyncAppConfigurationResource: - return AsyncAppConfigurationResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncSitesResourceWithRawResponse: - return AsyncSitesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncSitesResourceWithStreamingResponse: - return AsyncSitesResourceWithStreamingResponse(self) - - -class SitesResourceWithRawResponse: - def __init__(self, sites: SitesResource) -> None: - self._sites = sites - - @cached_property - def app_configuration(self) -> AppConfigurationResourceWithRawResponse: - return AppConfigurationResourceWithRawResponse(self._sites.app_configuration) - - -class AsyncSitesResourceWithRawResponse: - def __init__(self, sites: AsyncSitesResource) -> None: - self._sites = sites - - @cached_property - def app_configuration(self) -> AsyncAppConfigurationResourceWithRawResponse: - return AsyncAppConfigurationResourceWithRawResponse(self._sites.app_configuration) - - -class SitesResourceWithStreamingResponse: - def __init__(self, sites: SitesResource) -> None: - self._sites = sites - - @cached_property - def app_configuration(self) -> AppConfigurationResourceWithStreamingResponse: - return AppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) - - -class AsyncSitesResourceWithStreamingResponse: - def __init__(self, sites: AsyncSitesResource) -> None: - self._sites = sites - - @cached_property - def app_configuration(self) -> AsyncAppConfigurationResourceWithStreamingResponse: - return AsyncAppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) diff --git a/src/cloudflare/types/magic_transit/sites/__init__.py b/src/cloudflare/types/magic_transit/sites/__init__.py index 38f592bb4e6..9ce9579033c 100644 --- a/src/cloudflare/types/magic_transit/sites/__init__.py +++ b/src/cloudflare/types/magic_transit/sites/__init__.py @@ -33,3 +33,9 @@ from .acl_configuration_param import ACLConfigurationParam as ACLConfigurationParam from .lan_static_addressing_param import LANStaticAddressingParam as LANStaticAddressingParam from .wan_static_addressing_param import WANStaticAddressingParam as WANStaticAddressingParam +from .app_configuration_create_params import AppConfigurationCreateParams as AppConfigurationCreateParams +from .app_configuration_list_response import AppConfigurationListResponse as AppConfigurationListResponse +from .app_configuration_update_params import AppConfigurationUpdateParams as AppConfigurationUpdateParams +from .app_configuration_create_response import AppConfigurationCreateResponse as AppConfigurationCreateResponse +from .app_configuration_delete_response import AppConfigurationDeleteResponse as AppConfigurationDeleteResponse +from .app_configuration_update_response import AppConfigurationUpdateResponse as AppConfigurationUpdateResponse diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py b/src/cloudflare/types/magic_transit/sites/app_configuration_create_params.py similarity index 100% rename from src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_params.py rename to src/cloudflare/types/magic_transit/sites/app_configuration_create_params.py diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py b/src/cloudflare/types/magic_transit/sites/app_configuration_create_response.py similarity index 94% rename from src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py rename to src/cloudflare/types/magic_transit/sites/app_configuration_create_response.py index 3b1c31a4251..84e52fc8403 100644 --- a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_create_response.py +++ b/src/cloudflare/types/magic_transit/sites/app_configuration_create_response.py @@ -2,7 +2,7 @@ from typing import Optional -from ....._models import BaseModel +from ...._models import BaseModel __all__ = ["AppConfigurationCreateResponse"] diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py b/src/cloudflare/types/magic_transit/sites/app_configuration_delete_response.py similarity index 94% rename from src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py rename to src/cloudflare/types/magic_transit/sites/app_configuration_delete_response.py index 1c5daf9c4fc..bffa4cb833d 100644 --- a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_delete_response.py +++ b/src/cloudflare/types/magic_transit/sites/app_configuration_delete_response.py @@ -2,7 +2,7 @@ from typing import Optional -from ....._models import BaseModel +from ...._models import BaseModel __all__ = ["AppConfigurationDeleteResponse"] diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py b/src/cloudflare/types/magic_transit/sites/app_configuration_list_response.py similarity index 94% rename from src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py rename to src/cloudflare/types/magic_transit/sites/app_configuration_list_response.py index 9c508e2a035..15f8a52f3eb 100644 --- a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_list_response.py +++ b/src/cloudflare/types/magic_transit/sites/app_configuration_list_response.py @@ -2,7 +2,7 @@ from typing import Optional -from ....._models import BaseModel +from ...._models import BaseModel __all__ = ["AppConfigurationListResponse"] diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py b/src/cloudflare/types/magic_transit/sites/app_configuration_update_params.py similarity index 100% rename from src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_params.py rename to src/cloudflare/types/magic_transit/sites/app_configuration_update_params.py diff --git a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py b/src/cloudflare/types/magic_transit/sites/app_configuration_update_response.py similarity index 94% rename from src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py rename to src/cloudflare/types/magic_transit/sites/app_configuration_update_response.py index 01ef039b4e6..4cf34ba7780 100644 --- a/src/cloudflare/types/magic_transit/sites/sites/app_configuration_update_response.py +++ b/src/cloudflare/types/magic_transit/sites/app_configuration_update_response.py @@ -2,7 +2,7 @@ from typing import Optional -from ....._models import BaseModel +from ...._models import BaseModel __all__ = ["AppConfigurationUpdateResponse"] diff --git a/src/cloudflare/types/magic_transit/sites/sites/__init__.py b/src/cloudflare/types/magic_transit/sites/sites/__init__.py deleted file mode 100644 index 4b8fd25c1d0..00000000000 --- a/src/cloudflare/types/magic_transit/sites/sites/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .app_configuration_create_params import AppConfigurationCreateParams as AppConfigurationCreateParams -from .app_configuration_list_response import AppConfigurationListResponse as AppConfigurationListResponse -from .app_configuration_update_params import AppConfigurationUpdateParams as AppConfigurationUpdateParams -from .app_configuration_create_response import AppConfigurationCreateResponse as AppConfigurationCreateResponse -from .app_configuration_delete_response import AppConfigurationDeleteResponse as AppConfigurationDeleteResponse -from .app_configuration_update_response import AppConfigurationUpdateResponse as AppConfigurationUpdateResponse diff --git a/tests/api_resources/magic_transit/sites/sites/__init__.py b/tests/api_resources/magic_transit/sites/sites/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/magic_transit/sites/sites/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/magic_transit/sites/sites/test_app_configuration.py b/tests/api_resources/magic_transit/sites/test_app_configuration.py similarity index 83% rename from tests/api_resources/magic_transit/sites/sites/test_app_configuration.py rename to tests/api_resources/magic_transit/sites/test_app_configuration.py index 65670e86460..8effe5be706 100644 --- a/tests/api_resources/magic_transit/sites/sites/test_app_configuration.py +++ b/tests/api_resources/magic_transit/sites/test_app_configuration.py @@ -10,7 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.magic_transit.sites.sites import ( +from cloudflare.types.magic_transit.sites import ( AppConfigurationListResponse, AppConfigurationCreateResponse, AppConfigurationDeleteResponse, @@ -25,7 +25,7 @@ class TestAppConfiguration: @parametrize def test_method_create_overload_1(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.create( + app_configuration = client.magic_transit.sites.app_configuration.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", account_app_id="ac60d3d0435248289d446cedd870bcf4", @@ -34,7 +34,7 @@ def test_method_create_overload_1(self, client: Cloudflare) -> None: @parametrize def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + response = client.magic_transit.sites.app_configuration.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", account_app_id="ac60d3d0435248289d446cedd870bcf4", @@ -47,7 +47,7 @@ def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + with client.magic_transit.sites.app_configuration.with_streaming_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", account_app_id="ac60d3d0435248289d446cedd870bcf4", @@ -63,14 +63,14 @@ def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: @parametrize def test_path_params_create_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + client.magic_transit.sites.app_configuration.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", account_app_id="ac60d3d0435248289d446cedd870bcf4", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + client.magic_transit.sites.app_configuration.with_raw_response.create( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", account_app_id="ac60d3d0435248289d446cedd870bcf4", @@ -78,7 +78,7 @@ def test_path_params_create_overload_1(self, client: Cloudflare) -> None: @parametrize def test_method_create_overload_2(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.create( + app_configuration = client.magic_transit.sites.app_configuration.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", managed_app_id="cloudflare", @@ -87,7 +87,7 @@ def test_method_create_overload_2(self, client: Cloudflare) -> None: @parametrize def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + response = client.magic_transit.sites.app_configuration.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", managed_app_id="cloudflare", @@ -100,7 +100,7 @@ def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + with client.magic_transit.sites.app_configuration.with_streaming_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", managed_app_id="cloudflare", @@ -116,14 +116,14 @@ def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: @parametrize def test_path_params_create_overload_2(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + client.magic_transit.sites.app_configuration.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", managed_app_id="cloudflare", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + client.magic_transit.sites.app_configuration.with_raw_response.create( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", managed_app_id="cloudflare", @@ -131,7 +131,7 @@ def test_path_params_create_overload_2(self, client: Cloudflare) -> None: @parametrize def test_method_update_overload_1(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.update( + app_configuration = client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -141,7 +141,7 @@ def test_method_update_overload_1(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -155,7 +155,7 @@ def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + with client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -172,7 +172,7 @@ def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: @parametrize def test_path_params_update_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -180,7 +180,7 @@ def test_path_params_update_overload_1(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -188,7 +188,7 @@ def test_path_params_update_overload_1(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -197,7 +197,7 @@ def test_path_params_update_overload_1(self, client: Cloudflare) -> None: @parametrize def test_method_update_overload_2(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.update( + app_configuration = client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -207,7 +207,7 @@ def test_method_update_overload_2(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -221,7 +221,7 @@ def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + with client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -238,7 +238,7 @@ def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: @parametrize def test_path_params_update_overload_2(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -246,7 +246,7 @@ def test_path_params_update_overload_2(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -254,7 +254,7 @@ def test_path_params_update_overload_2(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -263,7 +263,7 @@ def test_path_params_update_overload_2(self, client: Cloudflare) -> None: @parametrize def test_method_update_overload_3(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.update( + app_configuration = client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -273,7 +273,7 @@ def test_method_update_overload_3(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -287,7 +287,7 @@ def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + with client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -304,7 +304,7 @@ def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: @parametrize def test_path_params_update_overload_3(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -312,7 +312,7 @@ def test_path_params_update_overload_3(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -320,7 +320,7 @@ def test_path_params_update_overload_3(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -329,7 +329,7 @@ def test_path_params_update_overload_3(self, client: Cloudflare) -> None: @parametrize def test_method_update_overload_4(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.update( + app_configuration = client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -339,7 +339,7 @@ def test_method_update_overload_4(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -353,7 +353,7 @@ def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + with client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -370,7 +370,7 @@ def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: @parametrize def test_path_params_update_overload_4(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -378,7 +378,7 @@ def test_path_params_update_overload_4(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -386,7 +386,7 @@ def test_path_params_update_overload_4(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -395,7 +395,7 @@ def test_path_params_update_overload_4(self, client: Cloudflare) -> None: @parametrize def test_method_update_overload_5(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.update( + app_configuration = client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -406,7 +406,7 @@ def test_method_update_overload_5(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -421,7 +421,7 @@ def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + with client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -439,7 +439,7 @@ def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: @parametrize def test_path_params_update_overload_5(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -448,7 +448,7 @@ def test_path_params_update_overload_5(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -457,7 +457,7 @@ def test_path_params_update_overload_5(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -467,7 +467,7 @@ def test_path_params_update_overload_5(self, client: Cloudflare) -> None: @parametrize def test_method_update_overload_6(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.update( + app_configuration = client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -478,7 +478,7 @@ def test_method_update_overload_6(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -493,7 +493,7 @@ def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + with client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -511,7 +511,7 @@ def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: @parametrize def test_path_params_update_overload_6(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -520,7 +520,7 @@ def test_path_params_update_overload_6(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -529,7 +529,7 @@ def test_path_params_update_overload_6(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -539,7 +539,7 @@ def test_path_params_update_overload_6(self, client: Cloudflare) -> None: @parametrize def test_method_list(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.list( + app_configuration = client.magic_transit.sites.app_configuration.list( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -547,7 +547,7 @@ def test_method_list(self, client: Cloudflare) -> None: @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + response = client.magic_transit.sites.app_configuration.with_raw_response.list( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -559,7 +559,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.list( + with client.magic_transit.sites.app_configuration.with_streaming_response.list( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: @@ -574,20 +574,20 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: @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.magic_transit.sites.sites.app_configuration.with_raw_response.list( + client.magic_transit.sites.app_configuration.with_raw_response.list( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + client.magic_transit.sites.app_configuration.with_raw_response.list( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize def test_method_delete(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.sites.app_configuration.delete( + app_configuration = client.magic_transit.sites.app_configuration.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -596,7 +596,7 @@ def test_method_delete(self, client: Cloudflare) -> None: @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + response = client.magic_transit.sites.app_configuration.with_raw_response.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -609,7 +609,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.magic_transit.sites.sites.app_configuration.with_streaming_response.delete( + with client.magic_transit.sites.app_configuration.with_streaming_response.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -625,21 +625,21 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: @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.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + client.magic_transit.sites.app_configuration.with_raw_response.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + client.magic_transit.sites.app_configuration.with_raw_response.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + client.magic_transit.sites.app_configuration.with_raw_response.delete( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -651,7 +651,7 @@ class TestAsyncAppConfiguration: @parametrize async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.create( + app_configuration = await async_client.magic_transit.sites.app_configuration.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", account_app_id="ac60d3d0435248289d446cedd870bcf4", @@ -660,7 +660,7 @@ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> @parametrize async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", account_app_id="ac60d3d0435248289d446cedd870bcf4", @@ -673,7 +673,7 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar @parametrize async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", account_app_id="ac60d3d0435248289d446cedd870bcf4", @@ -689,14 +689,14 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo @parametrize async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + await async_client.magic_transit.sites.app_configuration.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", account_app_id="ac60d3d0435248289d446cedd870bcf4", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + await async_client.magic_transit.sites.app_configuration.with_raw_response.create( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", account_app_id="ac60d3d0435248289d446cedd870bcf4", @@ -704,7 +704,7 @@ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare @parametrize async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.create( + app_configuration = await async_client.magic_transit.sites.app_configuration.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", managed_app_id="cloudflare", @@ -713,7 +713,7 @@ async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> @parametrize async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", managed_app_id="cloudflare", @@ -726,7 +726,7 @@ async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflar @parametrize async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.create( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", managed_app_id="cloudflare", @@ -742,14 +742,14 @@ async def test_streaming_response_create_overload_2(self, async_client: AsyncClo @parametrize async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + await async_client.magic_transit.sites.app_configuration.with_raw_response.create( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", managed_app_id="cloudflare", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.create( + await async_client.magic_transit.sites.app_configuration.with_raw_response.create( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", managed_app_id="cloudflare", @@ -757,7 +757,7 @@ async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare @parametrize async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + app_configuration = await async_client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -767,7 +767,7 @@ async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> @parametrize async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -781,7 +781,7 @@ async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflar @parametrize async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -798,7 +798,7 @@ async def test_streaming_response_update_overload_1(self, async_client: AsyncClo @parametrize async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -806,7 +806,7 @@ async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -814,7 +814,7 @@ async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -823,7 +823,7 @@ async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare @parametrize async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + app_configuration = await async_client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -833,7 +833,7 @@ async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> @parametrize async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -847,7 +847,7 @@ async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflar @parametrize async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -864,7 +864,7 @@ async def test_streaming_response_update_overload_2(self, async_client: AsyncClo @parametrize async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -872,7 +872,7 @@ async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -880,7 +880,7 @@ async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -889,7 +889,7 @@ async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare @parametrize async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + app_configuration = await async_client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -899,7 +899,7 @@ async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> @parametrize async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -913,7 +913,7 @@ async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflar @parametrize async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -930,7 +930,7 @@ async def test_streaming_response_update_overload_3(self, async_client: AsyncClo @parametrize async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -938,7 +938,7 @@ async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -946,7 +946,7 @@ async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -955,7 +955,7 @@ async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare @parametrize async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + app_configuration = await async_client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -965,7 +965,7 @@ async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> @parametrize async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -979,7 +979,7 @@ async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflar @parametrize async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -996,7 +996,7 @@ async def test_streaming_response_update_overload_4(self, async_client: AsyncClo @parametrize async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1004,7 +1004,7 @@ async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -1012,7 +1012,7 @@ async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1021,7 +1021,7 @@ async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare @parametrize async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + app_configuration = await async_client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1032,7 +1032,7 @@ async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> @parametrize async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1047,7 +1047,7 @@ async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflar @parametrize async def test_streaming_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1065,7 +1065,7 @@ async def test_streaming_response_update_overload_5(self, async_client: AsyncClo @parametrize async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1074,7 +1074,7 @@ async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -1083,7 +1083,7 @@ async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1093,7 +1093,7 @@ async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare @parametrize async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.update( + app_configuration = await async_client.magic_transit.sites.app_configuration.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1104,7 +1104,7 @@ async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> @parametrize async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1119,7 +1119,7 @@ async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflar @parametrize async def test_streaming_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.update( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1137,7 +1137,7 @@ async def test_streaming_response_update_overload_6(self, async_client: AsyncClo @parametrize async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1146,7 +1146,7 @@ async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", @@ -1155,7 +1155,7 @@ async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.update( + await async_client.magic_transit.sites.app_configuration.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1165,7 +1165,7 @@ async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.list( + app_configuration = await async_client.magic_transit.sites.app_configuration.list( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -1173,7 +1173,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.list( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -1185,7 +1185,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.list( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.list( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: @@ -1200,20 +1200,20 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N @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.magic_transit.sites.sites.app_configuration.with_raw_response.list( + await async_client.magic_transit.sites.app_configuration.with_raw_response.list( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.list( + await async_client.magic_transit.sites.app_configuration.with_raw_response.list( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.sites.app_configuration.delete( + app_configuration = await async_client.magic_transit.sites.app_configuration.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1222,7 +1222,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + response = await async_client.magic_transit.sites.app_configuration.with_raw_response.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1235,7 +1235,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.sites.app_configuration.with_streaming_response.delete( + async with async_client.magic_transit.sites.app_configuration.with_streaming_response.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -1251,21 +1251,21 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> @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.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + await async_client.magic_transit.sites.app_configuration.with_raw_response.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="", site_id="023e105f4ecef8ad9ca31a8372d0c353", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + await async_client.magic_transit.sites.app_configuration.with_raw_response.delete( "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.sites.app_configuration.with_raw_response.delete( + await async_client.magic_transit.sites.app_configuration.with_raw_response.delete( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", From bd08f43b49292706755e2772c876ae1a8cb39dc1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:59:14 +0000 Subject: [PATCH 298/532] feat(api): OpenAPI spec update via Stainless API (#779) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 036bd6a320f..5d67bcc6bdc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5be95789763c3b4b655f44e48b2d615e059cdfb5a52d62a7e084c84ffa039fe2.yml From 2d617ad49431032b211bb8c5aeb1ca76463866ef Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 23:01:23 +0000 Subject: [PATCH 299/532] feat(api): OpenAPI spec update via Stainless API (#780) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5d67bcc6bdc..036bd6a320f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5be95789763c3b4b655f44e48b2d615e059cdfb5a52d62a7e084c84ffa039fe2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml From f5ecfb2c0e890526d0166fbc300e670659aaaf26 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 23:43:38 +0000 Subject: [PATCH 300/532] feat(api): OpenAPI spec update via Stainless API (#781) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 036bd6a320f..3050b50ac78 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dcd6da6d54ab84199b2a5a342783a5388aa6ea0f460f8ad821f5b5dc60b3726e.yml From c8dc5e30a180643fbf269ce5cbb276d91db36373 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 02:39:38 +0000 Subject: [PATCH 301/532] feat(api): update via SDK Studio (#782) --- .../alerting/destinations/test_pagerduty.py | 48 +++++++++++++++ .../alerting/destinations/test_webhooks.py | 60 +++++++++++++++++++ tests/api_resources/alerting/test_policies.py | 60 +++++++++++++++++++ 3 files changed, 168 insertions(+) diff --git a/tests/api_resources/alerting/destinations/test_pagerduty.py b/tests/api_resources/alerting/destinations/test_pagerduty.py index cded507dd68..a0b32fc9ce4 100644 --- a/tests/api_resources/alerting/destinations/test_pagerduty.py +++ b/tests/api_resources/alerting/destinations/test_pagerduty.py @@ -22,6 +22,9 @@ class TestPagerduty: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize def test_method_create(self, client: Cloudflare) -> None: pagerduty = client.alerting.destinations.pagerduty.create( @@ -29,6 +32,9 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.alerting.destinations.pagerduty.with_raw_response.create( @@ -40,6 +46,9 @@ def test_raw_response_create(self, client: Cloudflare) -> None: pagerduty = response.parse() assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.alerting.destinations.pagerduty.with_streaming_response.create( @@ -53,6 +62,9 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @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 ''"): @@ -136,6 +148,9 @@ def test_path_params_get(self, client: Cloudflare) -> None: account_id="", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize def test_method_link(self, client: Cloudflare) -> None: pagerduty = client.alerting.destinations.pagerduty.link( @@ -144,6 +159,9 @@ def test_method_link(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize def test_raw_response_link(self, client: Cloudflare) -> None: response = client.alerting.destinations.pagerduty.with_raw_response.link( @@ -156,6 +174,9 @@ def test_raw_response_link(self, client: Cloudflare) -> None: pagerduty = response.parse() assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize def test_streaming_response_link(self, client: Cloudflare) -> None: with client.alerting.destinations.pagerduty.with_streaming_response.link( @@ -170,6 +191,9 @@ def test_streaming_response_link(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize def test_path_params_link(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -188,6 +212,9 @@ def test_path_params_link(self, client: Cloudflare) -> None: class TestAsyncPagerduty: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: pagerduty = await async_client.alerting.destinations.pagerduty.create( @@ -195,6 +222,9 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.alerting.destinations.pagerduty.with_raw_response.create( @@ -206,6 +236,9 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: pagerduty = await response.parse() assert_matches_type(Optional[PagerdutyCreateResponse], pagerduty, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.alerting.destinations.pagerduty.with_streaming_response.create( @@ -219,6 +252,9 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @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 ''"): @@ -302,6 +338,9 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: account_id="", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize async def test_method_link(self, async_client: AsyncCloudflare) -> None: pagerduty = await async_client.alerting.destinations.pagerduty.link( @@ -310,6 +349,9 @@ async def test_method_link(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize async def test_raw_response_link(self, async_client: AsyncCloudflare) -> None: response = await async_client.alerting.destinations.pagerduty.with_raw_response.link( @@ -322,6 +364,9 @@ async def test_raw_response_link(self, async_client: AsyncCloudflare) -> None: pagerduty = await response.parse() assert_matches_type(Optional[PagerdutyLinkResponse], pagerduty, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize async def test_streaming_response_link(self, async_client: AsyncCloudflare) -> None: async with async_client.alerting.destinations.pagerduty.with_streaming_response.link( @@ -336,6 +381,9 @@ async def test_streaming_response_link(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4285" + ) @parametrize async def test_path_params_link(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): diff --git a/tests/api_resources/alerting/destinations/test_webhooks.py b/tests/api_resources/alerting/destinations/test_webhooks.py index 29460dcbc01..3392d832715 100644 --- a/tests/api_resources/alerting/destinations/test_webhooks.py +++ b/tests/api_resources/alerting/destinations/test_webhooks.py @@ -23,6 +23,9 @@ class TestWebhooks: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_method_create(self, client: Cloudflare) -> None: webhook = client.alerting.destinations.webhooks.create( @@ -32,6 +35,9 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: webhook = client.alerting.destinations.webhooks.create( @@ -42,6 +48,9 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.alerting.destinations.webhooks.with_raw_response.create( @@ -55,6 +64,9 @@ def test_raw_response_create(self, client: Cloudflare) -> None: webhook = response.parse() assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.alerting.destinations.webhooks.with_streaming_response.create( @@ -70,6 +82,9 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @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 ''"): @@ -79,6 +94,9 @@ def test_path_params_create(self, client: Cloudflare) -> None: url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_method_update(self, client: Cloudflare) -> None: webhook = client.alerting.destinations.webhooks.update( @@ -89,6 +107,9 @@ def test_method_update(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: webhook = client.alerting.destinations.webhooks.update( @@ -100,6 +121,9 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.alerting.destinations.webhooks.with_raw_response.update( @@ -114,6 +138,9 @@ def test_raw_response_update(self, client: Cloudflare) -> None: webhook = response.parse() assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.alerting.destinations.webhooks.with_streaming_response.update( @@ -130,6 +157,9 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @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 ''"): @@ -286,6 +316,9 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncWebhooks: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: webhook = await async_client.alerting.destinations.webhooks.create( @@ -295,6 +328,9 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: webhook = await async_client.alerting.destinations.webhooks.create( @@ -305,6 +341,9 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.alerting.destinations.webhooks.with_raw_response.create( @@ -318,6 +357,9 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: webhook = await response.parse() assert_matches_type(Optional[WebhookCreateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.alerting.destinations.webhooks.with_streaming_response.create( @@ -333,6 +375,9 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @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 ''"): @@ -342,6 +387,9 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: url="https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: webhook = await async_client.alerting.destinations.webhooks.update( @@ -352,6 +400,9 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: webhook = await async_client.alerting.destinations.webhooks.update( @@ -363,6 +414,9 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.alerting.destinations.webhooks.with_raw_response.update( @@ -377,6 +431,9 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: webhook = await response.parse() assert_matches_type(Optional[WebhookUpdateResponse], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.alerting.destinations.webhooks.with_streaming_response.update( @@ -393,6 +450,9 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @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 ''"): diff --git a/tests/api_resources/alerting/test_policies.py b/tests/api_resources/alerting/test_policies.py index 2eb84a45b54..4814ba6a9d2 100644 --- a/tests/api_resources/alerting/test_policies.py +++ b/tests/api_resources/alerting/test_policies.py @@ -23,6 +23,9 @@ class TestPolicies: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_method_create(self, client: Cloudflare) -> None: policy = client.alerting.policies.create( @@ -38,6 +41,9 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: policy = client.alerting.policies.create( @@ -96,6 +102,9 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.alerting.policies.with_raw_response.create( @@ -115,6 +124,9 @@ def test_raw_response_create(self, client: Cloudflare) -> None: policy = response.parse() assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.alerting.policies.with_streaming_response.create( @@ -136,6 +148,9 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @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 ''"): @@ -151,6 +166,9 @@ def test_path_params_create(self, client: Cloudflare) -> None: name="SSL Notification Event Policy", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_method_update(self, client: Cloudflare) -> None: policy = client.alerting.policies.update( @@ -159,6 +177,9 @@ def test_method_update(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: policy = client.alerting.policies.update( @@ -218,6 +239,9 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.alerting.policies.with_raw_response.update( @@ -230,6 +254,9 @@ def test_raw_response_update(self, client: Cloudflare) -> None: policy = response.parse() assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.alerting.policies.with_streaming_response.update( @@ -244,6 +271,9 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @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 ''"): @@ -396,6 +426,9 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncPolicies: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: policy = await async_client.alerting.policies.create( @@ -411,6 +444,9 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: policy = await async_client.alerting.policies.create( @@ -469,6 +505,9 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.alerting.policies.with_raw_response.create( @@ -488,6 +527,9 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: policy = await response.parse() assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.alerting.policies.with_streaming_response.create( @@ -509,6 +551,9 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @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 ''"): @@ -524,6 +569,9 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: name="SSL Notification Event Policy", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: policy = await async_client.alerting.policies.update( @@ -532,6 +580,9 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: policy = await async_client.alerting.policies.update( @@ -591,6 +642,9 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.alerting.policies.with_raw_response.update( @@ -603,6 +657,9 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: policy = await response.parse() assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.alerting.policies.with_streaming_response.update( @@ -617,6 +674,9 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @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 ''"): From f30af8597b0de54d7ca199a713e7e66f7fc16ec5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 02:52:41 +0000 Subject: [PATCH 302/532] feat(api): update via SDK Studio (#783) --- .../alerting/destinations/test_webhooks.py | 24 +++ .../sites/test_app_configuration.py | 192 ++++++++++++++++++ .../api_resources/magic_transit/test_apps.py | 168 +++++++++++++++ 3 files changed, 384 insertions(+) diff --git a/tests/api_resources/alerting/destinations/test_webhooks.py b/tests/api_resources/alerting/destinations/test_webhooks.py index 3392d832715..bf8bc07acdf 100644 --- a/tests/api_resources/alerting/destinations/test_webhooks.py +++ b/tests/api_resources/alerting/destinations/test_webhooks.py @@ -264,6 +264,9 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_method_get(self, client: Cloudflare) -> None: webhook = client.alerting.destinations.webhooks.get( @@ -272,6 +275,9 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[Webhooks], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.alerting.destinations.webhooks.with_raw_response.get( @@ -284,6 +290,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: webhook = response.parse() assert_matches_type(Optional[Webhooks], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.alerting.destinations.webhooks.with_streaming_response.get( @@ -298,6 +307,9 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @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 ''"): @@ -557,6 +569,9 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: webhook = await async_client.alerting.destinations.webhooks.get( @@ -565,6 +580,9 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[Webhooks], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.alerting.destinations.webhooks.with_raw_response.get( @@ -577,6 +595,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: webhook = await response.parse() assert_matches_type(Optional[Webhooks], webhook, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.alerting.destinations.webhooks.with_streaming_response.get( @@ -591,6 +612,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4291" + ) @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 ''"): diff --git a/tests/api_resources/magic_transit/sites/test_app_configuration.py b/tests/api_resources/magic_transit/sites/test_app_configuration.py index 8effe5be706..742259f302f 100644 --- a/tests/api_resources/magic_transit/sites/test_app_configuration.py +++ b/tests/api_resources/magic_transit/sites/test_app_configuration.py @@ -23,6 +23,9 @@ class TestAppConfiguration: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_create_overload_1(self, client: Cloudflare) -> None: app_configuration = client.magic_transit.sites.app_configuration.create( @@ -32,6 +35,9 @@ def test_method_create_overload_1(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: response = client.magic_transit.sites.app_configuration.with_raw_response.create( @@ -45,6 +51,9 @@ def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: app_configuration = response.parse() assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: with client.magic_transit.sites.app_configuration.with_streaming_response.create( @@ -60,6 +69,9 @@ def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_create_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -76,6 +88,9 @@ def test_path_params_create_overload_1(self, client: Cloudflare) -> None: account_app_id="ac60d3d0435248289d446cedd870bcf4", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_create_overload_2(self, client: Cloudflare) -> None: app_configuration = client.magic_transit.sites.app_configuration.create( @@ -85,6 +100,9 @@ def test_method_create_overload_2(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: response = client.magic_transit.sites.app_configuration.with_raw_response.create( @@ -98,6 +116,9 @@ def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: app_configuration = response.parse() assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: with client.magic_transit.sites.app_configuration.with_streaming_response.create( @@ -113,6 +134,9 @@ def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_create_overload_2(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -129,6 +153,9 @@ def test_path_params_create_overload_2(self, client: Cloudflare) -> None: managed_app_id="cloudflare", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_1(self, client: Cloudflare) -> None: app_configuration = client.magic_transit.sites.app_configuration.update( @@ -139,6 +166,9 @@ def test_method_update_overload_1(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: response = client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -153,6 +183,9 @@ def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: app_configuration = response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: with client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -169,6 +202,9 @@ def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -195,6 +231,9 @@ def test_path_params_update_overload_1(self, client: Cloudflare) -> None: body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_2(self, client: Cloudflare) -> None: app_configuration = client.magic_transit.sites.app_configuration.update( @@ -205,6 +244,9 @@ def test_method_update_overload_2(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: response = client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -219,6 +261,9 @@ def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: app_configuration = response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: with client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -235,6 +280,9 @@ def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_2(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -261,6 +309,9 @@ def test_path_params_update_overload_2(self, client: Cloudflare) -> None: body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_3(self, client: Cloudflare) -> None: app_configuration = client.magic_transit.sites.app_configuration.update( @@ -271,6 +322,9 @@ def test_method_update_overload_3(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: response = client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -285,6 +339,9 @@ def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: app_configuration = response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: with client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -301,6 +358,9 @@ def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_3(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -327,6 +387,9 @@ def test_path_params_update_overload_3(self, client: Cloudflare) -> None: account_app_id="ac60d3d0435248289d446cedd870bcf4", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_4(self, client: Cloudflare) -> None: app_configuration = client.magic_transit.sites.app_configuration.update( @@ -337,6 +400,9 @@ def test_method_update_overload_4(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: response = client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -351,6 +417,9 @@ def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: app_configuration = response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: with client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -367,6 +436,9 @@ def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_4(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -393,6 +465,9 @@ def test_path_params_update_overload_4(self, client: Cloudflare) -> None: managed_app_id="cloudflare", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_5(self, client: Cloudflare) -> None: app_configuration = client.magic_transit.sites.app_configuration.update( @@ -404,6 +479,9 @@ def test_method_update_overload_5(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: response = client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -419,6 +497,9 @@ def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: app_configuration = response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: with client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -436,6 +517,9 @@ def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_5(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -465,6 +549,9 @@ def test_path_params_update_overload_5(self, client: Cloudflare) -> None: managed_app_id="string", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_6(self, client: Cloudflare) -> None: app_configuration = client.magic_transit.sites.app_configuration.update( @@ -476,6 +563,9 @@ def test_method_update_overload_6(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: response = client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -491,6 +581,9 @@ def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: app_configuration = response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: with client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -508,6 +601,9 @@ def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_6(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -649,6 +745,9 @@ def test_path_params_delete(self, client: Cloudflare) -> None: class TestAsyncAppConfiguration: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: app_configuration = await async_client.magic_transit.sites.app_configuration.create( @@ -658,6 +757,9 @@ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.sites.app_configuration.with_raw_response.create( @@ -671,6 +773,9 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar app_configuration = await response.parse() assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.sites.app_configuration.with_streaming_response.create( @@ -686,6 +791,9 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -702,6 +810,9 @@ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare account_app_id="ac60d3d0435248289d446cedd870bcf4", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: app_configuration = await async_client.magic_transit.sites.app_configuration.create( @@ -711,6 +822,9 @@ async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.sites.app_configuration.with_raw_response.create( @@ -724,6 +838,9 @@ async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflar app_configuration = await response.parse() assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.sites.app_configuration.with_streaming_response.create( @@ -739,6 +856,9 @@ async def test_streaming_response_create_overload_2(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -755,6 +875,9 @@ async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare managed_app_id="cloudflare", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: app_configuration = await async_client.magic_transit.sites.app_configuration.update( @@ -765,6 +888,9 @@ async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -779,6 +905,9 @@ async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflar app_configuration = await response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -795,6 +924,9 @@ async def test_streaming_response_update_overload_1(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -821,6 +953,9 @@ async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: app_configuration = await async_client.magic_transit.sites.app_configuration.update( @@ -831,6 +966,9 @@ async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -845,6 +983,9 @@ async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflar app_configuration = await response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -861,6 +1002,9 @@ async def test_streaming_response_update_overload_2(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -887,6 +1031,9 @@ async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: app_configuration = await async_client.magic_transit.sites.app_configuration.update( @@ -897,6 +1044,9 @@ async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -911,6 +1061,9 @@ async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflar app_configuration = await response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -927,6 +1080,9 @@ async def test_streaming_response_update_overload_3(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -953,6 +1109,9 @@ async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare account_app_id="ac60d3d0435248289d446cedd870bcf4", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: app_configuration = await async_client.magic_transit.sites.app_configuration.update( @@ -963,6 +1122,9 @@ async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -977,6 +1139,9 @@ async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflar app_configuration = await response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -993,6 +1158,9 @@ async def test_streaming_response_update_overload_4(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -1019,6 +1187,9 @@ async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare managed_app_id="cloudflare", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> None: app_configuration = await async_client.magic_transit.sites.app_configuration.update( @@ -1030,6 +1201,9 @@ async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -1045,6 +1219,9 @@ async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflar app_configuration = await response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -1062,6 +1239,9 @@ async def test_streaming_response_update_overload_5(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -1091,6 +1271,9 @@ async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare managed_app_id="string", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> None: app_configuration = await async_client.magic_transit.sites.app_configuration.update( @@ -1102,6 +1285,9 @@ async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( @@ -1117,6 +1303,9 @@ async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflar app_configuration = await response.parse() assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( @@ -1134,6 +1323,9 @@ async def test_streaming_response_update_overload_6(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): diff --git a/tests/api_resources/magic_transit/test_apps.py b/tests/api_resources/magic_transit/test_apps.py index 32ba34bf644..1cd6c73830d 100644 --- a/tests/api_resources/magic_transit/test_apps.py +++ b/tests/api_resources/magic_transit/test_apps.py @@ -23,6 +23,9 @@ class TestApps: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_create_overload_1(self, client: Cloudflare) -> None: app = client.magic_transit.apps.create( @@ -31,6 +34,9 @@ def test_method_create_overload_1(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: response = client.magic_transit.apps.with_raw_response.create( @@ -43,6 +49,9 @@ def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: app = response.parse() assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: with client.magic_transit.apps.with_streaming_response.create( @@ -57,6 +66,9 @@ def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_create_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -65,6 +77,9 @@ def test_path_params_create_overload_1(self, client: Cloudflare) -> None: body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_create_overload_2(self, client: Cloudflare) -> None: app = client.magic_transit.apps.create( @@ -73,6 +88,9 @@ def test_method_create_overload_2(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: response = client.magic_transit.apps.with_raw_response.create( @@ -85,6 +103,9 @@ def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: app = response.parse() assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: with client.magic_transit.apps.with_streaming_response.create( @@ -99,6 +120,9 @@ def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_create_overload_2(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -107,6 +131,9 @@ def test_path_params_create_overload_2(self, client: Cloudflare) -> None: body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_1(self, client: Cloudflare) -> None: app = client.magic_transit.apps.update( @@ -116,6 +143,9 @@ def test_method_update_overload_1(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: response = client.magic_transit.apps.with_raw_response.update( @@ -129,6 +159,9 @@ def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: app = response.parse() assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: with client.magic_transit.apps.with_streaming_response.update( @@ -144,6 +177,9 @@ def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -160,6 +196,9 @@ def test_path_params_update_overload_1(self, client: Cloudflare) -> None: body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_2(self, client: Cloudflare) -> None: app = client.magic_transit.apps.update( @@ -169,6 +208,9 @@ def test_method_update_overload_2(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: response = client.magic_transit.apps.with_raw_response.update( @@ -182,6 +224,9 @@ def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: app = response.parse() assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: with client.magic_transit.apps.with_streaming_response.update( @@ -197,6 +242,9 @@ def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_2(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -213,6 +261,9 @@ def test_path_params_update_overload_2(self, client: Cloudflare) -> None: body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_3(self, client: Cloudflare) -> None: app = client.magic_transit.apps.update( @@ -222,6 +273,9 @@ def test_method_update_overload_3(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: response = client.magic_transit.apps.with_raw_response.update( @@ -235,6 +289,9 @@ def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: app = response.parse() assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: with client.magic_transit.apps.with_streaming_response.update( @@ -250,6 +307,9 @@ def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_3(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -266,6 +326,9 @@ def test_path_params_update_overload_3(self, client: Cloudflare) -> None: body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_update_overload_4(self, client: Cloudflare) -> None: app = client.magic_transit.apps.update( @@ -275,6 +338,9 @@ def test_method_update_overload_4(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: response = client.magic_transit.apps.with_raw_response.update( @@ -288,6 +354,9 @@ def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: app = response.parse() assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: with client.magic_transit.apps.with_streaming_response.update( @@ -303,6 +372,9 @@ def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_path_params_update_overload_4(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -319,6 +391,9 @@ def test_path_params_update_overload_4(self, client: Cloudflare) -> None: body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_method_list(self, client: Cloudflare) -> None: app = client.magic_transit.apps.list( @@ -326,6 +401,9 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(SyncSinglePage[AppListResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.magic_transit.apps.with_raw_response.list( @@ -337,6 +415,9 @@ def test_raw_response_list(self, client: Cloudflare) -> None: app = response.parse() assert_matches_type(SyncSinglePage[AppListResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.magic_transit.apps.with_streaming_response.list( @@ -350,6 +431,9 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @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 ''"): @@ -409,6 +493,9 @@ def test_path_params_delete(self, client: Cloudflare) -> None: class TestAsyncApps: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: app = await async_client.magic_transit.apps.create( @@ -417,6 +504,9 @@ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.apps.with_raw_response.create( @@ -429,6 +519,9 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar app = await response.parse() assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.apps.with_streaming_response.create( @@ -443,6 +536,9 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -451,6 +547,9 @@ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: app = await async_client.magic_transit.apps.create( @@ -459,6 +558,9 @@ async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.apps.with_raw_response.create( @@ -471,6 +573,9 @@ async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflar app = await response.parse() assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.apps.with_streaming_response.create( @@ -485,6 +590,9 @@ async def test_streaming_response_create_overload_2(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -493,6 +601,9 @@ async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: app = await async_client.magic_transit.apps.update( @@ -502,6 +613,9 @@ async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.apps.with_raw_response.update( @@ -515,6 +629,9 @@ async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflar app = await response.parse() assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.apps.with_streaming_response.update( @@ -530,6 +647,9 @@ async def test_streaming_response_update_overload_1(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -546,6 +666,9 @@ async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: app = await async_client.magic_transit.apps.update( @@ -555,6 +678,9 @@ async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.apps.with_raw_response.update( @@ -568,6 +694,9 @@ async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflar app = await response.parse() assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.apps.with_streaming_response.update( @@ -583,6 +712,9 @@ async def test_streaming_response_update_overload_2(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -599,6 +731,9 @@ async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: app = await async_client.magic_transit.apps.update( @@ -608,6 +743,9 @@ async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.apps.with_raw_response.update( @@ -621,6 +759,9 @@ async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflar app = await response.parse() assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.apps.with_streaming_response.update( @@ -636,6 +777,9 @@ async def test_streaming_response_update_overload_3(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -652,6 +796,9 @@ async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: app = await async_client.magic_transit.apps.update( @@ -661,6 +808,9 @@ async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.apps.with_raw_response.update( @@ -674,6 +824,9 @@ async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflar app = await response.parse() assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.apps.with_streaming_response.update( @@ -689,6 +842,9 @@ async def test_streaming_response_update_overload_4(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -705,6 +861,9 @@ async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare body={}, ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: app = await async_client.magic_transit.apps.list( @@ -712,6 +871,9 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(AsyncSinglePage[AppListResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_transit.apps.with_raw_response.list( @@ -723,6 +885,9 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: app = await response.parse() assert_matches_type(AsyncSinglePage[AppListResponse], app, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_transit.apps.with_streaming_response.list( @@ -736,6 +901,9 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" + ) @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 ''"): From 547f900a651274f74fa778bb26b12b5492179775 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 03:07:07 +0000 Subject: [PATCH 303/532] feat(api): update via SDK Studio (#784) --- tests/api_resources/alerting/test_policies.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/api_resources/alerting/test_policies.py b/tests/api_resources/alerting/test_policies.py index 4814ba6a9d2..7f5b50e9c10 100644 --- a/tests/api_resources/alerting/test_policies.py +++ b/tests/api_resources/alerting/test_policies.py @@ -374,6 +374,9 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_method_get(self, client: Cloudflare) -> None: policy = client.alerting.policies.get( @@ -382,6 +385,9 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[Policy], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.alerting.policies.with_raw_response.get( @@ -394,6 +400,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: policy = response.parse() assert_matches_type(Optional[Policy], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.alerting.policies.with_streaming_response.get( @@ -408,6 +417,9 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @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 ''"): @@ -777,6 +789,9 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", ) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: policy = await async_client.alerting.policies.get( @@ -785,6 +800,9 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[Policy], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.alerting.policies.with_raw_response.get( @@ -797,6 +815,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: policy = await response.parse() assert_matches_type(Optional[Policy], policy, path=["response"]) + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.alerting.policies.with_streaming_response.get( @@ -811,6 +832,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip( + reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9327225061/job/25676826349?pr=482#step:5:4274" + ) @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 ''"): From 7f3baa694305a43de27dd61e9278319e309ab3f8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:49:57 +0000 Subject: [PATCH 304/532] feat(api): OpenAPI spec update via Stainless API (#785) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3050b50ac78..036bd6a320f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dcd6da6d54ab84199b2a5a342783a5388aa6ea0f460f8ad821f5b5dc60b3726e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml From ffbb10669205683229a8ddb18c64cb8a9599fffe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:52:05 +0000 Subject: [PATCH 305/532] feat(api): OpenAPI spec update via Stainless API (#786) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 036bd6a320f..3050b50ac78 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dcd6da6d54ab84199b2a5a342783a5388aa6ea0f460f8ad821f5b5dc60b3726e.yml From ecf6363a5307ff255892ada1803074856c78ae44 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:57:33 +0000 Subject: [PATCH 306/532] feat(api): OpenAPI spec update via Stainless API (#787) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3050b50ac78..036bd6a320f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dcd6da6d54ab84199b2a5a342783a5388aa6ea0f460f8ad821f5b5dc60b3726e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml From ee85bf180b6b32b28ef05de2642c53a837721d3f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:59:40 +0000 Subject: [PATCH 307/532] feat(api): OpenAPI spec update via Stainless API (#788) --- .stats.yml | 2 +- api.md | 11 ++++--- .../resources/rulesets/phases/phases.py | 11 +------ .../resources/rulesets/phases/versions.py | 14 ++++---- src/cloudflare/resources/rulesets/rulesets.py | 14 ++++---- .../resources/rulesets/versions/versions.py | 14 ++++---- src/cloudflare/types/rulesets/__init__.py | 3 +- .../types/rulesets/phase_update_params.py | 4 --- .../types/rulesets/phases/__init__.py | 1 + .../rulesets/phases/version_list_response.py | 33 +++++++++++++++++++ .../{ruleset.py => ruleset_list_response.py} | 22 ++++++------- .../types/rulesets/version_list_response.py | 33 +++++++++++++++++++ .../rulesets/phases/test_versions.py | 19 +++++------ tests/api_resources/rulesets/test_phases.py | 2 -- tests/api_resources/rulesets/test_versions.py | 18 +++++----- tests/api_resources/test_rulesets.py | 18 +++++----- 16 files changed, 136 insertions(+), 83 deletions(-) create mode 100644 src/cloudflare/types/rulesets/phases/version_list_response.py rename src/cloudflare/types/rulesets/{ruleset.py => ruleset_list_response.py} (81%) create mode 100644 src/cloudflare/types/rulesets/version_list_response.py diff --git a/.stats.yml b/.stats.yml index 036bd6a320f..4d1193a3b2b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e83b5eb5706ca8b525141f506338cd1d465eb133815b9ddc53df612ea4a2ecef.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0be7a22d1cc24a2a63cf7c7d9324fa078990d35e80629e2cbd28b9838940d75d.yml diff --git a/api.md b/api.md index 26ae9445536..14aaae3917c 100644 --- a/api.md +++ b/api.md @@ -3165,6 +3165,7 @@ from cloudflare.types.rulesets import ( Ruleset, RulesetCreateResponse, RulesetUpdateResponse, + RulesetListResponse, RulesetGetResponse, ) ``` @@ -3173,7 +3174,7 @@ Methods: - client.rulesets.create(\*, account_id, zone_id, \*\*params) -> RulesetCreateResponse - client.rulesets.update(ruleset_id, \*, account_id, zone_id, \*\*params) -> RulesetUpdateResponse -- client.rulesets.list(\*, account_id, zone_id) -> SyncSinglePage[Ruleset] +- client.rulesets.list(\*, account_id, zone_id) -> SyncSinglePage[RulesetListResponse] - client.rulesets.delete(ruleset_id, \*, account_id, zone_id) -> None - client.rulesets.get(ruleset_id, \*, account_id, zone_id) -> RulesetGetResponse @@ -3195,12 +3196,12 @@ Methods: Types: ```python -from cloudflare.types.rulesets.phases import VersionGetResponse +from cloudflare.types.rulesets.phases import VersionListResponse, VersionGetResponse ``` Methods: -- client.rulesets.phases.versions.list(ruleset_phase, \*, account_id, zone_id) -> SyncSinglePage[Ruleset] +- client.rulesets.phases.versions.list(ruleset_phase, \*, account_id, zone_id) -> SyncSinglePage[VersionListResponse] - client.rulesets.phases.versions.get(ruleset_version, \*, ruleset_phase, account_id, zone_id) -> VersionGetResponse ## Rules @@ -3244,12 +3245,12 @@ Methods: Types: ```python -from cloudflare.types.rulesets import VersionGetResponse +from cloudflare.types.rulesets import VersionListResponse, VersionGetResponse ``` Methods: -- client.rulesets.versions.list(ruleset_id, \*, account_id, zone_id) -> SyncSinglePage[Ruleset] +- client.rulesets.versions.list(ruleset_id, \*, account_id, zone_id) -> SyncSinglePage[VersionListResponse] - client.rulesets.versions.delete(ruleset_version, \*, ruleset_id, account_id, zone_id) -> None - client.rulesets.versions.get(ruleset_version, \*, ruleset_id, account_id, zone_id) -> VersionGetResponse diff --git a/src/cloudflare/resources/rulesets/phases/phases.py b/src/cloudflare/resources/rulesets/phases/phases.py index 5cb0317d0fa..c95aafd532f 100644 --- a/src/cloudflare/resources/rulesets/phases/phases.py +++ b/src/cloudflare/resources/rulesets/phases/phases.py @@ -31,8 +31,7 @@ from ...._base_client import ( make_request_options, ) -from ....types.rulesets import Kind, Phase, phase_update_params -from ....types.rulesets.kind import Kind +from ....types.rulesets import Phase, phase_update_params from ....types.rulesets.phase import Phase from ....types.rulesets.phase_get_response import PhaseGetResponse from ....types.rulesets.phase_update_response import PhaseUpdateResponse @@ -61,7 +60,6 @@ def update( account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, - kind: Kind | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, phase: Phase | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -85,8 +83,6 @@ def update( description: An informative description of the ruleset. - kind: The kind of the ruleset. - name: The human-readable name of the ruleset. phase: The phase of the ruleset. @@ -119,7 +115,6 @@ def update( { "rules": rules, "description": description, - "kind": kind, "name": name, "phase": phase, }, @@ -215,7 +210,6 @@ async def update( account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, - kind: Kind | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, phase: Phase | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -239,8 +233,6 @@ async def update( description: An informative description of the ruleset. - kind: The kind of the ruleset. - name: The human-readable name of the ruleset. phase: The phase of the ruleset. @@ -273,7 +265,6 @@ async def update( { "rules": rules, "description": description, - "kind": kind, "name": name, "phase": phase, }, diff --git a/src/cloudflare/resources/rulesets/phases/versions.py b/src/cloudflare/resources/rulesets/phases/versions.py index 60967a5872f..93fbc705d12 100644 --- a/src/cloudflare/resources/rulesets/phases/versions.py +++ b/src/cloudflare/resources/rulesets/phases/versions.py @@ -23,8 +23,8 @@ ) from ....types.rulesets import Phase from ....types.rulesets.phase import Phase -from ....types.rulesets.ruleset import Ruleset from ....types.rulesets.phases.version_get_response import VersionGetResponse +from ....types.rulesets.phases.version_list_response import VersionListResponse __all__ = ["VersionsResource", "AsyncVersionsResource"] @@ -50,7 +50,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Ruleset]: + ) -> SyncSinglePage[VersionListResponse]: """ Fetches the versions of an account or zone entry point ruleset. @@ -85,11 +85,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint/versions", - page=SyncSinglePage[Ruleset], + page=SyncSinglePage[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Ruleset, + model=VersionListResponse, ) def get( @@ -176,7 +176,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Ruleset, AsyncSinglePage[Ruleset]]: + ) -> AsyncPaginator[VersionListResponse, AsyncSinglePage[VersionListResponse]]: """ Fetches the versions of an account or zone entry point ruleset. @@ -211,11 +211,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/rulesets/phases/{ruleset_phase}/entrypoint/versions", - page=AsyncSinglePage[Ruleset], + page=AsyncSinglePage[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Ruleset, + model=VersionListResponse, ) async def get( diff --git a/src/cloudflare/resources/rulesets/rulesets.py b/src/cloudflare/resources/rulesets/rulesets.py index f28542d39f5..7347798d5fd 100644 --- a/src/cloudflare/resources/rulesets/rulesets.py +++ b/src/cloudflare/resources/rulesets/rulesets.py @@ -54,8 +54,8 @@ from .versions.versions import VersionsResource, AsyncVersionsResource from ...types.rulesets.kind import Kind from ...types.rulesets.phase import Phase -from ...types.rulesets.ruleset import Ruleset from ...types.rulesets.ruleset_get_response import RulesetGetResponse +from ...types.rulesets.ruleset_list_response import RulesetListResponse from ...types.rulesets.ruleset_create_response import RulesetCreateResponse from ...types.rulesets.ruleset_update_response import RulesetUpdateResponse @@ -253,7 +253,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Ruleset]: + ) -> SyncSinglePage[RulesetListResponse]: """ Fetches all rulesets. @@ -284,11 +284,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/rulesets", - page=SyncSinglePage[Ruleset], + page=SyncSinglePage[RulesetListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Ruleset, + model=RulesetListResponse, ) def delete( @@ -594,7 +594,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Ruleset, AsyncSinglePage[Ruleset]]: + ) -> AsyncPaginator[RulesetListResponse, AsyncSinglePage[RulesetListResponse]]: """ Fetches all rulesets. @@ -625,11 +625,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/rulesets", - page=AsyncSinglePage[Ruleset], + page=AsyncSinglePage[RulesetListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Ruleset, + model=RulesetListResponse, ) async def delete( diff --git a/src/cloudflare/resources/rulesets/versions/versions.py b/src/cloudflare/resources/rulesets/versions/versions.py index 134fb1882b9..d19afd50795 100644 --- a/src/cloudflare/resources/rulesets/versions/versions.py +++ b/src/cloudflare/resources/rulesets/versions/versions.py @@ -29,8 +29,8 @@ AsyncPaginator, make_request_options, ) -from ....types.rulesets.ruleset import Ruleset from ....types.rulesets.version_get_response import VersionGetResponse +from ....types.rulesets.version_list_response import VersionListResponse __all__ = ["VersionsResource", "AsyncVersionsResource"] @@ -60,7 +60,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Ruleset]: + ) -> SyncSinglePage[VersionListResponse]: """ Fetches the versions of an account or zone ruleset. @@ -95,11 +95,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/versions", - page=SyncSinglePage[Ruleset], + page=SyncSinglePage[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Ruleset, + model=VersionListResponse, ) def delete( @@ -249,7 +249,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Ruleset, AsyncSinglePage[Ruleset]]: + ) -> AsyncPaginator[VersionListResponse, AsyncSinglePage[VersionListResponse]]: """ Fetches the versions of an account or zone ruleset. @@ -284,11 +284,11 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/versions", - page=AsyncSinglePage[Ruleset], + page=AsyncSinglePage[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Ruleset, + model=VersionListResponse, ) async def delete( diff --git a/src/cloudflare/types/rulesets/__init__.py b/src/cloudflare/types/rulesets/__init__.py index d5b6a67cb87..8b6885eb3fd 100644 --- a/src/cloudflare/types/rulesets/__init__.py +++ b/src/cloudflare/types/rulesets/__init__.py @@ -5,7 +5,6 @@ from .kind import Kind as Kind from .phase import Phase as Phase from .logging import Logging as Logging -from .ruleset import Ruleset as Ruleset from .log_rule import LogRule as LogRule from .skip_rule import SkipRule as SkipRule from .block_rule import BlockRule as BlockRule @@ -40,8 +39,10 @@ from .version_get_response import VersionGetResponse as VersionGetResponse from .phase_update_response import PhaseUpdateResponse as PhaseUpdateResponse from .ruleset_create_params import RulesetCreateParams as RulesetCreateParams +from .ruleset_list_response import RulesetListResponse as RulesetListResponse from .ruleset_update_params import RulesetUpdateParams as RulesetUpdateParams from .set_config_rule_param import SetConfigRuleParam as SetConfigRuleParam +from .version_list_response import VersionListResponse as VersionListResponse from .compress_response_rule import CompressResponseRule as CompressResponseRule from .managed_challenge_rule import ManagedChallengeRule as ManagedChallengeRule from .rewrite_uri_part_param import RewriteURIPartParam as RewriteURIPartParam diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index 27f4398d8c9..41cf834d9cf 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -5,7 +5,6 @@ from typing import Union, Iterable from typing_extensions import Literal, Required, TypedDict -from .kind import Kind from .phase import Phase from .logging_param import LoggingParam from .log_rule_param import LogRuleParam @@ -50,9 +49,6 @@ class PhaseUpdateParams(TypedDict, total=False): description: str """An informative description of the ruleset.""" - kind: Kind - """The kind of the ruleset.""" - name: str """The human-readable name of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/phases/__init__.py b/src/cloudflare/types/rulesets/phases/__init__.py index 398f2bd04ad..5a719b3e523 100644 --- a/src/cloudflare/types/rulesets/phases/__init__.py +++ b/src/cloudflare/types/rulesets/phases/__init__.py @@ -3,3 +3,4 @@ from __future__ import annotations from .version_get_response import VersionGetResponse as VersionGetResponse +from .version_list_response import VersionListResponse as VersionListResponse diff --git a/src/cloudflare/types/rulesets/phases/version_list_response.py b/src/cloudflare/types/rulesets/phases/version_list_response.py new file mode 100644 index 00000000000..921e1de8c40 --- /dev/null +++ b/src/cloudflare/types/rulesets/phases/version_list_response.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..kind import Kind +from ..phase import Phase +from ...._models import BaseModel + +__all__ = ["VersionListResponse"] + + +class VersionListResponse(BaseModel): + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/ruleset.py b/src/cloudflare/types/rulesets/ruleset_list_response.py similarity index 81% rename from src/cloudflare/types/rulesets/ruleset.py rename to src/cloudflare/types/rulesets/ruleset_list_response.py index a570fcc344d..582742290a7 100644 --- a/src/cloudflare/types/rulesets/ruleset.py +++ b/src/cloudflare/types/rulesets/ruleset_list_response.py @@ -7,27 +7,27 @@ from .phase import Phase from ..._models import BaseModel -__all__ = ["Ruleset"] +__all__ = ["RulesetListResponse"] -class Ruleset(BaseModel): +class RulesetListResponse(BaseModel): id: str """The unique ID of the ruleset.""" + kind: Kind + """The kind of the ruleset.""" + last_updated: datetime """The timestamp of when the ruleset was last modified.""" + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + version: str """The version of the ruleset.""" description: Optional[str] = None """An informative description of the ruleset.""" - - kind: Optional[Kind] = None - """The kind of the ruleset.""" - - name: Optional[str] = None - """The human-readable name of the ruleset.""" - - phase: Optional[Phase] = None - """The phase of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/version_list_response.py b/src/cloudflare/types/rulesets/version_list_response.py new file mode 100644 index 00000000000..bfc8b80491c --- /dev/null +++ b/src/cloudflare/types/rulesets/version_list_response.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from .kind import Kind +from .phase import Phase +from ..._models import BaseModel + +__all__ = ["VersionListResponse"] + + +class VersionListResponse(BaseModel): + id: str + """The unique ID of the ruleset.""" + + kind: Kind + """The kind of the ruleset.""" + + last_updated: datetime + """The timestamp of when the ruleset was last modified.""" + + name: str + """The human-readable name of the ruleset.""" + + phase: Phase + """The phase of the ruleset.""" + + version: str + """The version of the ruleset.""" + + description: Optional[str] = None + """An informative description of the ruleset.""" diff --git a/tests/api_resources/rulesets/phases/test_versions.py b/tests/api_resources/rulesets/phases/test_versions.py index 7c88a7ef7f8..f763170399e 100644 --- a/tests/api_resources/rulesets/phases/test_versions.py +++ b/tests/api_resources/rulesets/phases/test_versions.py @@ -10,8 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.rulesets import Ruleset -from cloudflare.types.rulesets.phases import VersionGetResponse +from cloudflare.types.rulesets.phases import VersionGetResponse, VersionListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -26,7 +25,7 @@ def test_method_list(self, client: Cloudflare) -> None: "http_request_firewall_custom", account_id="string", ) - assert_matches_type(SyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -35,7 +34,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: "http_request_firewall_custom", account_id="string", ) - assert_matches_type(SyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -48,7 +47,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert_matches_type(SyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -61,7 +60,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert_matches_type(SyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True @@ -165,7 +164,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: "http_request_firewall_custom", account_id="string", ) - assert_matches_type(AsyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -174,7 +173,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) "http_request_firewall_custom", account_id="string", ) - assert_matches_type(AsyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -187,7 +186,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert_matches_type(AsyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -200,7 +199,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert_matches_type(AsyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/rulesets/test_phases.py b/tests/api_resources/rulesets/test_phases.py index 40462f29ea8..447be7922ae 100644 --- a/tests/api_resources/rulesets/test_phases.py +++ b/tests/api_resources/rulesets/test_phases.py @@ -84,7 +84,6 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: ], account_id="string", description="My ruleset to execute managed rulesets", - kind="root", name="My ruleset", phase="http_request_firewall_custom", ) @@ -269,7 +268,6 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare ], account_id="string", description="My ruleset to execute managed rulesets", - kind="root", name="My ruleset", phase="http_request_firewall_custom", ) diff --git a/tests/api_resources/rulesets/test_versions.py b/tests/api_resources/rulesets/test_versions.py index 1fd08c4b629..3106292143c 100644 --- a/tests/api_resources/rulesets/test_versions.py +++ b/tests/api_resources/rulesets/test_versions.py @@ -10,7 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.rulesets import Ruleset, VersionGetResponse +from cloudflare.types.rulesets import VersionGetResponse, VersionListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -25,7 +25,7 @@ def test_method_list(self, client: Cloudflare) -> None: "2f2feab2026849078ba485f918791bdc", account_id="string", ) - assert_matches_type(SyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -34,7 +34,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: "2f2feab2026849078ba485f918791bdc", account_id="string", ) - assert_matches_type(SyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -47,7 +47,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert_matches_type(SyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -60,7 +60,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert_matches_type(SyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(SyncSinglePage[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True @@ -258,7 +258,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: "2f2feab2026849078ba485f918791bdc", account_id="string", ) - assert_matches_type(AsyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -267,7 +267,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) "2f2feab2026849078ba485f918791bdc", account_id="string", ) - assert_matches_type(AsyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -280,7 +280,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert_matches_type(AsyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -293,7 +293,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert_matches_type(AsyncSinglePage[Ruleset], version, path=["response"]) + assert_matches_type(AsyncSinglePage[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_rulesets.py b/tests/api_resources/test_rulesets.py index ae2f1c54dc7..97d3d27207e 100644 --- a/tests/api_resources/test_rulesets.py +++ b/tests/api_resources/test_rulesets.py @@ -11,8 +11,8 @@ from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.rulesets import ( - Ruleset, RulesetGetResponse, + RulesetListResponse, RulesetCreateResponse, RulesetUpdateResponse, ) @@ -285,7 +285,7 @@ def test_method_list(self, client: Cloudflare) -> None: ruleset = client.rulesets.list( account_id="string", ) - assert_matches_type(SyncSinglePage[Ruleset], ruleset, path=["response"]) + assert_matches_type(SyncSinglePage[RulesetListResponse], ruleset, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -293,7 +293,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: ruleset = client.rulesets.list( account_id="string", ) - assert_matches_type(SyncSinglePage[Ruleset], ruleset, path=["response"]) + assert_matches_type(SyncSinglePage[RulesetListResponse], ruleset, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -305,7 +305,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" ruleset = response.parse() - assert_matches_type(SyncSinglePage[Ruleset], ruleset, path=["response"]) + assert_matches_type(SyncSinglePage[RulesetListResponse], ruleset, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -317,7 +317,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" ruleset = response.parse() - assert_matches_type(SyncSinglePage[Ruleset], ruleset, path=["response"]) + assert_matches_type(SyncSinglePage[RulesetListResponse], ruleset, path=["response"]) assert cast(Any, response.is_closed) is True @@ -734,7 +734,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ruleset = await async_client.rulesets.list( account_id="string", ) - assert_matches_type(AsyncSinglePage[Ruleset], ruleset, path=["response"]) + assert_matches_type(AsyncSinglePage[RulesetListResponse], ruleset, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -742,7 +742,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) ruleset = await async_client.rulesets.list( account_id="string", ) - assert_matches_type(AsyncSinglePage[Ruleset], ruleset, path=["response"]) + assert_matches_type(AsyncSinglePage[RulesetListResponse], ruleset, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -754,7 +754,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" ruleset = await response.parse() - assert_matches_type(AsyncSinglePage[Ruleset], ruleset, path=["response"]) + assert_matches_type(AsyncSinglePage[RulesetListResponse], ruleset, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -766,7 +766,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" ruleset = await response.parse() - assert_matches_type(AsyncSinglePage[Ruleset], ruleset, path=["response"]) + assert_matches_type(AsyncSinglePage[RulesetListResponse], ruleset, path=["response"]) assert cast(Any, response.is_closed) is True From e8ed1f8f7f7cf78b7f1869b1296e8d570d025771 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:08:42 +0000 Subject: [PATCH 308/532] feat(api): OpenAPI spec update via Stainless API (#789) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4d1193a3b2b..d5880558773 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0be7a22d1cc24a2a63cf7c7d9324fa078990d35e80629e2cbd28b9838940d75d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b4dbcd29fdd5e0f88ee4097d3c58c446c6876505a522503afa704ebf51b8281.yml From 9091d7b0efaf6ece2e99756a6bc91c2d420b6cc8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:14:49 +0000 Subject: [PATCH 309/532] feat(api): OpenAPI spec update via Stainless API (#790) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d5880558773..26cd9a85be9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b4dbcd29fdd5e0f88ee4097d3c58c446c6876505a522503afa704ebf51b8281.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5dfb65a0436eec37b104ed913220b8182ddfe1336e6639f62077fa92501290a4.yml From 45f7884a795276b12a0c8ab7516193a6500c7583 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 11:38:10 +0000 Subject: [PATCH 310/532] feat(api): OpenAPI spec update via Stainless API (#791) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 26cd9a85be9..d5880558773 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5dfb65a0436eec37b104ed913220b8182ddfe1336e6639f62077fa92501290a4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b4dbcd29fdd5e0f88ee4097d3c58c446c6876505a522503afa704ebf51b8281.yml From cd93b55fbaecee453b2682e8efbf5ed490c6c249 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:02:01 +0000 Subject: [PATCH 311/532] feat(api): OpenAPI spec update via Stainless API (#792) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d5880558773..baa541eb78b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b4dbcd29fdd5e0f88ee4097d3c58c446c6876505a522503afa704ebf51b8281.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69d898fa65a89862112ce6db33086cc239868954ed54f1fae9a2784395899977.yml From 9475e3cbe7dc98fa889b44ae43a52346d949371e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:04:28 +0000 Subject: [PATCH 312/532] feat(api): OpenAPI spec update via Stainless API (#793) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index baa541eb78b..d5880558773 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69d898fa65a89862112ce6db33086cc239868954ed54f1fae9a2784395899977.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b4dbcd29fdd5e0f88ee4097d3c58c446c6876505a522503afa704ebf51b8281.yml From bb3889a105c71b02b97ea63e52ae6f310ea878f7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:53:43 +0000 Subject: [PATCH 313/532] feat(api): OpenAPI spec update via Stainless API (#794) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d5880558773..baa541eb78b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b4dbcd29fdd5e0f88ee4097d3c58c446c6876505a522503afa704ebf51b8281.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69d898fa65a89862112ce6db33086cc239868954ed54f1fae9a2784395899977.yml From d84dbbb74d4fd13ab612fcc76f1c3dd95ddbcc71 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:55:50 +0000 Subject: [PATCH 314/532] feat(api): OpenAPI spec update via Stainless API (#795) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index baa541eb78b..d5880558773 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-69d898fa65a89862112ce6db33086cc239868954ed54f1fae9a2784395899977.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b4dbcd29fdd5e0f88ee4097d3c58c446c6876505a522503afa704ebf51b8281.yml From bfa8b2256a21a5b5c40eaa5b7904caedb301fce4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 15:41:49 +0000 Subject: [PATCH 315/532] feat(api): OpenAPI spec update via Stainless API (#796) --- .stats.yml | 2 +- .../zero_trust/risk_scoring/integration_create_response.py | 7 +++++++ .../zero_trust/risk_scoring/integration_get_response.py | 7 +++++++ .../zero_trust/risk_scoring/integration_list_response.py | 7 +++++++ .../zero_trust/risk_scoring/integration_update_response.py | 7 +++++++ .../risk_scoring/integrations/reference_get_response.py | 7 +++++++ 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d5880558773..d3fe501a329 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b4dbcd29fdd5e0f88ee4097d3c58c446c6876505a522503afa704ebf51b8281.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_create_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_create_response.py index fe710d49e74..a30b33a1de8 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/integration_create_response.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_create_response.py @@ -32,3 +32,10 @@ class IntegrationCreateResponse(BaseModel): tenant_url: str """The base URL for the tenant. E.g. "https://tenant.okta.com" """ + + well_known_url: str + """The URL for the Shared Signals Framework configuration, e.g. + + "/.well-known/sse-configuration/{integration_uuid}/". + https://openid.net/specs/openid-sse-framework-1_0.html#rfc.section.6.2.1 + """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_get_response.py index af016764ca9..1e4bd01fa6c 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/integration_get_response.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_get_response.py @@ -32,3 +32,10 @@ class IntegrationGetResponse(BaseModel): tenant_url: str """The base URL for the tenant. E.g. "https://tenant.okta.com" """ + + well_known_url: str + """The URL for the Shared Signals Framework configuration, e.g. + + "/.well-known/sse-configuration/{integration_uuid}/". + https://openid.net/specs/openid-sse-framework-1_0.html#rfc.section.6.2.1 + """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_list_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_list_response.py index a56a92339d9..870bce91672 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/integration_list_response.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_list_response.py @@ -32,3 +32,10 @@ class IntegrationListResponse(BaseModel): tenant_url: str """The base URL for the tenant. E.g. "https://tenant.okta.com" """ + + well_known_url: str + """The URL for the Shared Signals Framework configuration, e.g. + + "/.well-known/sse-configuration/{integration_uuid}/". + https://openid.net/specs/openid-sse-framework-1_0.html#rfc.section.6.2.1 + """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integration_update_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integration_update_response.py index 9fc5ff96e0d..5d084429b0c 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/integration_update_response.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/integration_update_response.py @@ -32,3 +32,10 @@ class IntegrationUpdateResponse(BaseModel): tenant_url: str """The base URL for the tenant. E.g. "https://tenant.okta.com" """ + + well_known_url: str + """The URL for the Shared Signals Framework configuration, e.g. + + "/.well-known/sse-configuration/{integration_uuid}/". + https://openid.net/specs/openid-sse-framework-1_0.html#rfc.section.6.2.1 + """ diff --git a/src/cloudflare/types/zero_trust/risk_scoring/integrations/reference_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring/integrations/reference_get_response.py index 071ae7cf5e6..d0f79a48a3c 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/integrations/reference_get_response.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/integrations/reference_get_response.py @@ -32,3 +32,10 @@ class ReferenceGetResponse(BaseModel): tenant_url: str """The base URL for the tenant. E.g. "https://tenant.okta.com" """ + + well_known_url: str + """The URL for the Shared Signals Framework configuration, e.g. + + "/.well-known/sse-configuration/{integration_uuid}/". + https://openid.net/specs/openid-sse-framework-1_0.html#rfc.section.6.2.1 + """ From ec2e1e3670b003dff8a9f41d94e99055b03e9303 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:36:33 +0000 Subject: [PATCH 316/532] feat(api): OpenAPI spec update via Stainless API (#797) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d3fe501a329..4d42c2df933 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml From 4567f4d99ea72da60b5bcf3390ca1fdffedd43e9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:46:42 +0000 Subject: [PATCH 317/532] feat(api): OpenAPI spec update via Stainless API (#798) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4d42c2df933..06c14e7d755 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-478c3ece48209201bc7501936e087ab7892159f70746853b84daf689eb0f1a82.yml From 9066b5546dd19ea3aa0b6bc073ebd20a196bf3a2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:33:05 +0000 Subject: [PATCH 318/532] feat(api): OpenAPI spec update via Stainless API (#799) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 06c14e7d755..d3fe501a329 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-478c3ece48209201bc7501936e087ab7892159f70746853b84daf689eb0f1a82.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml From 098ce63b7560e7287b37b76cf9bee389e0551c95 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:42:14 +0000 Subject: [PATCH 319/532] feat(api): OpenAPI spec update via Stainless API (#800) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d3fe501a329..4d42c2df933 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml From 784447a897b73f8bd2a416e247aaa5a432d43996 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:44:26 +0000 Subject: [PATCH 320/532] feat(api): OpenAPI spec update via Stainless API (#801) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4d42c2df933..d3fe501a329 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml From 4e8e439098c4c1a76dc1f562c90bccf718d17c06 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:58:26 +0000 Subject: [PATCH 321/532] feat(api): OpenAPI spec update via Stainless API (#802) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d3fe501a329..4d42c2df933 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml From 0bfacd43972e5206b333ab1eed96a453f0c09a86 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:51:26 +0000 Subject: [PATCH 322/532] feat(api): OpenAPI spec update via Stainless API (#803) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4d42c2df933..d3fe501a329 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml From 442f36f79e7159a4c3787d6add16016b02f96941 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:53:45 +0000 Subject: [PATCH 323/532] feat(api): OpenAPI spec update via Stainless API (#804) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d3fe501a329..4d42c2df933 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml From 58169cc0744c229644294f6da4ad2782df9e3b6b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:55:54 +0000 Subject: [PATCH 324/532] feat(api): OpenAPI spec update via Stainless API (#805) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4d42c2df933..d3fe501a329 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml From 565b4a2c1a454cd4d47ccb222cc3d0503c66c571 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 19:59:13 +0000 Subject: [PATCH 325/532] feat(api): OpenAPI spec update via Stainless API (#806) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d3fe501a329..4d42c2df933 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml From c974ba0ad6e771ada9a9d5454e7c24101b725dc9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 21:05:23 +0000 Subject: [PATCH 326/532] feat(api): OpenAPI spec update via Stainless API (#807) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4d42c2df933..d3fe501a329 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b42f6e29f4883eca878ffd5b8350978562a313e526be526c1a5518e74b80c595.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml From 69b665d94d7124e1f4e150d8b9d727e2ec3a5f5b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 21:07:29 +0000 Subject: [PATCH 327/532] feat(api): OpenAPI spec update via Stainless API (#808) --- .stats.yml | 2 +- src/cloudflare/types/healthchecks/http_configuration.py | 4 ++-- src/cloudflare/types/healthchecks/http_configuration_param.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index d3fe501a329..9794221f660 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-909b9ecb3be7ec2f54817533e4ea551d1eac37c0df72ec91b5c9179f9e8195c1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e86b7715a3c49ac07162a99020f24e8ebe362cd2b6ace2d9d4f96e33bdec729d.yml diff --git a/src/cloudflare/types/healthchecks/http_configuration.py b/src/cloudflare/types/healthchecks/http_configuration.py index e7816f99ec0..b000623d5f9 100644 --- a/src/cloudflare/types/healthchecks/http_configuration.py +++ b/src/cloudflare/types/healthchecks/http_configuration.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Optional from typing_extensions import Literal from ..._models import BaseModel @@ -28,7 +28,7 @@ class HTTPConfiguration(BaseModel): follow_redirects: Optional[bool] = None """Follow redirects if the origin returns a 3xx status code.""" - header: Optional[object] = None + header: Optional[Dict[str, List[str]]] = None """The HTTP request headers to send in the health check. It is recommended you set a Host header by default. The User-Agent header cannot diff --git a/src/cloudflare/types/healthchecks/http_configuration_param.py b/src/cloudflare/types/healthchecks/http_configuration_param.py index 1b97f2f53c5..f8f0bc4ac32 100644 --- a/src/cloudflare/types/healthchecks/http_configuration_param.py +++ b/src/cloudflare/types/healthchecks/http_configuration_param.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Optional +from typing import Dict, List, Optional from typing_extensions import Literal, TypedDict __all__ = ["HTTPConfigurationParam"] @@ -28,7 +28,7 @@ class HTTPConfigurationParam(TypedDict, total=False): follow_redirects: bool """Follow redirects if the origin returns a 3xx status code.""" - header: Optional[object] + header: Optional[Dict[str, List[str]]] """The HTTP request headers to send in the health check. It is recommended you set a Host header by default. The User-Agent header cannot From 9d23770ed3153efe957cb14a51c6bdf9545a2af7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 03:55:22 +0000 Subject: [PATCH 328/532] feat(api): update via SDK Studio (#809) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9794221f660..c598bba4c51 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e86b7715a3c49ac07162a99020f24e8ebe362cd2b6ace2d9d4f96e33bdec729d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a251d357720416104482b5ef46e7fd51961fdaf6f3104d36b04f1bd51809cfb.yml From d2a77f29c75f3bd4bf8287e3f1479588f478f338 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 07:46:33 +0000 Subject: [PATCH 329/532] feat(api): OpenAPI spec update via Stainless API (#810) --- .stats.yml | 2 +- .../types/zero_trust/risk_scoring/behaviour_update_params.py | 4 ++-- .../types/zero_trust/risk_scoring/summary_get_response.py | 2 +- src/cloudflare/types/zero_trust/risk_scoring_get_response.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index c598bba4c51..f97096b9f52 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a251d357720416104482b5ef46e7fd51961fdaf6f3104d36b04f1bd51809cfb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4d641c65ec0fe43d3f8f3f2b13ec8ef70a7d9c4f4d2cb10679ccc140fdd143c3.yml diff --git a/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py index c0180b2da17..87299513320 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict from typing_extensions import Literal, Required, TypedDict __all__ = ["BehaviourUpdateParams", "Behaviors"] @@ -15,4 +15,4 @@ class BehaviourUpdateParams(TypedDict, total=False): class Behaviors(TypedDict, total=False): enabled: Required[bool] - risk_level: Required[Optional[Literal["low", "medium", "high"]]] + risk_level: Required[Literal["low", "medium", "high"]] diff --git a/src/cloudflare/types/zero_trust/risk_scoring/summary_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring/summary_get_response.py index c15eb288655..8af39df8b36 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring/summary_get_response.py +++ b/src/cloudflare/types/zero_trust/risk_scoring/summary_get_response.py @@ -16,7 +16,7 @@ class User(BaseModel): last_event: datetime - max_risk_level: Optional[Literal["low", "medium", "high"]] = None + max_risk_level: Literal["low", "medium", "high"] name: str diff --git a/src/cloudflare/types/zero_trust/risk_scoring_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring_get_response.py index 2b6ae19f438..74c48968647 100644 --- a/src/cloudflare/types/zero_trust/risk_scoring_get_response.py +++ b/src/cloudflare/types/zero_trust/risk_scoring_get_response.py @@ -14,7 +14,7 @@ class Event(BaseModel): name: str - risk_level: Optional[Literal["low", "medium", "high"]] = None + risk_level: Literal["low", "medium", "high"] timestamp: datetime From 8f5a33d507d165445ad10c23c249076cfc30847a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 07:48:51 +0000 Subject: [PATCH 330/532] feat(api): OpenAPI spec update via Stainless API (#811) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f97096b9f52..c598bba4c51 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4d641c65ec0fe43d3f8f3f2b13ec8ef70a7d9c4f4d2cb10679ccc140fdd143c3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a251d357720416104482b5ef46e7fd51961fdaf6f3104d36b04f1bd51809cfb.yml From 835829aa939117e91cfd20839de9ef5029bab0c9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:14:42 +0000 Subject: [PATCH 331/532] feat(api): OpenAPI spec update via Stainless API (#812) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c598bba4c51..9794221f660 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a251d357720416104482b5ef46e7fd51961fdaf6f3104d36b04f1bd51809cfb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e86b7715a3c49ac07162a99020f24e8ebe362cd2b6ace2d9d4f96e33bdec729d.yml From dd703c4841fa9a7094057543681fb4e9f97f5d6a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:25:43 +0000 Subject: [PATCH 332/532] feat(api): OpenAPI spec update via Stainless API (#813) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9794221f660..c598bba4c51 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e86b7715a3c49ac07162a99020f24e8ebe362cd2b6ace2d9d4f96e33bdec729d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a251d357720416104482b5ef46e7fd51961fdaf6f3104d36b04f1bd51809cfb.yml From 2b107f5ebc465c519b9df346af86134bf6306011 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:27:49 +0000 Subject: [PATCH 333/532] feat(api): OpenAPI spec update via Stainless API (#814) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c598bba4c51..9794221f660 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a251d357720416104482b5ef46e7fd51961fdaf6f3104d36b04f1bd51809cfb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e86b7715a3c49ac07162a99020f24e8ebe362cd2b6ace2d9d4f96e33bdec729d.yml From 063d1f3067e2427b978e03f93de0a87b8747044d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:33:35 +0000 Subject: [PATCH 334/532] feat(api): OpenAPI spec update via Stainless API (#815) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9794221f660..1294b789483 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e86b7715a3c49ac07162a99020f24e8ebe362cd2b6ace2d9d4f96e33bdec729d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-04b940c9141154f42fa17e1b4eba14b56e9adf9ba62d92c1bb61ab180531b928.yml From 98426f4c32e3421b4e67273e3d85024bc4cfedb8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:35:39 +0000 Subject: [PATCH 335/532] feat(api): OpenAPI spec update via Stainless API (#816) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1294b789483..c598bba4c51 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-04b940c9141154f42fa17e1b4eba14b56e9adf9ba62d92c1bb61ab180531b928.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a251d357720416104482b5ef46e7fd51961fdaf6f3104d36b04f1bd51809cfb.yml From f4f82f499061ae2a924b85f8c6328c7f6e13123b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:41:23 +0000 Subject: [PATCH 336/532] feat(api): OpenAPI spec update via Stainless API (#817) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c598bba4c51..1294b789483 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9a251d357720416104482b5ef46e7fd51961fdaf6f3104d36b04f1bd51809cfb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-04b940c9141154f42fa17e1b4eba14b56e9adf9ba62d92c1bb61ab180531b928.yml From b3fc97d2227f3607a02f26499c15fd8c70f0489d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:43:26 +0000 Subject: [PATCH 337/532] feat(api): OpenAPI spec update via Stainless API (#818) --- .stats.yml | 2 +- src/cloudflare/resources/radar/http/ases/os.py | 4 ++-- src/cloudflare/resources/radar/http/locations/os.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1294b789483..4aee698a35e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-04b940c9141154f42fa17e1b4eba14b56e9adf9ba62d92c1bb61ab180531b928.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-21481e672b35bdfdd6e4482f28cd9a5ac58ddff62f5b8506a3de0d53d58572fe.yml diff --git a/src/cloudflare/resources/radar/http/ases/os.py b/src/cloudflare/resources/radar/http/ases/os.py index 70dcdf4f079..33c0223fddf 100644 --- a/src/cloudflare/resources/radar/http/ases/os.py +++ b/src/cloudflare/resources/radar/http/ases/os.py @@ -91,7 +91,7 @@ def get( systems. Values are a percentage out of the total traffic. Args: - os: IP version. + os: Operating system. asn: Array of comma separated list of ASNs, start with `-` to exclude from results. For example, `-174, 3356` excludes results from AS174, but includes results from @@ -238,7 +238,7 @@ async def get( systems. Values are a percentage out of the total traffic. Args: - os: IP version. + os: Operating system. asn: Array of comma separated list of ASNs, start with `-` to exclude from results. For example, `-174, 3356` excludes results from AS174, but includes results from diff --git a/src/cloudflare/resources/radar/http/locations/os.py b/src/cloudflare/resources/radar/http/locations/os.py index 12e9f4512d0..1b89d9d2a66 100644 --- a/src/cloudflare/resources/radar/http/locations/os.py +++ b/src/cloudflare/resources/radar/http/locations/os.py @@ -91,7 +91,7 @@ def get( Values are a percentage out of the total traffic. Args: - os: IP version. + os: Operating system. asn: Array of comma separated list of ASNs, start with `-` to exclude from results. For example, `-174, 3356` excludes results from AS174, but includes results from @@ -238,7 +238,7 @@ async def get( Values are a percentage out of the total traffic. Args: - os: IP version. + os: Operating system. asn: Array of comma separated list of ASNs, start with `-` to exclude from results. For example, `-174, 3356` excludes results from AS174, but includes results from From 0592df806648374da2f0a96c5d5ebc679e93b140 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:53:18 +0000 Subject: [PATCH 338/532] feat(api): OpenAPI spec update via Stainless API (#819) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4aee698a35e..8e47fa9598b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-21481e672b35bdfdd6e4482f28cd9a5ac58ddff62f5b8506a3de0d53d58572fe.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1a0beb27a59a3abb36f2931ebc3fc1bcbf0f91a8da100fc87d2254a85549879b.yml From d3c3d58c9b132f63415583fa0804f606688696ef Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:03:45 +0000 Subject: [PATCH 339/532] feat(api): OpenAPI spec update via Stainless API (#820) --- .stats.yml | 2 +- .../resources/zones/dns_settings.py | 25 ++++++++++ src/cloudflare/types/zones/dns_setting.py | 47 +++++++++++++++++- .../types/zones/dns_setting_edit_params.py | 48 ++++++++++++++++++- .../api_resources/zones/test_dns_settings.py | 22 +++++++++ 5 files changed, 140 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8e47fa9598b..389fe251734 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1a0beb27a59a3abb36f2931ebc3fc1bcbf0f91a8da100fc87d2254a85549879b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-13157b0171e236329a3811eedbce4e5b71b517be66de1126b5dcb6ac4b964ee6.yml diff --git a/src/cloudflare/resources/zones/dns_settings.py b/src/cloudflare/resources/zones/dns_settings.py index 6da4a2d86ff..072889b3538 100644 --- a/src/cloudflare/resources/zones/dns_settings.py +++ b/src/cloudflare/resources/zones/dns_settings.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Type, Optional, cast +from typing_extensions import Literal import httpx @@ -46,7 +47,10 @@ def edit( foundation_dns: bool | NotGiven = NOT_GIVEN, multi_provider: bool | NotGiven = NOT_GIVEN, nameservers: NameserverParam | NotGiven = NOT_GIVEN, + ns_ttl: float | NotGiven = NOT_GIVEN, secondary_overrides: bool | NotGiven = NOT_GIVEN, + soa: dns_setting_edit_params.Soa | NotGiven = NOT_GIVEN, + zone_mode: Literal["standard", "cdn_only", "dns_only"] | 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, @@ -68,9 +72,15 @@ def edit( nameservers: Settings determining the nameservers through which the zone should be available. + ns_ttl: The time to live (TTL) of the zone's nameserver (NS) records. + secondary_overrides: Allows a Secondary DNS zone to use (proxied) override records and CNAME flattening at the zone apex. + soa: Components of the zone's SOA record. + + zone_mode: Whether the zone mode is a regular or CDN/DNS only zone. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -88,7 +98,10 @@ def edit( "foundation_dns": foundation_dns, "multi_provider": multi_provider, "nameservers": nameservers, + "ns_ttl": ns_ttl, "secondary_overrides": secondary_overrides, + "soa": soa, + "zone_mode": zone_mode, }, dns_setting_edit_params.DNSSettingEditParams, ), @@ -158,7 +171,10 @@ async def edit( foundation_dns: bool | NotGiven = NOT_GIVEN, multi_provider: bool | NotGiven = NOT_GIVEN, nameservers: NameserverParam | NotGiven = NOT_GIVEN, + ns_ttl: float | NotGiven = NOT_GIVEN, secondary_overrides: bool | NotGiven = NOT_GIVEN, + soa: dns_setting_edit_params.Soa | NotGiven = NOT_GIVEN, + zone_mode: Literal["standard", "cdn_only", "dns_only"] | 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, @@ -180,9 +196,15 @@ async def edit( nameservers: Settings determining the nameservers through which the zone should be available. + ns_ttl: The time to live (TTL) of the zone's nameserver (NS) records. + secondary_overrides: Allows a Secondary DNS zone to use (proxied) override records and CNAME flattening at the zone apex. + soa: Components of the zone's SOA record. + + zone_mode: Whether the zone mode is a regular or CDN/DNS only zone. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -200,7 +222,10 @@ async def edit( "foundation_dns": foundation_dns, "multi_provider": multi_provider, "nameservers": nameservers, + "ns_ttl": ns_ttl, "secondary_overrides": secondary_overrides, + "soa": soa, + "zone_mode": zone_mode, }, dns_setting_edit_params.DNSSettingEditParams, ), diff --git a/src/cloudflare/types/zones/dns_setting.py b/src/cloudflare/types/zones/dns_setting.py index ea337af7a25..81ac77cb2cd 100644 --- a/src/cloudflare/types/zones/dns_setting.py +++ b/src/cloudflare/types/zones/dns_setting.py @@ -1,11 +1,47 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import Optional +from typing_extensions import Literal from ..._models import BaseModel from .nameserver import Nameserver -__all__ = ["DNSSetting"] +__all__ = ["DNSSetting", "Soa"] + + +class Soa(BaseModel): + expire: float + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: float + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: str + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: float + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: float + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: str + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: float + """The time to live (TTL) of the SOA record itself.""" class DNSSetting(BaseModel): @@ -24,8 +60,17 @@ class DNSSetting(BaseModel): Settings determining the nameservers through which the zone should be available. """ + ns_ttl: Optional[float] = None + """The time to live (TTL) of the zone's nameserver (NS) records.""" + secondary_overrides: Optional[bool] = None """ Allows a Secondary DNS zone to use (proxied) override records and CNAME flattening at the zone apex. """ + + soa: Optional[Soa] = None + """Components of the zone's SOA record.""" + + zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]] = None + """Whether the zone mode is a regular or CDN/DNS only zone.""" diff --git a/src/cloudflare/types/zones/dns_setting_edit_params.py b/src/cloudflare/types/zones/dns_setting_edit_params.py index fa2cdb1dca2..431cafab4c0 100644 --- a/src/cloudflare/types/zones/dns_setting_edit_params.py +++ b/src/cloudflare/types/zones/dns_setting_edit_params.py @@ -2,11 +2,11 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict from .nameserver_param import NameserverParam -__all__ = ["DNSSettingEditParams"] +__all__ = ["DNSSettingEditParams", "Soa"] class DNSSettingEditParams(TypedDict, total=False): @@ -28,8 +28,52 @@ class DNSSettingEditParams(TypedDict, total=False): Settings determining the nameservers through which the zone should be available. """ + ns_ttl: float + """The time to live (TTL) of the zone's nameserver (NS) records.""" + secondary_overrides: bool """ Allows a Secondary DNS zone to use (proxied) override records and CNAME flattening at the zone apex. """ + + soa: Soa + """Components of the zone's SOA record.""" + + zone_mode: Literal["standard", "cdn_only", "dns_only"] + """Whether the zone mode is a regular or CDN/DNS only zone.""" + + +class Soa(TypedDict, total=False): + expire: Required[float] + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: Required[float] + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: Required[str] + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: Required[float] + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: Required[float] + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: Required[str] + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: Required[float] + """The time to live (TTL) of the SOA record itself.""" diff --git a/tests/api_resources/zones/test_dns_settings.py b/tests/api_resources/zones/test_dns_settings.py index d9df4b018c9..db759678ffa 100644 --- a/tests/api_resources/zones/test_dns_settings.py +++ b/tests/api_resources/zones/test_dns_settings.py @@ -31,7 +31,18 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: foundation_dns=False, multi_provider=False, nameservers={"type": "cloudflare.standard"}, + ns_ttl=86400, secondary_overrides=False, + soa={ + "expire": 604800, + "min_ttl": 1800, + "mname": "kristina.ns.cloudflare.com", + "refresh": 10000, + "retry": 2400, + "rname": "admin.example.com", + "ttl": 3600, + }, + zone_mode="dns_only", ) assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @@ -122,7 +133,18 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) foundation_dns=False, multi_provider=False, nameservers={"type": "cloudflare.standard"}, + ns_ttl=86400, secondary_overrides=False, + soa={ + "expire": 604800, + "min_ttl": 1800, + "mname": "kristina.ns.cloudflare.com", + "refresh": 10000, + "retry": 2400, + "rname": "admin.example.com", + "ttl": 3600, + }, + zone_mode="dns_only", ) assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) From f0c83e009e1938d57c261bda5af2e7ba4c3bdfd4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:14:30 +0000 Subject: [PATCH 340/532] feat(api): OpenAPI spec update via Stainless API (#821) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 389fe251734..3ef5620f3f9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-13157b0171e236329a3811eedbce4e5b71b517be66de1126b5dcb6ac4b964ee6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e14af815e43a68175aaf8a216fcfa98f21d3c9112bd1f52cc4235fe2de4d9ab7.yml From f61c978ec97810f9d8e9e81c1ad593c95fd1d82c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:16:43 +0000 Subject: [PATCH 341/532] feat(api): OpenAPI spec update via Stainless API (#822) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3ef5620f3f9..389fe251734 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e14af815e43a68175aaf8a216fcfa98f21d3c9112bd1f52cc4235fe2de4d9ab7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-13157b0171e236329a3811eedbce4e5b71b517be66de1126b5dcb6ac4b964ee6.yml From f3749fd6d003e3c8fd5da4a5a0c136e469d4c2e9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:32:24 +0000 Subject: [PATCH 342/532] feat(api): OpenAPI spec update via Stainless API (#823) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 389fe251734..3ef5620f3f9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-13157b0171e236329a3811eedbce4e5b71b517be66de1126b5dcb6ac4b964ee6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e14af815e43a68175aaf8a216fcfa98f21d3c9112bd1f52cc4235fe2de4d9ab7.yml From 3830cdae38c5feff3a6e50a81ca766b9b31f9b14 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 14:34:36 +0000 Subject: [PATCH 343/532] feat(api): OpenAPI spec update via Stainless API (#824) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3ef5620f3f9..7fa973bc0a2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e14af815e43a68175aaf8a216fcfa98f21d3c9112bd1f52cc4235fe2de4d9ab7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e66e92d0687b69f40ef0b8d565b7922f58ff978707971ff52ab5125b6e9b624f.yml From c3a0ecc86f1df1d40c4da016b032aee4be65ac86 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:10:57 +0000 Subject: [PATCH 344/532] feat(api): OpenAPI spec update via Stainless API (#825) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7fa973bc0a2..3ef5620f3f9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e66e92d0687b69f40ef0b8d565b7922f58ff978707971ff52ab5125b6e9b624f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e14af815e43a68175aaf8a216fcfa98f21d3c9112bd1f52cc4235fe2de4d9ab7.yml From f47e0885d02b32499cdb6e4428b6bf1ba775bf70 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:49:51 +0000 Subject: [PATCH 345/532] feat(api): OpenAPI spec update via Stainless API (#826) --- .stats.yml | 2 +- src/cloudflare/types/ai_gateway/log_get_response.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3ef5620f3f9..ee7b1b5c5c6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e14af815e43a68175aaf8a216fcfa98f21d3c9112bd1f52cc4235fe2de4d9ab7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a9fac2ac06a106ac7e616a6b77e657a85e0f9f5549ac2452a52fe4f25c4f3c2c.yml diff --git a/src/cloudflare/types/ai_gateway/log_get_response.py b/src/cloudflare/types/ai_gateway/log_get_response.py index 9a83c1d7a88..fd96ae02af1 100644 --- a/src/cloudflare/types/ai_gateway/log_get_response.py +++ b/src/cloudflare/types/ai_gateway/log_get_response.py @@ -35,7 +35,11 @@ class LogGetResponseItem(BaseModel): metadata: Optional[str] = None + request_type: Optional[str] = None + status_code: Optional[int] = None + step: Optional[int] = None + LogGetResponse = List[LogGetResponseItem] From 82a67f8fe5be49f2db639f4f9d22a5b531272a2d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:53:51 +0000 Subject: [PATCH 346/532] feat(api): OpenAPI spec update via Stainless API (#827) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ee7b1b5c5c6..e98dfa2a0d4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a9fac2ac06a106ac7e616a6b77e657a85e0f9f5549ac2452a52fe4f25c4f3c2c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0a2bc66945b61dcaf2a072fae9ef790ac10749897eb72a18cf5b761ce5d1b652.yml From 53c19b3eaa76ce8cf8519f045abf6f7d3210a070 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:56:00 +0000 Subject: [PATCH 347/532] feat(api): OpenAPI spec update via Stainless API (#828) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e98dfa2a0d4..ee7b1b5c5c6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0a2bc66945b61dcaf2a072fae9ef790ac10749897eb72a18cf5b761ce5d1b652.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a9fac2ac06a106ac7e616a6b77e657a85e0f9f5549ac2452a52fe4f25c4f3c2c.yml From 218645a9acae1c15994b3c2d31bf570bf31fd4f0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:22:34 +0000 Subject: [PATCH 348/532] feat(api): OpenAPI spec update via Stainless API (#829) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ee7b1b5c5c6..b2eb98d3179 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a9fac2ac06a106ac7e616a6b77e657a85e0f9f5549ac2452a52fe4f25c4f3c2c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-010654edb215153d26f382879c3dc51793da44932d6330b6c5a3526f40cda19f.yml From 8668e02b24f1e0363cf61f939264df634eeae1a4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:10:47 +0000 Subject: [PATCH 349/532] feat(api): OpenAPI spec update via Stainless API (#830) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b2eb98d3179..9aab24e0fbb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-010654edb215153d26f382879c3dc51793da44932d6330b6c5a3526f40cda19f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5829869c29e9a52d01f33a21128b7ddd518522ddc58198d588d898d53668d371.yml From 442584f708be371e7717030f50de9ba147f1f879 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:27:22 +0000 Subject: [PATCH 350/532] feat(api): OpenAPI spec update via Stainless API (#831) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9aab24e0fbb..e98dfa2a0d4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5829869c29e9a52d01f33a21128b7ddd518522ddc58198d588d898d53668d371.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0a2bc66945b61dcaf2a072fae9ef790ac10749897eb72a18cf5b761ce5d1b652.yml From fff2454d959b7ee206f740e1134c268492d579c0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:34:07 +0000 Subject: [PATCH 351/532] feat(api): OpenAPI spec update via Stainless API (#832) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e98dfa2a0d4..ee7b1b5c5c6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0a2bc66945b61dcaf2a072fae9ef790ac10749897eb72a18cf5b761ce5d1b652.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a9fac2ac06a106ac7e616a6b77e657a85e0f9f5549ac2452a52fe4f25c4f3c2c.yml From 7ee6553a4ce1f41f7d005e30aa9cf42edb2aa1a8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 21:43:40 +0000 Subject: [PATCH 352/532] feat(api): OpenAPI spec update via Stainless API (#833) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ee7b1b5c5c6..ba2298a7015 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1335 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a9fac2ac06a106ac7e616a6b77e657a85e0f9f5549ac2452a52fe4f25c4f3c2c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-563da3da7347fb7ce5676737cc6a457de5da7c96aa7d44098a9db3b2fb8d6599.yml From 11bb6dd69fb5b3e8f872056580da76f62b2a2852 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:43:09 +0000 Subject: [PATCH 353/532] feat(api): update via SDK Studio (#834) --- src/cloudflare/resources/zones/dns_settings.py | 4 ++-- src/cloudflare/types/zones/dns_setting.py | 6 +++--- src/cloudflare/types/zones/dns_setting_edit_params.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cloudflare/resources/zones/dns_settings.py b/src/cloudflare/resources/zones/dns_settings.py index 072889b3538..5460d1f4c9c 100644 --- a/src/cloudflare/resources/zones/dns_settings.py +++ b/src/cloudflare/resources/zones/dns_settings.py @@ -49,7 +49,7 @@ def edit( nameservers: NameserverParam | NotGiven = NOT_GIVEN, ns_ttl: float | NotGiven = NOT_GIVEN, secondary_overrides: bool | NotGiven = NOT_GIVEN, - soa: dns_setting_edit_params.Soa | NotGiven = NOT_GIVEN, + soa: dns_setting_edit_params.SOA | NotGiven = NOT_GIVEN, zone_mode: Literal["standard", "cdn_only", "dns_only"] | 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. @@ -173,7 +173,7 @@ async def edit( nameservers: NameserverParam | NotGiven = NOT_GIVEN, ns_ttl: float | NotGiven = NOT_GIVEN, secondary_overrides: bool | NotGiven = NOT_GIVEN, - soa: dns_setting_edit_params.Soa | NotGiven = NOT_GIVEN, + soa: dns_setting_edit_params.SOA | NotGiven = NOT_GIVEN, zone_mode: Literal["standard", "cdn_only", "dns_only"] | 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. diff --git a/src/cloudflare/types/zones/dns_setting.py b/src/cloudflare/types/zones/dns_setting.py index 81ac77cb2cd..c96b14afb67 100644 --- a/src/cloudflare/types/zones/dns_setting.py +++ b/src/cloudflare/types/zones/dns_setting.py @@ -6,10 +6,10 @@ from ..._models import BaseModel from .nameserver import Nameserver -__all__ = ["DNSSetting", "Soa"] +__all__ = ["DNSSetting", "SOA"] -class Soa(BaseModel): +class SOA(BaseModel): expire: float """ Time in seconds of being unable to query the primary server after which @@ -69,7 +69,7 @@ class DNSSetting(BaseModel): flattening at the zone apex. """ - soa: Optional[Soa] = None + soa: Optional[SOA] = None """Components of the zone's SOA record.""" zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]] = None diff --git a/src/cloudflare/types/zones/dns_setting_edit_params.py b/src/cloudflare/types/zones/dns_setting_edit_params.py index 431cafab4c0..96739b9404c 100644 --- a/src/cloudflare/types/zones/dns_setting_edit_params.py +++ b/src/cloudflare/types/zones/dns_setting_edit_params.py @@ -6,7 +6,7 @@ from .nameserver_param import NameserverParam -__all__ = ["DNSSettingEditParams", "Soa"] +__all__ = ["DNSSettingEditParams", "SOA"] class DNSSettingEditParams(TypedDict, total=False): @@ -37,14 +37,14 @@ class DNSSettingEditParams(TypedDict, total=False): flattening at the zone apex. """ - soa: Soa + soa: SOA """Components of the zone's SOA record.""" zone_mode: Literal["standard", "cdn_only", "dns_only"] """Whether the zone mode is a regular or CDN/DNS only zone.""" -class Soa(TypedDict, total=False): +class SOA(TypedDict, total=False): expire: Required[float] """ Time in seconds of being unable to query the primary server after which From df5ef97507b50a14aefafd0d908ce703ae7ca075 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 22:50:39 +0000 Subject: [PATCH 354/532] feat(api): update via SDK Studio (#835) --- .stats.yml | 2 +- api.md | 34 ++- src/cloudflare/resources/radar/bgp/routes.py | 135 +++++++++- src/cloudflare/resources/radar/http/http.py | 247 ++++++++++++++++++ .../resources/workers/ai/__init__.py | 33 +++ .../resources/workers/{ => ai}/ai.py | 51 +++- .../resources/workers/ai/models/__init__.py | 33 +++ .../resources/workers/ai/models/models.py | 80 ++++++ .../resources/workers/ai/models/schema.py | 166 ++++++++++++ src/cloudflare/resources/workers/workers.py | 1 + src/cloudflare/types/radar/__init__.py | 2 + src/cloudflare/types/radar/bgp/__init__.py | 2 + .../types/radar/bgp/route_ases_params.py | 29 ++ .../types/radar/bgp/route_ases_response.py | 57 ++++ .../types/radar/http_timeseries_params.py | 81 ++++++ .../types/radar/http_timeseries_response.py | 69 +++++ src/cloudflare/types/workers/ai/__init__.py | 3 + .../types/workers/ai/models/__init__.py | 5 + .../workers/ai/models/schema_get_params.py | 14 + tests/api_resources/radar/bgp/test_routes.py | 73 ++++++ tests/api_resources/radar/test_http.py | 119 +++++++++ tests/api_resources/workers/ai/__init__.py | 1 + .../workers/ai/models/__init__.py | 1 + .../workers/ai/models/test_schema.py | 105 ++++++++ 24 files changed, 1330 insertions(+), 13 deletions(-) create mode 100644 src/cloudflare/resources/workers/ai/__init__.py rename src/cloudflare/resources/workers/{ => ai}/ai.py (96%) create mode 100644 src/cloudflare/resources/workers/ai/models/__init__.py create mode 100644 src/cloudflare/resources/workers/ai/models/models.py create mode 100644 src/cloudflare/resources/workers/ai/models/schema.py create mode 100644 src/cloudflare/types/radar/bgp/route_ases_params.py create mode 100644 src/cloudflare/types/radar/bgp/route_ases_response.py create mode 100644 src/cloudflare/types/radar/http_timeseries_params.py create mode 100644 src/cloudflare/types/radar/http_timeseries_response.py create mode 100644 src/cloudflare/types/workers/ai/__init__.py create mode 100644 src/cloudflare/types/workers/ai/models/__init__.py create mode 100644 src/cloudflare/types/workers/ai/models/schema_get_params.py create mode 100644 tests/api_resources/radar/test_http.py create mode 100644 tests/api_resources/workers/ai/__init__.py create mode 100644 tests/api_resources/workers/ai/models/__init__.py create mode 100644 tests/api_resources/workers/ai/models/test_schema.py diff --git a/.stats.yml b/.stats.yml index ba2298a7015..c10a59bb098 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1335 +configured_endpoints: 1338 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-563da3da7347fb7ce5676737cc6a457de5da7c96aa7d44098a9db3b2fb8d6599.yml diff --git a/api.md b/api.md index 14aaae3917c..330a480993e 100644 --- a/api.md +++ b/api.md @@ -2655,7 +2655,21 @@ from cloudflare.types.workers import AIRunResponse Methods: -- client.workers.ai.run(model_name, \*, account_id, \*\*params) -> Optional +- client.workers.ai.run(model_name, \*, account_id, \*\*params) -> Optional + +### Models + +#### Schema + +Types: + +```python +from cloudflare.types.workers.ai.models import SchemaGetResponse +``` + +Methods: + +- client.workers.ai.models.schema.get(\*, account_id, \*\*params) -> object ## Scripts @@ -6494,11 +6508,17 @@ Methods: Types: ```python -from cloudflare.types.radar.bgp import RouteMoasResponse, RoutePfx2asResponse, RouteStatsResponse +from cloudflare.types.radar.bgp import ( + RouteAsesResponse, + RouteMoasResponse, + RoutePfx2asResponse, + RouteStatsResponse, +) ``` Methods: +- client.radar.bgp.routes.ases(\*\*params) -> RouteAsesResponse - client.radar.bgp.routes.moas(\*\*params) -> RouteMoasResponse - client.radar.bgp.routes.pfx2as(\*\*params) -> RoutePfx2asResponse - client.radar.bgp.routes.stats(\*\*params) -> RouteStatsResponse @@ -7113,6 +7133,16 @@ Methods: ## HTTP +Types: + +```python +from cloudflare.types.radar import HTTPTimeseriesResponse +``` + +Methods: + +- client.radar.http.timeseries(\*\*params) -> HTTPTimeseriesResponse + ### Top Types: diff --git a/src/cloudflare/resources/radar/bgp/routes.py b/src/cloudflare/resources/radar/bgp/routes.py index 4f993e592f5..104c66fdd4d 100644 --- a/src/cloudflare/resources/radar/bgp/routes.py +++ b/src/cloudflare/resources/radar/bgp/routes.py @@ -24,7 +24,8 @@ from ...._base_client import ( make_request_options, ) -from ....types.radar.bgp import route_moas_params, route_stats_params, route_pfx2as_params +from ....types.radar.bgp import route_ases_params, route_moas_params, route_stats_params, route_pfx2as_params +from ....types.radar.bgp.route_ases_response import RouteAsesResponse from ....types.radar.bgp.route_moas_response import RouteMoasResponse from ....types.radar.bgp.route_stats_response import RouteStatsResponse from ....types.radar.bgp.route_pfx2as_response import RoutePfx2asResponse @@ -41,6 +42,66 @@ def with_raw_response(self) -> RoutesResourceWithRawResponse: def with_streaming_response(self) -> RoutesResourceWithStreamingResponse: return RoutesResourceWithStreamingResponse(self) + def ases( + self, + *, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + location: str | NotGiven = NOT_GIVEN, + sort_by: Literal["cone", "pfxs", "ipv4", "ipv6", "rpki_valid", "rpki_invalid", "rpki_unknown"] + | NotGiven = NOT_GIVEN, + sort_order: Literal["asc", "desc"] | 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, + ) -> RouteAsesResponse: + """ + List all ASes on current global routing tables with routing statistics + + Args: + format: Format results are returned in. + + limit: Limit the number of objects in the response. + + location: Location Alpha2 code. + + sort_by: Return order results by given type + + sort_order: Sort by value ascending or descending + + 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 + """ + return self._get( + "/radar/bgp/routes/ases", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "format": format, + "limit": limit, + "location": location, + "sort_by": sort_by, + "sort_order": sort_order, + }, + route_ases_params.RouteAsesParams, + ), + post_parser=ResultWrapper[RouteAsesResponse]._unwrapper, + ), + cast_to=cast(Type[RouteAsesResponse], ResultWrapper[RouteAsesResponse]), + ) + def moas( self, *, @@ -217,6 +278,66 @@ def with_raw_response(self) -> AsyncRoutesResourceWithRawResponse: def with_streaming_response(self) -> AsyncRoutesResourceWithStreamingResponse: return AsyncRoutesResourceWithStreamingResponse(self) + async def ases( + self, + *, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + location: str | NotGiven = NOT_GIVEN, + sort_by: Literal["cone", "pfxs", "ipv4", "ipv6", "rpki_valid", "rpki_invalid", "rpki_unknown"] + | NotGiven = NOT_GIVEN, + sort_order: Literal["asc", "desc"] | 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, + ) -> RouteAsesResponse: + """ + List all ASes on current global routing tables with routing statistics + + Args: + format: Format results are returned in. + + limit: Limit the number of objects in the response. + + location: Location Alpha2 code. + + sort_by: Return order results by given type + + sort_order: Sort by value ascending or descending + + 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 + """ + return await self._get( + "/radar/bgp/routes/ases", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "format": format, + "limit": limit, + "location": location, + "sort_by": sort_by, + "sort_order": sort_order, + }, + route_ases_params.RouteAsesParams, + ), + post_parser=ResultWrapper[RouteAsesResponse]._unwrapper, + ), + cast_to=cast(Type[RouteAsesResponse], ResultWrapper[RouteAsesResponse]), + ) + async def moas( self, *, @@ -388,6 +509,9 @@ class RoutesResourceWithRawResponse: def __init__(self, routes: RoutesResource) -> None: self._routes = routes + self.ases = to_raw_response_wrapper( + routes.ases, + ) self.moas = to_raw_response_wrapper( routes.moas, ) @@ -403,6 +527,9 @@ class AsyncRoutesResourceWithRawResponse: def __init__(self, routes: AsyncRoutesResource) -> None: self._routes = routes + self.ases = async_to_raw_response_wrapper( + routes.ases, + ) self.moas = async_to_raw_response_wrapper( routes.moas, ) @@ -418,6 +545,9 @@ class RoutesResourceWithStreamingResponse: def __init__(self, routes: RoutesResource) -> None: self._routes = routes + self.ases = to_streamed_response_wrapper( + routes.ases, + ) self.moas = to_streamed_response_wrapper( routes.moas, ) @@ -433,6 +563,9 @@ class AsyncRoutesResourceWithStreamingResponse: def __init__(self, routes: AsyncRoutesResource) -> None: self._routes = routes + self.ases = async_to_streamed_response_wrapper( + routes.ases, + ) self.moas = async_to_streamed_response_wrapper( routes.moas, ) diff --git a/src/cloudflare/resources/radar/http/http.py b/src/cloudflare/resources/radar/http/http.py index b8a704fd14d..9f32cbdd054 100644 --- a/src/cloudflare/resources/radar/http/http.py +++ b/src/cloudflare/resources/radar/http/http.py @@ -2,6 +2,12 @@ from __future__ import annotations +from typing import List, Type, Union, cast +from datetime import datetime +from typing_extensions import Literal + +import httpx + from .top import ( TopResource, AsyncTopResource, @@ -26,6 +32,11 @@ SummaryResourceWithStreamingResponse, AsyncSummaryResourceWithStreamingResponse, ) +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) from .ases.ases import AsesResource, AsyncAsesResource from .locations import ( LocationsResource, @@ -37,6 +48,17 @@ ) 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 ....types.radar import http_timeseries_params +from ...._base_client import ( + make_request_options, +) from .timeseries_groups import ( TimeseriesGroupsResource, AsyncTimeseriesGroupsResource, @@ -46,6 +68,7 @@ AsyncTimeseriesGroupsResourceWithStreamingResponse, ) from .locations.locations import LocationsResource, AsyncLocationsResource +from ....types.radar.http_timeseries_response import HTTPTimeseriesResponse __all__ = ["HTTPResource", "AsyncHTTPResource"] @@ -79,6 +102,110 @@ def with_raw_response(self) -> HTTPResourceWithRawResponse: def with_streaming_response(self) -> HTTPResourceWithStreamingResponse: return HTTPResourceWithStreamingResponse(self) + def timeseries( + self, + *, + agg_interval: Literal["15m", "1h", "1d", "1w"] | NotGiven = NOT_GIVEN, + asn: List[str] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[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, + ) -> HTTPTimeseriesResponse: + """ + Get HTTP requests over time. + + Args: + agg_interval: Aggregation interval results should be returned in (for example, in 15 minutes + or 1 hour intervals). Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + format: Format results are returned in. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + 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 + """ + return self._get( + "/radar/http/timeseries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "agg_interval": agg_interval, + "asn": asn, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "location": location, + "name": name, + }, + http_timeseries_params.HTTPTimeseriesParams, + ), + post_parser=ResultWrapper[HTTPTimeseriesResponse]._unwrapper, + ), + cast_to=cast(Type[HTTPTimeseriesResponse], ResultWrapper[HTTPTimeseriesResponse]), + ) + class AsyncHTTPResource(AsyncAPIResource): @cached_property @@ -109,11 +236,119 @@ def with_raw_response(self) -> AsyncHTTPResourceWithRawResponse: def with_streaming_response(self) -> AsyncHTTPResourceWithStreamingResponse: return AsyncHTTPResourceWithStreamingResponse(self) + async def timeseries( + self, + *, + agg_interval: Literal["15m", "1h", "1d", "1w"] | NotGiven = NOT_GIVEN, + asn: List[str] | NotGiven = NOT_GIVEN, + continent: List[str] | NotGiven = NOT_GIVEN, + date_end: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + date_range: List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ] + | NotGiven = NOT_GIVEN, + date_start: List[Union[str, datetime]] | NotGiven = NOT_GIVEN, + format: Literal["JSON", "CSV"] | NotGiven = NOT_GIVEN, + location: List[str] | NotGiven = NOT_GIVEN, + name: List[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, + ) -> HTTPTimeseriesResponse: + """ + Get HTTP requests over time. + + Args: + agg_interval: Aggregation interval results should be returned in (for example, in 15 minutes + or 1 hour intervals). Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + + asn: Array of comma separated list of ASNs, start with `-` to exclude from results. + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + + continent: Array of comma separated list of continents (alpha-2 continent codes). Start + with `-` to exclude from results. For example, `-EU,NA` excludes results from + Europe, but includes results from North America. + + date_end: End of the date range (inclusive). + + date_range: For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + + date_start: Array of datetimes to filter the start of a series. + + format: Format results are returned in. + + location: Array of comma separated list of locations (alpha-2 country codes). Start with + `-` to exclude from results. For example, `-US,PT` excludes results from the US, + but includes results from PT. + + name: Array of names that will be used to name the series in responses. + + 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 + """ + return await self._get( + "/radar/http/timeseries", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "agg_interval": agg_interval, + "asn": asn, + "continent": continent, + "date_end": date_end, + "date_range": date_range, + "date_start": date_start, + "format": format, + "location": location, + "name": name, + }, + http_timeseries_params.HTTPTimeseriesParams, + ), + post_parser=ResultWrapper[HTTPTimeseriesResponse]._unwrapper, + ), + cast_to=cast(Type[HTTPTimeseriesResponse], ResultWrapper[HTTPTimeseriesResponse]), + ) + class HTTPResourceWithRawResponse: def __init__(self, http: HTTPResource) -> None: self._http = http + self.timeseries = to_raw_response_wrapper( + http.timeseries, + ) + @cached_property def top(self) -> TopResourceWithRawResponse: return TopResourceWithRawResponse(self._http.top) @@ -139,6 +374,10 @@ class AsyncHTTPResourceWithRawResponse: def __init__(self, http: AsyncHTTPResource) -> None: self._http = http + self.timeseries = async_to_raw_response_wrapper( + http.timeseries, + ) + @cached_property def top(self) -> AsyncTopResourceWithRawResponse: return AsyncTopResourceWithRawResponse(self._http.top) @@ -164,6 +403,10 @@ class HTTPResourceWithStreamingResponse: def __init__(self, http: HTTPResource) -> None: self._http = http + self.timeseries = to_streamed_response_wrapper( + http.timeseries, + ) + @cached_property def top(self) -> TopResourceWithStreamingResponse: return TopResourceWithStreamingResponse(self._http.top) @@ -189,6 +432,10 @@ class AsyncHTTPResourceWithStreamingResponse: def __init__(self, http: AsyncHTTPResource) -> None: self._http = http + self.timeseries = async_to_streamed_response_wrapper( + http.timeseries, + ) + @cached_property def top(self) -> AsyncTopResourceWithStreamingResponse: return AsyncTopResourceWithStreamingResponse(self._http.top) diff --git a/src/cloudflare/resources/workers/ai/__init__.py b/src/cloudflare/resources/workers/ai/__init__.py new file mode 100644 index 00000000000..4921cf245a4 --- /dev/null +++ b/src/cloudflare/resources/workers/ai/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .ai import ( + AIResource, + AsyncAIResource, + AIResourceWithRawResponse, + AsyncAIResourceWithRawResponse, + AIResourceWithStreamingResponse, + AsyncAIResourceWithStreamingResponse, +) +from .models import ( + ModelsResource, + AsyncModelsResource, + ModelsResourceWithRawResponse, + AsyncModelsResourceWithRawResponse, + ModelsResourceWithStreamingResponse, + AsyncModelsResourceWithStreamingResponse, +) + +__all__ = [ + "ModelsResource", + "AsyncModelsResource", + "ModelsResourceWithRawResponse", + "AsyncModelsResourceWithRawResponse", + "ModelsResourceWithStreamingResponse", + "AsyncModelsResourceWithStreamingResponse", + "AIResource", + "AsyncAIResource", + "AIResourceWithRawResponse", + "AsyncAIResourceWithRawResponse", + "AIResourceWithStreamingResponse", + "AsyncAIResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/workers/ai.py b/src/cloudflare/resources/workers/ai/ai.py similarity index 96% rename from src/cloudflare/resources/workers/ai.py rename to src/cloudflare/resources/workers/ai/ai.py index 4c1f83aed9a..86d294ec5fa 100644 --- a/src/cloudflare/resources/workers/ai.py +++ b/src/cloudflare/resources/workers/ai/ai.py @@ -6,31 +6,44 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( +from .models import ( + ModelsResource, + AsyncModelsResource, + ModelsResourceWithRawResponse, + AsyncModelsResourceWithRawResponse, + ModelsResourceWithStreamingResponse, + AsyncModelsResourceWithStreamingResponse, +) +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( required_args, 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 ( +from ...._wrappers import ResultWrapper +from .models.models import ModelsResource, AsyncModelsResource +from ...._base_client import ( make_request_options, ) -from ...types.workers import ai_run_params -from ...types.workers.ai_run_response import AIRunResponse +from ....types.workers import ai_run_params +from ....types.workers.ai_run_response import AIRunResponse __all__ = ["AIResource", "AsyncAIResource"] class AIResource(SyncAPIResource): + @cached_property + def models(self) -> ModelsResource: + return ModelsResource(self._client) + @cached_property def with_raw_response(self) -> AIResourceWithRawResponse: return AIResourceWithRawResponse(self) @@ -544,6 +557,10 @@ def run( class AsyncAIResource(AsyncAPIResource): + @cached_property + def models(self) -> AsyncModelsResource: + return AsyncModelsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAIResourceWithRawResponse: return AsyncAIResourceWithRawResponse(self) @@ -1064,6 +1081,10 @@ def __init__(self, ai: AIResource) -> None: ai.run, ) + @cached_property + def models(self) -> ModelsResourceWithRawResponse: + return ModelsResourceWithRawResponse(self._ai.models) + class AsyncAIResourceWithRawResponse: def __init__(self, ai: AsyncAIResource) -> None: @@ -1073,6 +1094,10 @@ def __init__(self, ai: AsyncAIResource) -> None: ai.run, ) + @cached_property + def models(self) -> AsyncModelsResourceWithRawResponse: + return AsyncModelsResourceWithRawResponse(self._ai.models) + class AIResourceWithStreamingResponse: def __init__(self, ai: AIResource) -> None: @@ -1082,6 +1107,10 @@ def __init__(self, ai: AIResource) -> None: ai.run, ) + @cached_property + def models(self) -> ModelsResourceWithStreamingResponse: + return ModelsResourceWithStreamingResponse(self._ai.models) + class AsyncAIResourceWithStreamingResponse: def __init__(self, ai: AsyncAIResource) -> None: @@ -1090,3 +1119,7 @@ def __init__(self, ai: AsyncAIResource) -> None: self.run = async_to_streamed_response_wrapper( ai.run, ) + + @cached_property + def models(self) -> AsyncModelsResourceWithStreamingResponse: + return AsyncModelsResourceWithStreamingResponse(self._ai.models) diff --git a/src/cloudflare/resources/workers/ai/models/__init__.py b/src/cloudflare/resources/workers/ai/models/__init__.py new file mode 100644 index 00000000000..9ccd4fa07fb --- /dev/null +++ b/src/cloudflare/resources/workers/ai/models/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .models import ( + ModelsResource, + AsyncModelsResource, + ModelsResourceWithRawResponse, + AsyncModelsResourceWithRawResponse, + ModelsResourceWithStreamingResponse, + AsyncModelsResourceWithStreamingResponse, +) +from .schema import ( + SchemaResource, + AsyncSchemaResource, + SchemaResourceWithRawResponse, + AsyncSchemaResourceWithRawResponse, + SchemaResourceWithStreamingResponse, + AsyncSchemaResourceWithStreamingResponse, +) + +__all__ = [ + "SchemaResource", + "AsyncSchemaResource", + "SchemaResourceWithRawResponse", + "AsyncSchemaResourceWithRawResponse", + "SchemaResourceWithStreamingResponse", + "AsyncSchemaResourceWithStreamingResponse", + "ModelsResource", + "AsyncModelsResource", + "ModelsResourceWithRawResponse", + "AsyncModelsResourceWithRawResponse", + "ModelsResourceWithStreamingResponse", + "AsyncModelsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/workers/ai/models/models.py b/src/cloudflare/resources/workers/ai/models/models.py new file mode 100644 index 00000000000..8f90eb7304d --- /dev/null +++ b/src/cloudflare/resources/workers/ai/models/models.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .schema import ( + SchemaResource, + AsyncSchemaResource, + SchemaResourceWithRawResponse, + AsyncSchemaResourceWithRawResponse, + SchemaResourceWithStreamingResponse, + AsyncSchemaResourceWithStreamingResponse, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["ModelsResource", "AsyncModelsResource"] + + +class ModelsResource(SyncAPIResource): + @cached_property + def schema(self) -> SchemaResource: + return SchemaResource(self._client) + + @cached_property + def with_raw_response(self) -> ModelsResourceWithRawResponse: + return ModelsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ModelsResourceWithStreamingResponse: + return ModelsResourceWithStreamingResponse(self) + + +class AsyncModelsResource(AsyncAPIResource): + @cached_property + def schema(self) -> AsyncSchemaResource: + return AsyncSchemaResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncModelsResourceWithRawResponse: + return AsyncModelsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncModelsResourceWithStreamingResponse: + return AsyncModelsResourceWithStreamingResponse(self) + + +class ModelsResourceWithRawResponse: + def __init__(self, models: ModelsResource) -> None: + self._models = models + + @cached_property + def schema(self) -> SchemaResourceWithRawResponse: + return SchemaResourceWithRawResponse(self._models.schema) + + +class AsyncModelsResourceWithRawResponse: + def __init__(self, models: AsyncModelsResource) -> None: + self._models = models + + @cached_property + def schema(self) -> AsyncSchemaResourceWithRawResponse: + return AsyncSchemaResourceWithRawResponse(self._models.schema) + + +class ModelsResourceWithStreamingResponse: + def __init__(self, models: ModelsResource) -> None: + self._models = models + + @cached_property + def schema(self) -> SchemaResourceWithStreamingResponse: + return SchemaResourceWithStreamingResponse(self._models.schema) + + +class AsyncModelsResourceWithStreamingResponse: + def __init__(self, models: AsyncModelsResource) -> None: + self._models = models + + @cached_property + def schema(self) -> AsyncSchemaResourceWithStreamingResponse: + return AsyncSchemaResourceWithStreamingResponse(self._models.schema) diff --git a/src/cloudflare/resources/workers/ai/models/schema.py b/src/cloudflare/resources/workers/ai/models/schema.py new file mode 100644 index 00000000000..934b517b989 --- /dev/null +++ b/src/cloudflare/resources/workers/ai/models/schema.py @@ -0,0 +1,166 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, cast + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....._wrappers import ResultWrapper +from ....._base_client import ( + make_request_options, +) +from .....types.workers.ai.models import schema_get_params + +__all__ = ["SchemaResource", "AsyncSchemaResource"] + + +class SchemaResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SchemaResourceWithRawResponse: + return SchemaResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SchemaResourceWithStreamingResponse: + return SchemaResourceWithStreamingResponse(self) + + def get( + self, + *, + account_id: str, + model: 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, + ) -> object: + """ + Get Model Schema + + Args: + model: Model Name + + 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}/ai/models/schema", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"model": model}, schema_get_params.SchemaGetParams), + post_parser=ResultWrapper[object]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), + ) + + +class AsyncSchemaResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSchemaResourceWithRawResponse: + return AsyncSchemaResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSchemaResourceWithStreamingResponse: + return AsyncSchemaResourceWithStreamingResponse(self) + + async def get( + self, + *, + account_id: str, + model: 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, + ) -> object: + """ + Get Model Schema + + Args: + model: Model Name + + 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}/ai/models/schema", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform({"model": model}, schema_get_params.SchemaGetParams), + post_parser=ResultWrapper[object]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), + ) + + +class SchemaResourceWithRawResponse: + def __init__(self, schema: SchemaResource) -> None: + self._schema = schema + + self.get = to_raw_response_wrapper( + schema.get, + ) + + +class AsyncSchemaResourceWithRawResponse: + def __init__(self, schema: AsyncSchemaResource) -> None: + self._schema = schema + + self.get = async_to_raw_response_wrapper( + schema.get, + ) + + +class SchemaResourceWithStreamingResponse: + def __init__(self, schema: SchemaResource) -> None: + self._schema = schema + + self.get = to_streamed_response_wrapper( + schema.get, + ) + + +class AsyncSchemaResourceWithStreamingResponse: + def __init__(self, schema: AsyncSchemaResource) -> None: + self._schema = schema + + self.get = async_to_streamed_response_wrapper( + schema.get, + ) diff --git a/src/cloudflare/resources/workers/workers.py b/src/cloudflare/resources/workers/workers.py index 195b4a21670..55326950c01 100644 --- a/src/cloudflare/resources/workers/workers.py +++ b/src/cloudflare/resources/workers/workers.py @@ -10,6 +10,7 @@ AIResourceWithStreamingResponse, AsyncAIResourceWithStreamingResponse, ) +from .ai.ai import AIResource, AsyncAIResource from .domains import ( DomainsResource, AsyncDomainsResource, diff --git a/src/cloudflare/types/radar/__init__.py b/src/cloudflare/types/radar/__init__.py index cacf1e11ece..cab083c87f6 100644 --- a/src/cloudflare/types/radar/__init__.py +++ b/src/cloudflare/types/radar/__init__.py @@ -14,10 +14,12 @@ from .search_global_params import SearchGlobalParams as SearchGlobalParams from .bgp_timeseries_params import BGPTimeseriesParams as BGPTimeseriesParams from .dataset_list_response import DatasetListResponse as DatasetListResponse +from .http_timeseries_params import HTTPTimeseriesParams as HTTPTimeseriesParams from .search_global_response import SearchGlobalResponse as SearchGlobalResponse from .as112_timeseries_params import AS112TimeseriesParams as AS112TimeseriesParams from .bgp_timeseries_response import BGPTimeseriesResponse as BGPTimeseriesResponse from .dataset_download_params import DatasetDownloadParams as DatasetDownloadParams +from .http_timeseries_response import HTTPTimeseriesResponse as HTTPTimeseriesResponse from .as112_timeseries_response import AS112TimeseriesResponse as AS112TimeseriesResponse from .dataset_download_response import DatasetDownloadResponse as DatasetDownloadResponse from .netflow_timeseries_params import NetflowTimeseriesParams as NetflowTimeseriesParams diff --git a/src/cloudflare/types/radar/bgp/__init__.py b/src/cloudflare/types/radar/bgp/__init__.py index abf4e584e4d..fdbf378f666 100644 --- a/src/cloudflare/types/radar/bgp/__init__.py +++ b/src/cloudflare/types/radar/bgp/__init__.py @@ -2,8 +2,10 @@ from __future__ import annotations +from .route_ases_params import RouteAsesParams as RouteAsesParams from .route_moas_params import RouteMoasParams as RouteMoasParams from .route_stats_params import RouteStatsParams as RouteStatsParams +from .route_ases_response import RouteAsesResponse as RouteAsesResponse from .route_moas_response import RouteMoasResponse as RouteMoasResponse from .route_pfx2as_params import RoutePfx2asParams as RoutePfx2asParams from .top_prefixes_params import TopPrefixesParams as TopPrefixesParams diff --git a/src/cloudflare/types/radar/bgp/route_ases_params.py b/src/cloudflare/types/radar/bgp/route_ases_params.py new file mode 100644 index 00000000000..734a74168f0 --- /dev/null +++ b/src/cloudflare/types/radar/bgp/route_ases_params.py @@ -0,0 +1,29 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["RouteAsesParams"] + + +class RouteAsesParams(TypedDict, total=False): + format: Literal["JSON", "CSV"] + """Format results are returned in.""" + + limit: int + """Limit the number of objects in the response.""" + + location: str + """Location Alpha2 code.""" + + sort_by: Annotated[ + Literal["cone", "pfxs", "ipv4", "ipv6", "rpki_valid", "rpki_invalid", "rpki_unknown"], + PropertyInfo(alias="sortBy"), + ] + """Return order results by given type""" + + sort_order: Annotated[Literal["asc", "desc"], PropertyInfo(alias="sortOrder")] + """Sort by value ascending or descending""" diff --git a/src/cloudflare/types/radar/bgp/route_ases_response.py b/src/cloudflare/types/radar/bgp/route_ases_response.py new file mode 100644 index 00000000000..56e851baf3d --- /dev/null +++ b/src/cloudflare/types/radar/bgp/route_ases_response.py @@ -0,0 +1,57 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["RouteAsesResponse", "ASN", "Meta"] + + +class ASN(BaseModel): + asn: int + + cone_size: int = FieldInfo(alias="coneSize") + """AS's customer cone size""" + + country: str + """2-letter country code for the AS's registration country""" + + ipv4_count: int = FieldInfo(alias="ipv4Count") + """number of IPv4 addresses originated by the AS""" + + ipv6_count: str = FieldInfo(alias="ipv6Count") + """number of IPv6 addresses originated by the AS""" + + name: str + """name of the AS""" + + pfxs_count: int = FieldInfo(alias="pfxsCount") + """number of total IP prefixes originated by the AS""" + + rpki_invalid: int = FieldInfo(alias="rpkiInvalid") + """number of RPKI invalid prefixes originated by the AS""" + + rpki_unknown: int = FieldInfo(alias="rpkiUnknown") + """number of RPKI unknown prefixes originated by the AS""" + + rpki_valid: int = FieldInfo(alias="rpkiValid") + """number of RPKI valid prefixes originated by the AS""" + + +class Meta(BaseModel): + data_time: str = FieldInfo(alias="dataTime") + """the timestamp of when the data is generated""" + + query_time: str = FieldInfo(alias="queryTime") + """the timestamp of the query""" + + total_peers: int = FieldInfo(alias="totalPeers") + """total number of route collector peers used to generate this data""" + + +class RouteAsesResponse(BaseModel): + asns: List[ASN] + + meta: Meta diff --git a/src/cloudflare/types/radar/http_timeseries_params.py b/src/cloudflare/types/radar/http_timeseries_params.py new file mode 100644 index 00000000000..a11c86f05f2 --- /dev/null +++ b/src/cloudflare/types/radar/http_timeseries_params.py @@ -0,0 +1,81 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union +from datetime import datetime +from typing_extensions import Literal, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["HTTPTimeseriesParams"] + + +class HTTPTimeseriesParams(TypedDict, total=False): + agg_interval: Annotated[Literal["15m", "1h", "1d", "1w"], PropertyInfo(alias="aggInterval")] + """ + Aggregation interval results should be returned in (for example, in 15 minutes + or 1 hour intervals). Refer to + [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + """ + + asn: List[str] + """Array of comma separated list of ASNs, start with `-` to exclude from results. + + For example, `-174, 3356` excludes results from AS174, but includes results from + AS3356. + """ + + continent: List[str] + """Array of comma separated list of continents (alpha-2 continent codes). + + Start with `-` to exclude from results. For example, `-EU,NA` excludes results + from Europe, but includes results from North America. + """ + + date_end: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateEnd", format="iso8601")] + """End of the date range (inclusive).""" + + date_range: Annotated[ + List[ + Literal[ + "1d", + "2d", + "7d", + "14d", + "28d", + "12w", + "24w", + "52w", + "1dControl", + "2dControl", + "7dControl", + "14dControl", + "28dControl", + "12wControl", + "24wControl", + ] + ], + PropertyInfo(alias="dateRange"), + ] + """ + For example, use `7d` and `7dControl` to compare this week with the previous + week. Use this parameter or set specific start and end dates (`dateStart` and + `dateEnd` parameters). + """ + + date_start: Annotated[List[Union[str, datetime]], PropertyInfo(alias="dateStart", format="iso8601")] + """Array of datetimes to filter the start of a series.""" + + format: Literal["JSON", "CSV"] + """Format results are returned in.""" + + location: List[str] + """Array of comma separated list of locations (alpha-2 country codes). + + Start with `-` to exclude from results. For example, `-US,PT` excludes results + from the US, but includes results from PT. + """ + + name: List[str] + """Array of names that will be used to name the series in responses.""" diff --git a/src/cloudflare/types/radar/http_timeseries_response.py b/src/cloudflare/types/radar/http_timeseries_response.py new file mode 100644 index 00000000000..00d0b8dada4 --- /dev/null +++ b/src/cloudflare/types/radar/http_timeseries_response.py @@ -0,0 +1,69 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = [ + "HTTPTimeseriesResponse", + "Meta", + "MetaDateRange", + "MetaConfidenceInfo", + "MetaConfidenceInfoAnnotation", + "Serie0", +] + + +class MetaDateRange(BaseModel): + end_time: datetime = FieldInfo(alias="endTime") + """Adjusted end of date range.""" + + start_time: datetime = FieldInfo(alias="startTime") + """Adjusted start of date range.""" + + +class MetaConfidenceInfoAnnotation(BaseModel): + data_source: str = FieldInfo(alias="dataSource") + + description: str + + event_type: str = FieldInfo(alias="eventType") + + is_instantaneous: object = FieldInfo(alias="isInstantaneous") + + end_time: Optional[datetime] = FieldInfo(alias="endTime", default=None) + + linked_url: Optional[str] = FieldInfo(alias="linkedUrl", default=None) + + start_time: Optional[datetime] = FieldInfo(alias="startTime", default=None) + + +class MetaConfidenceInfo(BaseModel): + annotations: Optional[List[MetaConfidenceInfoAnnotation]] = None + + level: Optional[int] = None + + +class Meta(BaseModel): + agg_interval: str = FieldInfo(alias="aggInterval") + + date_range: List[MetaDateRange] = FieldInfo(alias="dateRange") + + last_updated: datetime = FieldInfo(alias="lastUpdated") + + confidence_info: Optional[MetaConfidenceInfo] = FieldInfo(alias="confidenceInfo", default=None) + + +class Serie0(BaseModel): + timestamps: List[datetime] + + values: List[str] + + +class HTTPTimeseriesResponse(BaseModel): + meta: Meta + + serie_0: Serie0 diff --git a/src/cloudflare/types/workers/ai/__init__.py b/src/cloudflare/types/workers/ai/__init__.py new file mode 100644 index 00000000000..f8ee8b14b1c --- /dev/null +++ b/src/cloudflare/types/workers/ai/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations diff --git a/src/cloudflare/types/workers/ai/models/__init__.py b/src/cloudflare/types/workers/ai/models/__init__.py new file mode 100644 index 00000000000..64ed676cee2 --- /dev/null +++ b/src/cloudflare/types/workers/ai/models/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .schema_get_params import SchemaGetParams as SchemaGetParams diff --git a/src/cloudflare/types/workers/ai/models/schema_get_params.py b/src/cloudflare/types/workers/ai/models/schema_get_params.py new file mode 100644 index 00000000000..92d676194ab --- /dev/null +++ b/src/cloudflare/types/workers/ai/models/schema_get_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 Required, TypedDict + +__all__ = ["SchemaGetParams"] + + +class SchemaGetParams(TypedDict, total=False): + account_id: Required[str] + + model: Required[str] + """Model Name""" diff --git a/tests/api_resources/radar/bgp/test_routes.py b/tests/api_resources/radar/bgp/test_routes.py index fc506877a1b..bcb74fee056 100644 --- a/tests/api_resources/radar/bgp/test_routes.py +++ b/tests/api_resources/radar/bgp/test_routes.py @@ -10,6 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.types.radar.bgp import ( + RouteAsesResponse, RouteMoasResponse, RouteStatsResponse, RoutePfx2asResponse, @@ -21,6 +22,42 @@ class TestRoutes: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + def test_method_ases(self, client: Cloudflare) -> None: + route = client.radar.bgp.routes.ases() + assert_matches_type(RouteAsesResponse, route, path=["response"]) + + @parametrize + def test_method_ases_with_all_params(self, client: Cloudflare) -> None: + route = client.radar.bgp.routes.ases( + format="JSON", + limit=5, + location="US", + sort_by="ipv4", + sort_order="desc", + ) + assert_matches_type(RouteAsesResponse, route, path=["response"]) + + @parametrize + def test_raw_response_ases(self, client: Cloudflare) -> None: + response = client.radar.bgp.routes.with_raw_response.ases() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = response.parse() + assert_matches_type(RouteAsesResponse, route, path=["response"]) + + @parametrize + def test_streaming_response_ases(self, client: Cloudflare) -> None: + with client.radar.bgp.routes.with_streaming_response.ases() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = response.parse() + assert_matches_type(RouteAsesResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize def test_method_moas(self, client: Cloudflare) -> None: route = client.radar.bgp.routes.moas() @@ -130,6 +167,42 @@ def test_streaming_response_stats(self, client: Cloudflare) -> None: class TestAsyncRoutes: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + async def test_method_ases(self, async_client: AsyncCloudflare) -> None: + route = await async_client.radar.bgp.routes.ases() + assert_matches_type(RouteAsesResponse, route, path=["response"]) + + @parametrize + async def test_method_ases_with_all_params(self, async_client: AsyncCloudflare) -> None: + route = await async_client.radar.bgp.routes.ases( + format="JSON", + limit=5, + location="US", + sort_by="ipv4", + sort_order="desc", + ) + assert_matches_type(RouteAsesResponse, route, path=["response"]) + + @parametrize + async def test_raw_response_ases(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.bgp.routes.with_raw_response.ases() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + route = await response.parse() + assert_matches_type(RouteAsesResponse, route, path=["response"]) + + @parametrize + async def test_streaming_response_ases(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.bgp.routes.with_streaming_response.ases() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + route = await response.parse() + assert_matches_type(RouteAsesResponse, route, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize async def test_method_moas(self, async_client: AsyncCloudflare) -> None: route = await async_client.radar.bgp.routes.moas() diff --git a/tests/api_resources/radar/test_http.py b/tests/api_resources/radar/test_http.py new file mode 100644 index 00000000000..4828f727a4f --- /dev/null +++ b/tests/api_resources/radar/test_http.py @@ -0,0 +1,119 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime +from cloudflare.types.radar import HTTPTimeseriesResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestHTTP: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_timeseries(self, client: Cloudflare) -> None: + http = client.radar.http.timeseries() + assert_matches_type(HTTPTimeseriesResponse, http, path=["response"]) + + @parametrize + def test_method_timeseries_with_all_params(self, client: Cloudflare) -> None: + http = client.radar.http.timeseries( + agg_interval="1h", + asn=["string", "string", "string"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + format="JSON", + location=["string", "string", "string"], + name=["string", "string", "string"], + ) + assert_matches_type(HTTPTimeseriesResponse, http, path=["response"]) + + @parametrize + def test_raw_response_timeseries(self, client: Cloudflare) -> None: + response = client.radar.http.with_raw_response.timeseries() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + http = response.parse() + assert_matches_type(HTTPTimeseriesResponse, http, path=["response"]) + + @parametrize + def test_streaming_response_timeseries(self, client: Cloudflare) -> None: + with client.radar.http.with_streaming_response.timeseries() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + http = response.parse() + assert_matches_type(HTTPTimeseriesResponse, http, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncHTTP: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_timeseries(self, async_client: AsyncCloudflare) -> None: + http = await async_client.radar.http.timeseries() + assert_matches_type(HTTPTimeseriesResponse, http, path=["response"]) + + @parametrize + async def test_method_timeseries_with_all_params(self, async_client: AsyncCloudflare) -> None: + http = await async_client.radar.http.timeseries( + agg_interval="1h", + asn=["string", "string", "string"], + continent=["string", "string", "string"], + date_end=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + date_range=["1d", "2d", "7d"], + date_start=[ + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + parse_datetime("2019-12-27T18:11:19.117Z"), + ], + format="JSON", + location=["string", "string", "string"], + name=["string", "string", "string"], + ) + assert_matches_type(HTTPTimeseriesResponse, http, path=["response"]) + + @parametrize + async def test_raw_response_timeseries(self, async_client: AsyncCloudflare) -> None: + response = await async_client.radar.http.with_raw_response.timeseries() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + http = await response.parse() + assert_matches_type(HTTPTimeseriesResponse, http, path=["response"]) + + @parametrize + async def test_streaming_response_timeseries(self, async_client: AsyncCloudflare) -> None: + async with async_client.radar.http.with_streaming_response.timeseries() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + http = await response.parse() + assert_matches_type(HTTPTimeseriesResponse, http, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/workers/ai/__init__.py b/tests/api_resources/workers/ai/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/workers/ai/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/workers/ai/models/__init__.py b/tests/api_resources/workers/ai/models/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/workers/ai/models/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/workers/ai/models/test_schema.py b/tests/api_resources/workers/ai/models/test_schema.py new file mode 100644 index 00000000000..5937cee8a64 --- /dev/null +++ b/tests/api_resources/workers/ai/models/test_schema.py @@ -0,0 +1,105 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSchema: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + schema = client.workers.ai.models.schema.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + model="string", + ) + assert_matches_type(object, schema, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.workers.ai.models.schema.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + model="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema = response.parse() + assert_matches_type(object, schema, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.workers.ai.models.schema.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + model="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema = response.parse() + assert_matches_type(object, schema, 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.workers.ai.models.schema.with_raw_response.get( + account_id="", + model="string", + ) + + +class TestAsyncSchema: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + schema = await async_client.workers.ai.models.schema.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + model="string", + ) + assert_matches_type(object, schema, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.workers.ai.models.schema.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + model="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema = await response.parse() + assert_matches_type(object, schema, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.workers.ai.models.schema.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + model="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema = await response.parse() + assert_matches_type(object, schema, 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.workers.ai.models.schema.with_raw_response.get( + account_id="", + model="string", + ) From 2d97be7aa527f1bf80dd7ead3de6b717f342aa87 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 07:53:05 +0000 Subject: [PATCH 355/532] feat(api): OpenAPI spec update via Stainless API (#836) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c10a59bb098..c59c4be91d5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1338 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-563da3da7347fb7ce5676737cc6a457de5da7c96aa7d44098a9db3b2fb8d6599.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6537ce0cca2a8b4688b717abc1782d929fc949649130a34c7dd86031294f2810.yml From ed6a712c10eefc6bc5e4668359cb0082624e8b4e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:04:39 +0000 Subject: [PATCH 356/532] feat(api): OpenAPI spec update via Stainless API (#837) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c59c4be91d5..6744521cd5b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1338 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6537ce0cca2a8b4688b717abc1782d929fc949649130a34c7dd86031294f2810.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-980ca1b5a0f22cdbb5a3645d7142164f008cdf7e70dfb6b53e9544f91e184fdd.yml From 9bc4946f7489b752a93654bc2ccdda85c2ae1816 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:24:23 +0000 Subject: [PATCH 357/532] feat(api): OpenAPI spec update via Stainless API (#838) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6744521cd5b..fe7ec849652 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1338 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-980ca1b5a0f22cdbb5a3645d7142164f008cdf7e70dfb6b53e9544f91e184fdd.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b02b68427ca7af705b9f5f833944a4959877bb48cb88a7dc74dd8bfbf2d9a25a.yml From f520ca581ccd653787cb58ff4178f77e3dc22826 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:42:56 +0000 Subject: [PATCH 358/532] feat(api): OpenAPI spec update via Stainless API (#839) --- .stats.yml | 2 +- src/cloudflare/resources/rulesets/phases/phases.py | 8 -------- src/cloudflare/types/rulesets/phase_update_params.py | 4 ---- tests/api_resources/rulesets/test_phases.py | 2 -- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.stats.yml b/.stats.yml index fe7ec849652..bf9ade0a890 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1338 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b02b68427ca7af705b9f5f833944a4959877bb48cb88a7dc74dd8bfbf2d9a25a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0ec270b3c03c21a8d2358f8bf7726d82da5aa7eda902b5df86220f550eac2c2e.yml diff --git a/src/cloudflare/resources/rulesets/phases/phases.py b/src/cloudflare/resources/rulesets/phases/phases.py index c95aafd532f..9f6a6755eb3 100644 --- a/src/cloudflare/resources/rulesets/phases/phases.py +++ b/src/cloudflare/resources/rulesets/phases/phases.py @@ -61,7 +61,6 @@ def update( zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - phase: Phase | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -85,8 +84,6 @@ def update( name: The human-readable name of the ruleset. - phase: The phase of the ruleset. - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -116,7 +113,6 @@ def update( "rules": rules, "description": description, "name": name, - "phase": phase, }, phase_update_params.PhaseUpdateParams, ), @@ -211,7 +207,6 @@ async def update( zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - phase: Phase | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -235,8 +230,6 @@ async def update( name: The human-readable name of the ruleset. - phase: The phase of the ruleset. - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -266,7 +259,6 @@ async def update( "rules": rules, "description": description, "name": name, - "phase": phase, }, phase_update_params.PhaseUpdateParams, ), diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index 41cf834d9cf..972c5295f31 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -5,7 +5,6 @@ from typing import Union, Iterable from typing_extensions import Literal, Required, TypedDict -from .phase import Phase from .logging_param import LoggingParam from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam @@ -52,9 +51,6 @@ class PhaseUpdateParams(TypedDict, total=False): name: str """The human-readable name of the ruleset.""" - phase: Phase - """The phase of the ruleset.""" - class RuleRulesetsLogCustomFieldRuleActionParametersCookieField(TypedDict, total=False): name: Required[str] diff --git a/tests/api_resources/rulesets/test_phases.py b/tests/api_resources/rulesets/test_phases.py index 447be7922ae..8abeef8e3df 100644 --- a/tests/api_resources/rulesets/test_phases.py +++ b/tests/api_resources/rulesets/test_phases.py @@ -85,7 +85,6 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: account_id="string", description="My ruleset to execute managed rulesets", name="My ruleset", - phase="http_request_firewall_custom", ) assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) @@ -269,7 +268,6 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare account_id="string", description="My ruleset to execute managed rulesets", name="My ruleset", - phase="http_request_firewall_custom", ) assert_matches_type(PhaseUpdateResponse, phase, path=["response"]) From 287bb9a3b7f082a2a1203bf53d3d5aab5443332e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 10:00:26 +0000 Subject: [PATCH 359/532] feat(api): OpenAPI spec update via Stainless API (#840) --- .stats.yml | 4 +- api.md | 5 - src/cloudflare/resources/zones/__init__.py | 14 - .../resources/zones/dns_settings.py | 327 ------------------ src/cloudflare/resources/zones/zones.py | 32 -- src/cloudflare/types/zones/__init__.py | 4 - src/cloudflare/types/zones/dns_setting.py | 76 ---- .../types/zones/dns_setting_edit_params.py | 79 ----- src/cloudflare/types/zones/nameserver.py | 12 - .../types/zones/nameserver_param.py | 12 - .../api_resources/zones/test_dns_settings.py | 218 ------------ 11 files changed, 2 insertions(+), 781 deletions(-) delete mode 100644 src/cloudflare/resources/zones/dns_settings.py delete mode 100644 src/cloudflare/types/zones/dns_setting.py delete mode 100644 src/cloudflare/types/zones/dns_setting_edit_params.py delete mode 100644 src/cloudflare/types/zones/nameserver.py delete mode 100644 src/cloudflare/types/zones/nameserver_param.py delete mode 100644 tests/api_resources/zones/test_dns_settings.py diff --git a/.stats.yml b/.stats.yml index bf9ade0a890..8670b1dd640 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1338 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0ec270b3c03c21a8d2358f8bf7726d82da5aa7eda902b5df86220f550eac2c2e.yml +configured_endpoints: 1336 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-36b39384f5550979f973317bd71942fbae76ba2d7ee3aa70c7c0af16740916b2.yml diff --git a/api.md b/api.md index 330a480993e..5020de58c34 100644 --- a/api.md +++ b/api.md @@ -310,11 +310,6 @@ Types: from cloudflare.types.zones import DNSSetting, Nameserver ``` -Methods: - -- client.zones.dns_settings.edit(\*, zone_id, \*\*params) -> Optional -- client.zones.dns_settings.get(\*, zone_id) -> Optional - ## Settings ### ZeroRTT diff --git a/src/cloudflare/resources/zones/__init__.py b/src/cloudflare/resources/zones/__init__.py index fe02e52f39d..06e8291ed86 100644 --- a/src/cloudflare/resources/zones/__init__.py +++ b/src/cloudflare/resources/zones/__init__.py @@ -24,14 +24,6 @@ SettingsResourceWithStreamingResponse, AsyncSettingsResourceWithStreamingResponse, ) -from .dns_settings import ( - DNSSettingsResource, - AsyncDNSSettingsResource, - DNSSettingsResourceWithRawResponse, - AsyncDNSSettingsResourceWithRawResponse, - DNSSettingsResourceWithStreamingResponse, - AsyncDNSSettingsResourceWithStreamingResponse, -) from .subscriptions import ( SubscriptionsResource, AsyncSubscriptionsResource, @@ -64,12 +56,6 @@ "AsyncActivationCheckResourceWithRawResponse", "ActivationCheckResourceWithStreamingResponse", "AsyncActivationCheckResourceWithStreamingResponse", - "DNSSettingsResource", - "AsyncDNSSettingsResource", - "DNSSettingsResourceWithRawResponse", - "AsyncDNSSettingsResourceWithRawResponse", - "DNSSettingsResourceWithStreamingResponse", - "AsyncDNSSettingsResourceWithStreamingResponse", "SettingsResource", "AsyncSettingsResource", "SettingsResourceWithRawResponse", diff --git a/src/cloudflare/resources/zones/dns_settings.py b/src/cloudflare/resources/zones/dns_settings.py deleted file mode 100644 index 5460d1f4c9c..00000000000 --- a/src/cloudflare/resources/zones/dns_settings.py +++ /dev/null @@ -1,327 +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 -from typing_extensions import Literal - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._wrappers import ResultWrapper -from ...types.zones import dns_setting_edit_params -from ..._base_client import ( - make_request_options, -) -from ...types.zones.dns_setting import DNSSetting -from ...types.zones.nameserver_param import NameserverParam - -__all__ = ["DNSSettingsResource", "AsyncDNSSettingsResource"] - - -class DNSSettingsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> DNSSettingsResourceWithRawResponse: - return DNSSettingsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> DNSSettingsResourceWithStreamingResponse: - return DNSSettingsResourceWithStreamingResponse(self) - - def edit( - self, - *, - zone_id: str, - foundation_dns: bool | NotGiven = NOT_GIVEN, - multi_provider: bool | NotGiven = NOT_GIVEN, - nameservers: NameserverParam | NotGiven = NOT_GIVEN, - ns_ttl: float | NotGiven = NOT_GIVEN, - secondary_overrides: bool | NotGiven = NOT_GIVEN, - soa: dns_setting_edit_params.SOA | NotGiven = NOT_GIVEN, - zone_mode: Literal["standard", "cdn_only", "dns_only"] | 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[DNSSetting]: - """ - Update DNS settings for a zone - - Args: - zone_id: Identifier - - foundation_dns: Whether to enable Foundation DNS Advanced Nameservers on the zone. - - multi_provider: Whether to enable multi-provider DNS, which causes Cloudflare to activate the - zone even when non-Cloudflare NS records exist, and to respect NS records at the - zone apex during outbound zone transfers. - - nameservers: Settings determining the nameservers through which the zone should be available. - - ns_ttl: The time to live (TTL) of the zone's nameserver (NS) records. - - secondary_overrides: Allows a Secondary DNS zone to use (proxied) override records and CNAME - flattening at the zone apex. - - soa: Components of the zone's SOA record. - - zone_mode: Whether the zone mode is a regular or CDN/DNS only zone. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._patch( - f"/zones/{zone_id}/dns_settings", - body=maybe_transform( - { - "foundation_dns": foundation_dns, - "multi_provider": multi_provider, - "nameservers": nameservers, - "ns_ttl": ns_ttl, - "secondary_overrides": secondary_overrides, - "soa": soa, - "zone_mode": zone_mode, - }, - dns_setting_edit_params.DNSSettingEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[DNSSetting]]._unwrapper, - ), - cast_to=cast(Type[Optional[DNSSetting]], ResultWrapper[DNSSetting]), - ) - - def get( - self, - *, - zone_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[DNSSetting]: - """ - Show DNS settings for a zone - - Args: - zone_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._get( - f"/zones/{zone_id}/dns_settings", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[DNSSetting]]._unwrapper, - ), - cast_to=cast(Type[Optional[DNSSetting]], ResultWrapper[DNSSetting]), - ) - - -class AsyncDNSSettingsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncDNSSettingsResourceWithRawResponse: - return AsyncDNSSettingsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncDNSSettingsResourceWithStreamingResponse: - return AsyncDNSSettingsResourceWithStreamingResponse(self) - - async def edit( - self, - *, - zone_id: str, - foundation_dns: bool | NotGiven = NOT_GIVEN, - multi_provider: bool | NotGiven = NOT_GIVEN, - nameservers: NameserverParam | NotGiven = NOT_GIVEN, - ns_ttl: float | NotGiven = NOT_GIVEN, - secondary_overrides: bool | NotGiven = NOT_GIVEN, - soa: dns_setting_edit_params.SOA | NotGiven = NOT_GIVEN, - zone_mode: Literal["standard", "cdn_only", "dns_only"] | 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[DNSSetting]: - """ - Update DNS settings for a zone - - Args: - zone_id: Identifier - - foundation_dns: Whether to enable Foundation DNS Advanced Nameservers on the zone. - - multi_provider: Whether to enable multi-provider DNS, which causes Cloudflare to activate the - zone even when non-Cloudflare NS records exist, and to respect NS records at the - zone apex during outbound zone transfers. - - nameservers: Settings determining the nameservers through which the zone should be available. - - ns_ttl: The time to live (TTL) of the zone's nameserver (NS) records. - - secondary_overrides: Allows a Secondary DNS zone to use (proxied) override records and CNAME - flattening at the zone apex. - - soa: Components of the zone's SOA record. - - zone_mode: Whether the zone mode is a regular or CDN/DNS only zone. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return await self._patch( - f"/zones/{zone_id}/dns_settings", - body=await async_maybe_transform( - { - "foundation_dns": foundation_dns, - "multi_provider": multi_provider, - "nameservers": nameservers, - "ns_ttl": ns_ttl, - "secondary_overrides": secondary_overrides, - "soa": soa, - "zone_mode": zone_mode, - }, - dns_setting_edit_params.DNSSettingEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[DNSSetting]]._unwrapper, - ), - cast_to=cast(Type[Optional[DNSSetting]], ResultWrapper[DNSSetting]), - ) - - async def get( - self, - *, - zone_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[DNSSetting]: - """ - Show DNS settings for a zone - - Args: - zone_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return await self._get( - f"/zones/{zone_id}/dns_settings", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[DNSSetting]]._unwrapper, - ), - cast_to=cast(Type[Optional[DNSSetting]], ResultWrapper[DNSSetting]), - ) - - -class DNSSettingsResourceWithRawResponse: - def __init__(self, dns_settings: DNSSettingsResource) -> None: - self._dns_settings = dns_settings - - self.edit = to_raw_response_wrapper( - dns_settings.edit, - ) - self.get = to_raw_response_wrapper( - dns_settings.get, - ) - - -class AsyncDNSSettingsResourceWithRawResponse: - def __init__(self, dns_settings: AsyncDNSSettingsResource) -> None: - self._dns_settings = dns_settings - - self.edit = async_to_raw_response_wrapper( - dns_settings.edit, - ) - self.get = async_to_raw_response_wrapper( - dns_settings.get, - ) - - -class DNSSettingsResourceWithStreamingResponse: - def __init__(self, dns_settings: DNSSettingsResource) -> None: - self._dns_settings = dns_settings - - self.edit = to_streamed_response_wrapper( - dns_settings.edit, - ) - self.get = to_streamed_response_wrapper( - dns_settings.get, - ) - - -class AsyncDNSSettingsResourceWithStreamingResponse: - def __init__(self, dns_settings: AsyncDNSSettingsResource) -> None: - self._dns_settings = dns_settings - - self.edit = async_to_streamed_response_wrapper( - dns_settings.edit, - ) - self.get = async_to_streamed_response_wrapper( - dns_settings.get, - ) diff --git a/src/cloudflare/resources/zones/zones.py b/src/cloudflare/resources/zones/zones.py index 6256a5db72a..2584b9a48a9 100644 --- a/src/cloudflare/resources/zones/zones.py +++ b/src/cloudflare/resources/zones/zones.py @@ -38,14 +38,6 @@ ) from ..._wrappers import ResultWrapper from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from .dns_settings import ( - DNSSettingsResource, - AsyncDNSSettingsResource, - DNSSettingsResourceWithRawResponse, - AsyncDNSSettingsResourceWithRawResponse, - DNSSettingsResourceWithStreamingResponse, - AsyncDNSSettingsResourceWithStreamingResponse, -) from ...types.zones import zone_edit_params, zone_list_params, zone_create_params from .subscriptions import ( SubscriptionsResource, @@ -88,10 +80,6 @@ class ZonesResource(SyncAPIResource): def activation_check(self) -> ActivationCheckResource: return ActivationCheckResource(self._client) - @cached_property - def dns_settings(self) -> DNSSettingsResource: - return DNSSettingsResource(self._client) - @cached_property def settings(self) -> SettingsResource: return SettingsResource(self._client) @@ -392,10 +380,6 @@ class AsyncZonesResource(AsyncAPIResource): def activation_check(self) -> AsyncActivationCheckResource: return AsyncActivationCheckResource(self._client) - @cached_property - def dns_settings(self) -> AsyncDNSSettingsResource: - return AsyncDNSSettingsResource(self._client) - @cached_property def settings(self) -> AsyncSettingsResource: return AsyncSettingsResource(self._client) @@ -715,10 +699,6 @@ def __init__(self, zones: ZonesResource) -> None: def activation_check(self) -> ActivationCheckResourceWithRawResponse: return ActivationCheckResourceWithRawResponse(self._zones.activation_check) - @cached_property - def dns_settings(self) -> DNSSettingsResourceWithRawResponse: - return DNSSettingsResourceWithRawResponse(self._zones.dns_settings) - @cached_property def settings(self) -> SettingsResourceWithRawResponse: return SettingsResourceWithRawResponse(self._zones.settings) @@ -760,10 +740,6 @@ def __init__(self, zones: AsyncZonesResource) -> None: def activation_check(self) -> AsyncActivationCheckResourceWithRawResponse: return AsyncActivationCheckResourceWithRawResponse(self._zones.activation_check) - @cached_property - def dns_settings(self) -> AsyncDNSSettingsResourceWithRawResponse: - return AsyncDNSSettingsResourceWithRawResponse(self._zones.dns_settings) - @cached_property def settings(self) -> AsyncSettingsResourceWithRawResponse: return AsyncSettingsResourceWithRawResponse(self._zones.settings) @@ -805,10 +781,6 @@ def __init__(self, zones: ZonesResource) -> None: def activation_check(self) -> ActivationCheckResourceWithStreamingResponse: return ActivationCheckResourceWithStreamingResponse(self._zones.activation_check) - @cached_property - def dns_settings(self) -> DNSSettingsResourceWithStreamingResponse: - return DNSSettingsResourceWithStreamingResponse(self._zones.dns_settings) - @cached_property def settings(self) -> SettingsResourceWithStreamingResponse: return SettingsResourceWithStreamingResponse(self._zones.settings) @@ -850,10 +822,6 @@ def __init__(self, zones: AsyncZonesResource) -> None: def activation_check(self) -> AsyncActivationCheckResourceWithStreamingResponse: return AsyncActivationCheckResourceWithStreamingResponse(self._zones.activation_check) - @cached_property - def dns_settings(self) -> AsyncDNSSettingsResourceWithStreamingResponse: - return AsyncDNSSettingsResourceWithStreamingResponse(self._zones.dns_settings) - @cached_property def settings(self) -> AsyncSettingsResourceWithStreamingResponse: return AsyncSettingsResourceWithStreamingResponse(self._zones.settings) diff --git a/src/cloudflare/types/zones/__init__.py b/src/cloudflare/types/zones/__init__.py index 3d3e43049cf..c7b972f4d45 100644 --- a/src/cloudflare/types/zones/__init__.py +++ b/src/cloudflare/types/zones/__init__.py @@ -5,16 +5,12 @@ from .type import Type as Type from .zone import Zone as Zone from .zone_hold import ZoneHold as ZoneHold -from .nameserver import Nameserver as Nameserver -from .dns_setting import DNSSetting as DNSSetting -from .nameserver_param import NameserverParam as NameserverParam from .zone_edit_params import ZoneEditParams as ZoneEditParams from .zone_list_params import ZoneListParams as ZoneListParams from .hold_create_params import HoldCreateParams as HoldCreateParams from .hold_delete_params import HoldDeleteParams as HoldDeleteParams from .zone_create_params import ZoneCreateParams as ZoneCreateParams from .zone_delete_response import ZoneDeleteResponse as ZoneDeleteResponse -from .dns_setting_edit_params import DNSSettingEditParams as DNSSettingEditParams from .subscription_get_response import SubscriptionGetResponse as SubscriptionGetResponse from .subscription_create_params import SubscriptionCreateParams as SubscriptionCreateParams from .subscription_create_response import SubscriptionCreateResponse as SubscriptionCreateResponse diff --git a/src/cloudflare/types/zones/dns_setting.py b/src/cloudflare/types/zones/dns_setting.py deleted file mode 100644 index c96b14afb67..00000000000 --- a/src/cloudflare/types/zones/dns_setting.py +++ /dev/null @@ -1,76 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel -from .nameserver import Nameserver - -__all__ = ["DNSSetting", "SOA"] - - -class SOA(BaseModel): - expire: float - """ - Time in seconds of being unable to query the primary server after which - secondary servers should stop serving the zone. - """ - - min_ttl: float - """The time to live (TTL) for negative caching of records within the zone.""" - - mname: str - """The primary nameserver, which may be used for outbound zone transfers.""" - - refresh: float - """ - Time in seconds after which secondary servers should re-check the SOA record to - see if the zone has been updated. - """ - - retry: float - """ - Time in seconds after which secondary servers should retry queries after the - primary server was unresponsive. - """ - - rname: str - """ - The email address of the zone administrator, with the first label representing - the local part of the email address. - """ - - ttl: float - """The time to live (TTL) of the SOA record itself.""" - - -class DNSSetting(BaseModel): - foundation_dns: Optional[bool] = None - """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" - - multi_provider: Optional[bool] = None - """ - Whether to enable multi-provider DNS, which causes Cloudflare to activate the - zone even when non-Cloudflare NS records exist, and to respect NS records at the - zone apex during outbound zone transfers. - """ - - nameservers: Optional[Nameserver] = None - """ - Settings determining the nameservers through which the zone should be available. - """ - - ns_ttl: Optional[float] = None - """The time to live (TTL) of the zone's nameserver (NS) records.""" - - secondary_overrides: Optional[bool] = None - """ - Allows a Secondary DNS zone to use (proxied) override records and CNAME - flattening at the zone apex. - """ - - soa: Optional[SOA] = None - """Components of the zone's SOA record.""" - - zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]] = None - """Whether the zone mode is a regular or CDN/DNS only zone.""" diff --git a/src/cloudflare/types/zones/dns_setting_edit_params.py b/src/cloudflare/types/zones/dns_setting_edit_params.py deleted file mode 100644 index 96739b9404c..00000000000 --- a/src/cloudflare/types/zones/dns_setting_edit_params.py +++ /dev/null @@ -1,79 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -from .nameserver_param import NameserverParam - -__all__ = ["DNSSettingEditParams", "SOA"] - - -class DNSSettingEditParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - foundation_dns: bool - """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" - - multi_provider: bool - """ - Whether to enable multi-provider DNS, which causes Cloudflare to activate the - zone even when non-Cloudflare NS records exist, and to respect NS records at the - zone apex during outbound zone transfers. - """ - - nameservers: NameserverParam - """ - Settings determining the nameservers through which the zone should be available. - """ - - ns_ttl: float - """The time to live (TTL) of the zone's nameserver (NS) records.""" - - secondary_overrides: bool - """ - Allows a Secondary DNS zone to use (proxied) override records and CNAME - flattening at the zone apex. - """ - - soa: SOA - """Components of the zone's SOA record.""" - - zone_mode: Literal["standard", "cdn_only", "dns_only"] - """Whether the zone mode is a regular or CDN/DNS only zone.""" - - -class SOA(TypedDict, total=False): - expire: Required[float] - """ - Time in seconds of being unable to query the primary server after which - secondary servers should stop serving the zone. - """ - - min_ttl: Required[float] - """The time to live (TTL) for negative caching of records within the zone.""" - - mname: Required[str] - """The primary nameserver, which may be used for outbound zone transfers.""" - - refresh: Required[float] - """ - Time in seconds after which secondary servers should re-check the SOA record to - see if the zone has been updated. - """ - - retry: Required[float] - """ - Time in seconds after which secondary servers should retry queries after the - primary server was unresponsive. - """ - - rname: Required[str] - """ - The email address of the zone administrator, with the first label representing - the local part of the email address. - """ - - ttl: Required[float] - """The time to live (TTL) of the SOA record itself.""" diff --git a/src/cloudflare/types/zones/nameserver.py b/src/cloudflare/types/zones/nameserver.py deleted file mode 100644 index 3076da16fbd..00000000000 --- a/src/cloudflare/types/zones/nameserver.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["Nameserver"] - - -class Nameserver(BaseModel): - type: Literal["cloudflare.standard"] - """Nameserver type""" diff --git a/src/cloudflare/types/zones/nameserver_param.py b/src/cloudflare/types/zones/nameserver_param.py deleted file mode 100644 index 6d73075a2ae..00000000000 --- a/src/cloudflare/types/zones/nameserver_param.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["NameserverParam"] - - -class NameserverParam(TypedDict, total=False): - type: Required[Literal["cloudflare.standard"]] - """Nameserver type""" diff --git a/tests/api_resources/zones/test_dns_settings.py b/tests/api_resources/zones/test_dns_settings.py deleted file mode 100644 index db759678ffa..00000000000 --- a/tests/api_resources/zones/test_dns_settings.py +++ /dev/null @@ -1,218 +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.zones import DNSSetting - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestDNSSettings: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_edit(self, client: Cloudflare) -> None: - dns_setting = client.zones.dns_settings.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - def test_method_edit_with_all_params(self, client: Cloudflare) -> None: - dns_setting = client.zones.dns_settings.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - foundation_dns=False, - multi_provider=False, - nameservers={"type": "cloudflare.standard"}, - ns_ttl=86400, - secondary_overrides=False, - soa={ - "expire": 604800, - "min_ttl": 1800, - "mname": "kristina.ns.cloudflare.com", - "refresh": 10000, - "retry": 2400, - "rname": "admin.example.com", - "ttl": 3600, - }, - zone_mode="dns_only", - ) - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.zones.dns_settings.with_raw_response.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - dns_setting = response.parse() - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.zones.dns_settings.with_streaming_response.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - dns_setting = response.parse() - assert_matches_type(Optional[DNSSetting], dns_setting, 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 `zone_id` but received ''"): - client.zones.dns_settings.with_raw_response.edit( - zone_id="", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - dns_setting = client.zones.dns_settings.get( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zones.dns_settings.with_raw_response.get( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - dns_setting = response.parse() - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zones.dns_settings.with_streaming_response.get( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - dns_setting = response.parse() - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.zones.dns_settings.with_raw_response.get( - zone_id="", - ) - - -class TestAsyncDNSSettings: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - dns_setting = await async_client.zones.dns_settings.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: - dns_setting = await async_client.zones.dns_settings.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - foundation_dns=False, - multi_provider=False, - nameservers={"type": "cloudflare.standard"}, - ns_ttl=86400, - secondary_overrides=False, - soa={ - "expire": 604800, - "min_ttl": 1800, - "mname": "kristina.ns.cloudflare.com", - "refresh": 10000, - "retry": 2400, - "rname": "admin.example.com", - "ttl": 3600, - }, - zone_mode="dns_only", - ) - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zones.dns_settings.with_raw_response.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - dns_setting = await response.parse() - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - async with async_client.zones.dns_settings.with_streaming_response.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - dns_setting = await response.parse() - assert_matches_type(Optional[DNSSetting], dns_setting, 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 `zone_id` but received ''"): - await async_client.zones.dns_settings.with_raw_response.edit( - zone_id="", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - dns_setting = await async_client.zones.dns_settings.get( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zones.dns_settings.with_raw_response.get( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - dns_setting = await response.parse() - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zones.dns_settings.with_streaming_response.get( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - dns_setting = await response.parse() - assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.zones.dns_settings.with_raw_response.get( - zone_id="", - ) From 7a0162e173c26d91afae0514599bb30037d87f12 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 11:42:53 +0000 Subject: [PATCH 360/532] feat(api): OpenAPI spec update via Stainless API (#841) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8670b1dd640..25b22c05081 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-36b39384f5550979f973317bd71942fbae76ba2d7ee3aa70c7c0af16740916b2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4e4e817eba08fb4827b9b553a56939fa973b1870780e33f42897910ff91fb7a7.yml From 943e7bf32d74a101e690721cebbeb3e5cefca860 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:15:18 +0000 Subject: [PATCH 361/532] feat(api): OpenAPI spec update via Stainless API (#842) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 25b22c05081..8670b1dd640 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4e4e817eba08fb4827b9b553a56939fa973b1870780e33f42897910ff91fb7a7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-36b39384f5550979f973317bd71942fbae76ba2d7ee3aa70c7c0af16740916b2.yml From 671030ae276bb000db3796ef04a626d0bd4338df Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:17:35 +0000 Subject: [PATCH 362/532] feat(api): OpenAPI spec update via Stainless API (#843) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8670b1dd640..25b22c05081 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-36b39384f5550979f973317bd71942fbae76ba2d7ee3aa70c7c0af16740916b2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4e4e817eba08fb4827b9b553a56939fa973b1870780e33f42897910ff91fb7a7.yml From 79eab2f86576f5b55e47620be9fbafb1e1fd0852 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 13:07:08 +0000 Subject: [PATCH 363/532] feat(api): OpenAPI spec update via Stainless API (#844) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 25b22c05081..8670b1dd640 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4e4e817eba08fb4827b9b553a56939fa973b1870780e33f42897910ff91fb7a7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-36b39384f5550979f973317bd71942fbae76ba2d7ee3aa70c7c0af16740916b2.yml From 2d7391be05780a67a1f84a4cb3e2cf7187b46c82 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 13:40:10 +0000 Subject: [PATCH 364/532] feat(api): OpenAPI spec update via Stainless API (#845) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8670b1dd640..5687d58b752 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-36b39384f5550979f973317bd71942fbae76ba2d7ee3aa70c7c0af16740916b2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0c5150531151846d105d663c712d62adb98269c4cfe632cff01acd7d103d7ba6.yml From 4d5d4bd261eff4a436f6c4b2ac768a0fa38e04d1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:54:04 +0000 Subject: [PATCH 365/532] feat(api): OpenAPI spec update via Stainless API (#846) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5687d58b752..8bf8851fe9b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0c5150531151846d105d663c712d62adb98269c4cfe632cff01acd7d103d7ba6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-55d5cd39348ff6d84361429d4573fb999f4d1328ec9130d5a0f7baee223caebf.yml From 33ca608d5ddc5da50231321e7289308d162f27ec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 15:05:58 +0000 Subject: [PATCH 366/532] feat(api): OpenAPI spec update via Stainless API (#847) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8bf8851fe9b..f604cb48b59 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-55d5cd39348ff6d84361429d4573fb999f4d1328ec9130d5a0f7baee223caebf.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-93d5ac1d3a9df89b61082ce1c02f2fbc1bf8ab7ca5d63ae7d3b8521e82b4188c.yml From 15c844182258ff2f0d010ee11ef6ebc05ce87f72 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:18:13 +0000 Subject: [PATCH 367/532] feat(api): OpenAPI spec update via Stainless API (#848) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f604cb48b59..5aa7311c5e6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-93d5ac1d3a9df89b61082ce1c02f2fbc1bf8ab7ca5d63ae7d3b8521e82b4188c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2a8a1caa6fe5f9470abfecdc44bec05bf438fd7e4a4a8278d5f262dabed78c3a.yml From 9966bb71bc61f4aad7565573f640de02e24943df Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:43:16 +0000 Subject: [PATCH 368/532] feat(api): OpenAPI spec update via Stainless API (#849) --- .stats.yml | 2 +- api.md | 39 +- src/cloudflare/resources/accounts/accounts.py | 132 +- src/cloudflare/resources/accounts/members.py | 400 ++++-- src/cloudflare/resources/accounts/roles.py | 53 +- src/cloudflare/resources/memberships.py | 46 +- src/cloudflare/resources/user/invites.py | 108 +- .../resources/user/organizations.py | 53 +- .../resources/user/tokens/tokens.py | 181 ++- src/cloudflare/resources/user/tokens/value.py | 6 +- src/cloudflare/resources/user/user.py | 144 +-- src/cloudflare/types/accounts/__init__.py | 8 +- .../types/accounts/account_get_response.py | 7 - .../types/accounts/account_update_response.py | 7 - .../types/accounts/member_create_params.py | 49 +- .../types/accounts/member_create_response.py | 15 + .../types/accounts/member_get_response.py | 15 + .../types/accounts/member_list_response.py | 26 - .../types/accounts/member_update_params.py | 51 +- .../types/accounts/member_update_response.py | 15 + .../types/accounts/role_get_response.py | 7 - .../types/accounts/user_with_invite_code.py | 82 -- .../types/memberships/membership.py | 3 - .../memberships/membership_get_response.py | 12 +- .../memberships/membership_update_response.py | 12 +- src/cloudflare/types/shared/member.py | 11 +- src/cloudflare/types/user/__init__.py | 8 - .../types/user/invite_edit_response.py | 7 - .../types/user/invite_get_response.py | 7 - src/cloudflare/types/user/organization.py | 2 +- .../types/user/organization_get_response.py | 7 - src/cloudflare/types/user/policy_param.py | 23 - .../types/user/token_create_params.py | 22 +- .../types/user/token_get_response.py | 7 - .../types/user/token_update_params.py | 20 +- .../types/user/token_update_response.py | 7 - .../types/user/user_edit_response.py | 7 - .../types/user/user_get_response.py | 7 - tests/api_resources/accounts/test_members.py | 1105 +++++++++++++++-- tests/api_resources/accounts/test_roles.py | 13 +- tests/api_resources/test_accounts.py | 32 +- tests/api_resources/test_memberships.py | 14 +- tests/api_resources/test_user.py | 29 +- tests/api_resources/user/test_invites.py | 26 +- .../api_resources/user/test_organizations.py | 18 +- tests/api_resources/user/test_tokens.py | 58 +- 46 files changed, 1946 insertions(+), 957 deletions(-) delete mode 100644 src/cloudflare/types/accounts/account_get_response.py delete mode 100644 src/cloudflare/types/accounts/account_update_response.py create mode 100644 src/cloudflare/types/accounts/member_create_response.py create mode 100644 src/cloudflare/types/accounts/member_get_response.py delete mode 100644 src/cloudflare/types/accounts/member_list_response.py create mode 100644 src/cloudflare/types/accounts/member_update_response.py delete mode 100644 src/cloudflare/types/accounts/role_get_response.py delete mode 100644 src/cloudflare/types/accounts/user_with_invite_code.py delete mode 100644 src/cloudflare/types/user/invite_edit_response.py delete mode 100644 src/cloudflare/types/user/invite_get_response.py delete mode 100644 src/cloudflare/types/user/organization_get_response.py delete mode 100644 src/cloudflare/types/user/policy_param.py delete mode 100644 src/cloudflare/types/user/token_get_response.py delete mode 100644 src/cloudflare/types/user/token_update_response.py delete mode 100644 src/cloudflare/types/user/user_edit_response.py delete mode 100644 src/cloudflare/types/user/user_get_response.py diff --git a/.stats.yml b/.stats.yml index 5aa7311c5e6..43ab45243cb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2a8a1caa6fe5f9470abfecdc44bec05bf438fd7e4a4a8278d5f262dabed78c3a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dae61c40e8505c826e518a64122325c0e12c78fe44961c1ff6a1e281b7095be3.yml diff --git a/api.md b/api.md index 5020de58c34..c514a7f3a0a 100644 --- a/api.md +++ b/api.md @@ -36,9 +36,9 @@ from cloudflare.types.accounts import ( Methods: -- client.accounts.update(\*, account_id, \*\*params) -> AccountUpdateResponse +- client.accounts.update(\*, account_id, \*\*params) -> object - client.accounts.list(\*\*params) -> SyncV4PagePaginationArray[object] -- client.accounts.get(\*, account_id) -> AccountGetResponse +- client.accounts.get(\*, account_id) -> object ## Members @@ -48,18 +48,20 @@ Types: from cloudflare.types.accounts import ( Status, UserWithInviteCode, - MemberListResponse, + MemberCreateResponse, + MemberUpdateResponse, MemberDeleteResponse, + MemberGetResponse, ) ``` Methods: -- client.accounts.members.create(\*, account_id, \*\*params) -> UserWithInviteCode -- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> Member -- client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[MemberListResponse] +- client.accounts.members.create(\*, account_id, \*\*params) -> MemberCreateResponse +- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> MemberUpdateResponse +- client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Member] - client.accounts.members.delete(member_id, \*, account_id) -> Optional -- client.accounts.members.get(member_id, \*, account_id) -> Member +- client.accounts.members.get(member_id, \*, account_id) -> MemberGetResponse ## Roles @@ -72,7 +74,7 @@ from cloudflare.types.accounts import RoleGetResponse Methods: - client.accounts.roles.list(\*, account_id) -> SyncSinglePage[Role] -- client.accounts.roles.get(role_id, \*, account_id) -> RoleGetResponse +- client.accounts.roles.get(role_id, \*, account_id) -> object # OriginCACertificates @@ -123,7 +125,7 @@ Methods: - client.memberships.update(membership_id, \*\*params) -> MembershipUpdateResponse - client.memberships.list(\*\*params) -> SyncV4PagePaginationArray[Membership] -- client.memberships.delete(membership_id) -> MembershipDeleteResponse +- client.memberships.delete(membership_id) -> Optional - client.memberships.get(membership_id) -> MembershipGetResponse # User @@ -136,8 +138,8 @@ from cloudflare.types.user import UserEditResponse, UserGetResponse Methods: -- client.user.edit(\*\*params) -> UserEditResponse -- client.user.get() -> UserGetResponse +- client.user.edit(\*\*params) -> object +- client.user.get() -> object ## AuditLogs @@ -182,8 +184,8 @@ from cloudflare.types.user import Invite, InviteEditResponse, InviteGetResponse Methods: - client.user.invites.list() -> SyncSinglePage[Invite] -- client.user.invites.edit(invite_id, \*\*params) -> InviteEditResponse -- client.user.invites.get(invite_id) -> InviteGetResponse +- client.user.invites.edit(invite_id, \*\*params) -> object +- client.user.invites.get(invite_id) -> object ## Organizations @@ -197,7 +199,7 @@ Methods: - client.user.organizations.list(\*\*params) -> SyncV4PagePaginationArray[Organization] - client.user.organizations.delete(organization_id) -> OrganizationDeleteResponse -- client.user.organizations.get(organization_id) -> OrganizationGetResponse +- client.user.organizations.get(organization_id) -> object ## Subscriptions @@ -230,7 +232,6 @@ Types: ```python from cloudflare.types.user import ( CIDRList, - Policy, Token, TokenCreateResponse, TokenUpdateResponse, @@ -243,12 +244,12 @@ from cloudflare.types.user import ( Methods: -- client.user.tokens.create(\*\*params) -> TokenCreateResponse -- client.user.tokens.update(token_id, \*\*params) -> TokenUpdateResponse +- client.user.tokens.create(\*\*params) -> Optional +- client.user.tokens.update(token_id, \*\*params) -> object - client.user.tokens.list(\*\*params) -> SyncV4PagePaginationArray[object] - client.user.tokens.delete(token_id) -> Optional -- client.user.tokens.get(token_id) -> TokenGetResponse -- client.user.tokens.verify() -> TokenVerifyResponse +- client.user.tokens.get(token_id) -> object +- client.user.tokens.verify() -> Optional ### PermissionGroups diff --git a/src/cloudflare/resources/accounts/accounts.py b/src/cloudflare/resources/accounts/accounts.py index f2778f600c0..75b2a0e8fbe 100644 --- a/src/cloudflare/resources/accounts/accounts.py +++ b/src/cloudflare/resources/accounts/accounts.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -43,8 +43,6 @@ make_request_options, ) from ...types.accounts import account_list_params, account_update_params -from ...types.accounts.account_get_response import AccountGetResponse -from ...types.accounts.account_update_response import AccountUpdateResponse __all__ = ["AccountsResource", "AsyncAccountsResource"] @@ -78,7 +76,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AccountUpdateResponse: + ) -> object: """ Update an existing account. @@ -95,28 +93,23 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - AccountUpdateResponse, - self._put( - f"/accounts/{account_id}", - body=maybe_transform( - { - "name": name, - "settings": settings, - }, - account_update_params.AccountUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccountUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[AccountUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}", + body=maybe_transform( + { + "name": name, + "settings": settings, + }, + account_update_params.AccountUpdateParams, ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), ) def list( @@ -184,7 +177,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AccountGetResponse: + ) -> object: """ Get information about a specific account that you are a member of. @@ -197,21 +190,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - AccountGetResponse, - self._get( - f"/accounts/{account_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccountGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[AccountGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/accounts/{account_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) @@ -244,7 +232,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AccountUpdateResponse: + ) -> object: """ Update an existing account. @@ -261,28 +249,23 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - AccountUpdateResponse, - await self._put( - f"/accounts/{account_id}", - body=await async_maybe_transform( - { - "name": name, - "settings": settings, - }, - account_update_params.AccountUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccountUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[AccountUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}", + body=await async_maybe_transform( + { + "name": name, + "settings": settings, + }, + account_update_params.AccountUpdateParams, ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), ) def list( @@ -350,7 +333,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AccountGetResponse: + ) -> object: """ Get information about a specific account that you are a member of. @@ -363,21 +346,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - AccountGetResponse, - await self._get( - f"/accounts/{account_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccountGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[AccountGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/accounts/{account_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 602ab0f69d7..a36881ed695 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -2,13 +2,14 @@ from __future__ import annotations -from typing import List, Type, Iterable, Optional, cast +from typing import Any, List, Type, Iterable, Optional, cast, overload from typing_extensions import Literal import httpx from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import ( + required_args, maybe_transform, async_maybe_transform, ) @@ -28,9 +29,10 @@ ) from ...types.accounts import member_list_params, member_create_params, member_update_params from ...types.shared.member import Member -from ...types.accounts.member_list_response import MemberListResponse -from ...types.accounts.user_with_invite_code import UserWithInviteCode +from ...types.accounts.member_get_response import MemberGetResponse +from ...types.accounts.member_create_response import MemberCreateResponse from ...types.accounts.member_delete_response import MemberDeleteResponse +from ...types.accounts.member_update_response import MemberUpdateResponse __all__ = ["MembersResource", "AsyncMembersResource"] @@ -44,6 +46,7 @@ def with_raw_response(self) -> MembersResourceWithRawResponse: def with_streaming_response(self) -> MembersResourceWithStreamingResponse: return MembersResourceWithStreamingResponse(self) + @overload def create( self, *, @@ -57,7 +60,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> UserWithInviteCode: + ) -> MemberCreateResponse: """ Add a user to the list of members for this account. @@ -74,41 +77,95 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + def create( + self, + *, + account_id: str, + email: str, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], + status: Literal["accepted", "pending"] | 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, + ) -> MemberCreateResponse: + """ + Add a user to the list of members for this account. + + Args: + email: The contact email address of the user. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) + def create( + self, + *, + account_id: str, + email: str, + roles: List[str] | NotGiven = NOT_GIVEN, + status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | 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, + ) -> MemberCreateResponse: 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}/members", - body=maybe_transform( - { - "email": email, - "roles": roles, - "status": status, - }, - member_create_params.MemberCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UserWithInviteCode]._unwrapper, + return cast( + MemberCreateResponse, + self._post( + f"/accounts/{account_id}/members", + body=maybe_transform( + { + "email": email, + "roles": roles, + "status": status, + "policies": policies, + }, + member_create_params.MemberCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=cast( + Any, MemberCreateResponse + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[UserWithInviteCode], ResultWrapper[UserWithInviteCode]), ) + @overload def update( self, member_id: str, *, account_id: str, - roles: Iterable[member_update_params.Role], + roles: Iterable[member_update_params.MemberRole] | 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, - ) -> Member: + ) -> MemberUpdateResponse: """ Modify an account member. @@ -125,21 +182,77 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + def update( + self, + member_id: str, + *, + account_id: str, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], + # 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, + ) -> MemberUpdateResponse: + """ + Modify an account member. + + Args: + member_id: Membership identifier tag. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id"], ["account_id", "policies"]) + def update( + self, + member_id: str, + *, + account_id: str, + roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | 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, + ) -> MemberUpdateResponse: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return self._put( - f"/accounts/{account_id}/members/{member_id}", - body=maybe_transform({"roles": roles}, member_update_params.MemberUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Member]._unwrapper, + return cast( + MemberUpdateResponse, + self._put( + f"/accounts/{account_id}/members/{member_id}", + body=maybe_transform( + { + "roles": roles, + "policies": policies, + }, + member_update_params.MemberUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=cast( + Any, MemberUpdateResponse + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[Member], ResultWrapper[Member]), ) def list( @@ -157,7 +270,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[MemberListResponse]: + ) -> SyncV4PagePaginationArray[Member]: """ List all members of an account. @@ -184,7 +297,7 @@ def list( 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}/members", - page=SyncV4PagePaginationArray[MemberListResponse], + page=SyncV4PagePaginationArray[Member], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -201,7 +314,7 @@ def list( member_list_params.MemberListParams, ), ), - model=MemberListResponse, + model=Member, ) def delete( @@ -257,7 +370,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Member: + ) -> MemberGetResponse: """ Get information about a specific member of an account. @@ -276,16 +389,15 @@ def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return self._get( - f"/accounts/{account_id}/members/{member_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Member]._unwrapper, + return cast( + MemberGetResponse, + self._get( + f"/accounts/{account_id}/members/{member_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=cast(Any, MemberGetResponse), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[Member], ResultWrapper[Member]), ) @@ -298,6 +410,7 @@ def with_raw_response(self) -> AsyncMembersResourceWithRawResponse: def with_streaming_response(self) -> AsyncMembersResourceWithStreamingResponse: return AsyncMembersResourceWithStreamingResponse(self) + @overload async def create( self, *, @@ -311,7 +424,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> UserWithInviteCode: + ) -> MemberCreateResponse: """ Add a user to the list of members for this account. @@ -328,41 +441,95 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + async def create( + self, + *, + account_id: str, + email: str, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], + status: Literal["accepted", "pending"] | 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, + ) -> MemberCreateResponse: + """ + Add a user to the list of members for this account. + + Args: + email: The contact email address of the user. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) + async def create( + self, + *, + account_id: str, + email: str, + roles: List[str] | NotGiven = NOT_GIVEN, + status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | 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, + ) -> MemberCreateResponse: 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}/members", - body=await async_maybe_transform( - { - "email": email, - "roles": roles, - "status": status, - }, - member_create_params.MemberCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UserWithInviteCode]._unwrapper, + return cast( + MemberCreateResponse, + await self._post( + f"/accounts/{account_id}/members", + body=await async_maybe_transform( + { + "email": email, + "roles": roles, + "status": status, + "policies": policies, + }, + member_create_params.MemberCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=cast( + Any, MemberCreateResponse + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[UserWithInviteCode], ResultWrapper[UserWithInviteCode]), ) + @overload async def update( self, member_id: str, *, account_id: str, - roles: Iterable[member_update_params.Role], + roles: Iterable[member_update_params.MemberRole] | 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, - ) -> Member: + ) -> MemberUpdateResponse: """ Modify an account member. @@ -379,21 +546,77 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + async def update( + self, + member_id: str, + *, + account_id: str, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], + # 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, + ) -> MemberUpdateResponse: + """ + Modify an account member. + + Args: + member_id: Membership identifier tag. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id"], ["account_id", "policies"]) + async def update( + self, + member_id: str, + *, + account_id: str, + roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | 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, + ) -> MemberUpdateResponse: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return await self._put( - f"/accounts/{account_id}/members/{member_id}", - body=await async_maybe_transform({"roles": roles}, member_update_params.MemberUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Member]._unwrapper, + return cast( + MemberUpdateResponse, + await self._put( + f"/accounts/{account_id}/members/{member_id}", + body=await async_maybe_transform( + { + "roles": roles, + "policies": policies, + }, + member_update_params.MemberUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=cast( + Any, MemberUpdateResponse + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[Member], ResultWrapper[Member]), ) def list( @@ -411,7 +634,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[MemberListResponse, AsyncV4PagePaginationArray[MemberListResponse]]: + ) -> AsyncPaginator[Member, AsyncV4PagePaginationArray[Member]]: """ List all members of an account. @@ -438,7 +661,7 @@ def list( 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}/members", - page=AsyncV4PagePaginationArray[MemberListResponse], + page=AsyncV4PagePaginationArray[Member], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -455,7 +678,7 @@ def list( member_list_params.MemberListParams, ), ), - model=MemberListResponse, + model=Member, ) async def delete( @@ -511,7 +734,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Member: + ) -> MemberGetResponse: """ Get information about a specific member of an account. @@ -530,16 +753,15 @@ async def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return await self._get( - f"/accounts/{account_id}/members/{member_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Member]._unwrapper, + return cast( + MemberGetResponse, + await self._get( + f"/accounts/{account_id}/members/{member_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=cast(Any, MemberGetResponse), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[Member], ResultWrapper[Member]), ) diff --git a/src/cloudflare/resources/accounts/roles.py b/src/cloudflare/resources/accounts/roles.py index f316a2caa9a..2cb8405d641 100644 --- a/src/cloudflare/resources/accounts/roles.py +++ b/src/cloudflare/resources/accounts/roles.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, Optional, cast import httpx @@ -22,7 +22,6 @@ make_request_options, ) from ...types.shared.role import Role -from ...types.accounts.role_get_response import RoleGetResponse __all__ = ["RolesResource", "AsyncRolesResource"] @@ -81,7 +80,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RoleGetResponse: + ) -> object: """ Get information about a specific role for an account. @@ -96,21 +95,16 @@ def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - RoleGetResponse, - self._get( - f"/accounts/{account_id}/roles/{role_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RoleGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RoleGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/accounts/{account_id}/roles/{role_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) @@ -168,7 +162,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RoleGetResponse: + ) -> object: """ Get information about a specific role for an account. @@ -183,21 +177,16 @@ async def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - RoleGetResponse, - await self._get( - f"/accounts/{account_id}/roles/{role_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RoleGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RoleGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/accounts/{account_id}/roles/{role_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) diff --git a/src/cloudflare/resources/memberships.py b/src/cloudflare/resources/memberships.py index aac512175a7..0884e4c7e8b 100644 --- a/src/cloudflare/resources/memberships.py +++ b/src/cloudflare/resources/memberships.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, cast +from typing import Any, Type, Optional, cast from typing_extensions import Literal import httpx @@ -80,14 +80,10 @@ def update( f"/memberships/{membership_id}", body=maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MembershipUpdateResponse]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=cast( - Any, ResultWrapper[MembershipUpdateResponse] + Any, MembershipUpdateResponse ), # Union types cannot be passed in as arguments in the type system ), ) @@ -167,7 +163,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipDeleteResponse: + ) -> Optional[MembershipDeleteResponse]: """ Remove the associated member from an account. @@ -191,9 +187,9 @@ def delete( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MembershipDeleteResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MembershipDeleteResponse]]._unwrapper, ), - cast_to=cast(Type[MembershipDeleteResponse], ResultWrapper[MembershipDeleteResponse]), + cast_to=cast(Type[Optional[MembershipDeleteResponse]], ResultWrapper[MembershipDeleteResponse]), ) def get( @@ -228,14 +224,10 @@ def get( self._get( f"/memberships/{membership_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MembershipGetResponse]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=cast( - Any, ResultWrapper[MembershipGetResponse] + Any, MembershipGetResponse ), # Union types cannot be passed in as arguments in the type system ), ) @@ -286,14 +278,10 @@ async def update( f"/memberships/{membership_id}", body=await async_maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MembershipUpdateResponse]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=cast( - Any, ResultWrapper[MembershipUpdateResponse] + Any, MembershipUpdateResponse ), # Union types cannot be passed in as arguments in the type system ), ) @@ -373,7 +361,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipDeleteResponse: + ) -> Optional[MembershipDeleteResponse]: """ Remove the associated member from an account. @@ -397,9 +385,9 @@ async def delete( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MembershipDeleteResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MembershipDeleteResponse]]._unwrapper, ), - cast_to=cast(Type[MembershipDeleteResponse], ResultWrapper[MembershipDeleteResponse]), + cast_to=cast(Type[Optional[MembershipDeleteResponse]], ResultWrapper[MembershipDeleteResponse]), ) async def get( @@ -434,14 +422,10 @@ async def get( await self._get( f"/memberships/{membership_id}", options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MembershipGetResponse]._unwrapper, + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=cast( - Any, ResultWrapper[MembershipGetResponse] + Any, MembershipGetResponse ), # Union types cannot be passed in as arguments in the type system ), ) diff --git a/src/cloudflare/resources/user/invites.py b/src/cloudflare/resources/user/invites.py index 197fa07e530..84d658ed708 100644 --- a/src/cloudflare/resources/user/invites.py +++ b/src/cloudflare/resources/user/invites.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -28,8 +28,6 @@ make_request_options, ) from ...types.user.invite import Invite -from ...types.user.invite_get_response import InviteGetResponse -from ...types.user.invite_edit_response import InviteEditResponse __all__ = ["InvitesResource", "AsyncInvitesResource"] @@ -74,7 +72,7 @@ def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> InviteEditResponse: + ) -> object: """ Responds to an invitation. @@ -93,22 +91,17 @@ def edit( """ if not invite_id: raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}") - return cast( - InviteEditResponse, - self._patch( - f"/user/invites/{invite_id}", - body=maybe_transform({"status": status}, invite_edit_params.InviteEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[InviteEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[InviteEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._patch( + f"/user/invites/{invite_id}", + body=maybe_transform({"status": status}, invite_edit_params.InviteEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) def get( @@ -121,7 +114,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> InviteGetResponse: + ) -> object: """ Gets the details of an invitation. @@ -138,21 +131,16 @@ def get( """ if not invite_id: raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}") - return cast( - InviteGetResponse, - self._get( - f"/user/invites/{invite_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[InviteGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[InviteGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/user/invites/{invite_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) @@ -196,7 +184,7 @@ async def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> InviteEditResponse: + ) -> object: """ Responds to an invitation. @@ -215,22 +203,17 @@ async def edit( """ if not invite_id: raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}") - return cast( - InviteEditResponse, - await self._patch( - f"/user/invites/{invite_id}", - body=await async_maybe_transform({"status": status}, invite_edit_params.InviteEditParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[InviteEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[InviteEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._patch( + f"/user/invites/{invite_id}", + body=await async_maybe_transform({"status": status}, invite_edit_params.InviteEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) async def get( @@ -243,7 +226,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> InviteGetResponse: + ) -> object: """ Gets the details of an invitation. @@ -260,21 +243,16 @@ async def get( """ if not invite_id: raise ValueError(f"Expected a non-empty value for `invite_id` but received {invite_id!r}") - return cast( - InviteGetResponse, - await self._get( - f"/user/invites/{invite_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[InviteGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[InviteGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/user/invites/{invite_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) diff --git a/src/cloudflare/resources/user/organizations.py b/src/cloudflare/resources/user/organizations.py index daf90da2aed..be94b8acb6a 100644 --- a/src/cloudflare/resources/user/organizations.py +++ b/src/cloudflare/resources/user/organizations.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -25,7 +25,6 @@ make_request_options, ) from ...types.user.organization import Organization -from ...types.user.organization_get_response import OrganizationGetResponse from ...types.user.organization_delete_response import OrganizationDeleteResponse __all__ = ["OrganizationsResource", "AsyncOrganizationsResource"] @@ -152,7 +151,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> OrganizationGetResponse: + ) -> object: """ Gets a specific organization the user is associated with. @@ -169,21 +168,16 @@ def get( """ if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") - return cast( - OrganizationGetResponse, - self._get( - f"/user/organizations/{organization_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[OrganizationGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[OrganizationGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/user/organizations/{organization_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) @@ -308,7 +302,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> OrganizationGetResponse: + ) -> object: """ Gets a specific organization the user is associated with. @@ -325,21 +319,16 @@ async def get( """ if not organization_id: raise ValueError(f"Expected a non-empty value for `organization_id` but received {organization_id!r}") - return cast( - OrganizationGetResponse, - await self._get( - f"/user/organizations/{organization_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[OrganizationGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[OrganizationGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/user/organizations/{organization_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) diff --git a/src/cloudflare/resources/user/tokens/tokens.py b/src/cloudflare/resources/user/tokens/tokens.py index 5a71d4cfdb1..4b3f1a41c26 100644 --- a/src/cloudflare/resources/user/tokens/tokens.py +++ b/src/cloudflare/resources/user/tokens/tokens.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, Iterable, Optional, cast +from typing import Type, Union, Iterable, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -44,11 +44,8 @@ PermissionGroupsResourceWithStreamingResponse, AsyncPermissionGroupsResourceWithStreamingResponse, ) -from ....types.user.policy_param import PolicyParam -from ....types.user.token_get_response import TokenGetResponse from ....types.user.token_create_response import TokenCreateResponse from ....types.user.token_delete_response import TokenDeleteResponse -from ....types.user.token_update_response import TokenUpdateResponse from ....types.user.token_verify_response import TokenVerifyResponse __all__ = ["TokensResource", "AsyncTokensResource"] @@ -75,7 +72,7 @@ def create( self, *, name: str, - policies: Iterable[PolicyParam], + policies: Iterable[token_create_params.Policy], condition: token_create_params.Condition | NotGiven = NOT_GIVEN, expires_on: Union[str, datetime] | NotGiven = NOT_GIVEN, not_before: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -85,7 +82,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TokenCreateResponse: + ) -> Optional[TokenCreateResponse]: """ Create a new access token. @@ -124,9 +121,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TokenCreateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[TokenCreateResponse]]._unwrapper, ), - cast_to=cast(Type[TokenCreateResponse], ResultWrapper[TokenCreateResponse]), + cast_to=cast(Type[Optional[TokenCreateResponse]], ResultWrapper[TokenCreateResponse]), ) def update( @@ -134,7 +131,7 @@ def update( token_id: object, *, name: str, - policies: Iterable[PolicyParam], + policies: Iterable[token_update_params.Policy], status: Literal["active", "disabled", "expired"], condition: token_update_params.Condition | NotGiven = NOT_GIVEN, expires_on: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -145,7 +142,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TokenUpdateResponse: + ) -> object: """ Update an existing token. @@ -169,32 +166,27 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - TokenUpdateResponse, - self._put( - f"/user/tokens/{token_id}", - body=maybe_transform( - { - "name": name, - "policies": policies, - "status": status, - "condition": condition, - "expires_on": expires_on, - "not_before": not_before, - }, - token_update_params.TokenUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[TokenUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[TokenUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/user/tokens/{token_id}", + body=maybe_transform( + { + "name": name, + "policies": policies, + "status": status, + "condition": condition, + "expires_on": expires_on, + "not_before": not_before, + }, + token_update_params.TokenUpdateParams, ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), ) def list( @@ -293,7 +285,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TokenGetResponse: + ) -> object: """ Get information about a specific token. @@ -306,21 +298,16 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - TokenGetResponse, - self._get( - f"/user/tokens/{token_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[TokenGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[TokenGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/user/tokens/{token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) def verify( @@ -332,7 +319,7 @@ def verify( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TokenVerifyResponse: + ) -> Optional[TokenVerifyResponse]: """Test whether a token works.""" return self._get( "/user/tokens/verify", @@ -341,9 +328,9 @@ def verify( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TokenVerifyResponse]._unwrapper, + post_parser=ResultWrapper[Optional[TokenVerifyResponse]]._unwrapper, ), - cast_to=cast(Type[TokenVerifyResponse], ResultWrapper[TokenVerifyResponse]), + cast_to=cast(Type[Optional[TokenVerifyResponse]], ResultWrapper[TokenVerifyResponse]), ) @@ -368,7 +355,7 @@ async def create( self, *, name: str, - policies: Iterable[PolicyParam], + policies: Iterable[token_create_params.Policy], condition: token_create_params.Condition | NotGiven = NOT_GIVEN, expires_on: Union[str, datetime] | NotGiven = NOT_GIVEN, not_before: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -378,7 +365,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TokenCreateResponse: + ) -> Optional[TokenCreateResponse]: """ Create a new access token. @@ -417,9 +404,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TokenCreateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[TokenCreateResponse]]._unwrapper, ), - cast_to=cast(Type[TokenCreateResponse], ResultWrapper[TokenCreateResponse]), + cast_to=cast(Type[Optional[TokenCreateResponse]], ResultWrapper[TokenCreateResponse]), ) async def update( @@ -427,7 +414,7 @@ async def update( token_id: object, *, name: str, - policies: Iterable[PolicyParam], + policies: Iterable[token_update_params.Policy], status: Literal["active", "disabled", "expired"], condition: token_update_params.Condition | NotGiven = NOT_GIVEN, expires_on: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -438,7 +425,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TokenUpdateResponse: + ) -> object: """ Update an existing token. @@ -462,32 +449,27 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - TokenUpdateResponse, - await self._put( - f"/user/tokens/{token_id}", - body=await async_maybe_transform( - { - "name": name, - "policies": policies, - "status": status, - "condition": condition, - "expires_on": expires_on, - "not_before": not_before, - }, - token_update_params.TokenUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[TokenUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[TokenUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/user/tokens/{token_id}", + body=await async_maybe_transform( + { + "name": name, + "policies": policies, + "status": status, + "condition": condition, + "expires_on": expires_on, + "not_before": not_before, + }, + token_update_params.TokenUpdateParams, ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), ) def list( @@ -586,7 +568,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TokenGetResponse: + ) -> object: """ Get information about a specific token. @@ -599,21 +581,16 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - TokenGetResponse, - await self._get( - f"/user/tokens/{token_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[TokenGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[TokenGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/user/tokens/{token_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) async def verify( @@ -625,7 +602,7 @@ async def verify( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> TokenVerifyResponse: + ) -> Optional[TokenVerifyResponse]: """Test whether a token works.""" return await self._get( "/user/tokens/verify", @@ -634,9 +611,9 @@ async def verify( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[TokenVerifyResponse]._unwrapper, + post_parser=ResultWrapper[Optional[TokenVerifyResponse]]._unwrapper, ), - cast_to=cast(Type[TokenVerifyResponse], ResultWrapper[TokenVerifyResponse]), + cast_to=cast(Type[Optional[TokenVerifyResponse]], ResultWrapper[TokenVerifyResponse]), ) diff --git a/src/cloudflare/resources/user/tokens/value.py b/src/cloudflare/resources/user/tokens/value.py index 1a35ddc543e..90195f2c4d2 100644 --- a/src/cloudflare/resources/user/tokens/value.py +++ b/src/cloudflare/resources/user/tokens/value.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -70,7 +70,7 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Value]._unwrapper, + post_parser=ResultWrapper[Optional[Value]]._unwrapper, ), cast_to=cast(Type[str], ResultWrapper[str]), ) @@ -117,7 +117,7 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Value]._unwrapper, + post_parser=ResultWrapper[Optional[Value]]._unwrapper, ), cast_to=cast(Type[str], ResultWrapper[str]), ) diff --git a/src/cloudflare/resources/user/user.py b/src/cloudflare/resources/user/user.py index 3e9117a3321..083b24efdb0 100644 --- a/src/cloudflare/resources/user/user.py +++ b/src/cloudflare/resources/user/user.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Optional, cast +from typing import Type, Optional, cast import httpx @@ -74,8 +74,6 @@ make_request_options, ) from .billing.billing import BillingResource, AsyncBillingResource -from ...types.user.user_get_response import UserGetResponse -from ...types.user.user_edit_response import UserEditResponse __all__ = ["UserResource", "AsyncUserResource"] @@ -127,7 +125,7 @@ def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> UserEditResponse: + ) -> object: """ Edit part of your user details. @@ -150,31 +148,26 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - UserEditResponse, - self._patch( - "/user", - body=maybe_transform( - { - "country": country, - "first_name": first_name, - "last_name": last_name, - "telephone": telephone, - "zipcode": zipcode, - }, - user_edit_params.UserEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UserEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UserEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._patch( + "/user", + body=maybe_transform( + { + "country": country, + "first_name": first_name, + "last_name": last_name, + "telephone": telephone, + "zipcode": zipcode, + }, + user_edit_params.UserEditParams, ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, + ), + cast_to=cast(Type[object], ResultWrapper[object]), ) def get( @@ -186,23 +179,18 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> UserGetResponse: + ) -> object: """User Details""" - return cast( - UserGetResponse, - self._get( - "/user", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UserGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UserGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._get( + "/user", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) @@ -253,7 +241,7 @@ async def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> UserEditResponse: + ) -> object: """ Edit part of your user details. @@ -276,31 +264,26 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ - return cast( - UserEditResponse, - await self._patch( - "/user", - body=await async_maybe_transform( - { - "country": country, - "first_name": first_name, - "last_name": last_name, - "telephone": telephone, - "zipcode": zipcode, - }, - user_edit_params.UserEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UserEditResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UserEditResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._patch( + "/user", + body=await async_maybe_transform( + { + "country": country, + "first_name": first_name, + "last_name": last_name, + "telephone": telephone, + "zipcode": zipcode, + }, + user_edit_params.UserEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) async def get( @@ -312,23 +295,18 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> UserGetResponse: + ) -> object: """User Details""" - return cast( - UserGetResponse, - await self._get( - "/user", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UserGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UserGetResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + "/user", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[object]]._unwrapper, ), + cast_to=cast(Type[object], ResultWrapper[object]), ) diff --git a/src/cloudflare/types/accounts/__init__.py b/src/cloudflare/types/accounts/__init__.py index 71487082562..5b4a4199ba4 100644 --- a/src/cloudflare/types/accounts/__init__.py +++ b/src/cloudflare/types/accounts/__init__.py @@ -4,14 +4,12 @@ from .status import Status as Status from .account import Account as Account -from .role_get_response import RoleGetResponse as RoleGetResponse from .member_list_params import MemberListParams as MemberListParams from .account_list_params import AccountListParams as AccountListParams -from .account_get_response import AccountGetResponse as AccountGetResponse +from .member_get_response import MemberGetResponse as MemberGetResponse from .member_create_params import MemberCreateParams as MemberCreateParams -from .member_list_response import MemberListResponse as MemberListResponse from .member_update_params import MemberUpdateParams as MemberUpdateParams from .account_update_params import AccountUpdateParams as AccountUpdateParams -from .user_with_invite_code import UserWithInviteCode as UserWithInviteCode +from .member_create_response import MemberCreateResponse as MemberCreateResponse from .member_delete_response import MemberDeleteResponse as MemberDeleteResponse -from .account_update_response import AccountUpdateResponse as AccountUpdateResponse +from .member_update_response import MemberUpdateResponse as MemberUpdateResponse diff --git a/src/cloudflare/types/accounts/account_get_response.py b/src/cloudflare/types/accounts/account_get_response.py deleted file mode 100644 index 90ec592d62b..00000000000 --- a/src/cloudflare/types/accounts/account_get_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["AccountGetResponse"] - -AccountGetResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/accounts/account_update_response.py b/src/cloudflare/types/accounts/account_update_response.py deleted file mode 100644 index a10025d46aa..00000000000 --- a/src/cloudflare/types/accounts/account_update_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["AccountUpdateResponse"] - -AccountUpdateResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/accounts/member_create_params.py b/src/cloudflare/types/accounts/member_create_params.py index 69acda8f5da..8706522e855 100644 --- a/src/cloudflare/types/accounts/member_create_params.py +++ b/src/cloudflare/types/accounts/member_create_params.py @@ -2,13 +2,20 @@ from __future__ import annotations -from typing import List +from typing import List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -__all__ = ["MemberCreateParams"] +__all__ = [ + "MemberCreateParams", + "IamCreateMemberWithRoles", + "IamCreateMemberWithPolicies", + "IamCreateMemberWithPoliciesPolicy", + "IamCreateMemberWithPoliciesPolicyPermissionGroup", + "IamCreateMemberWithPoliciesPolicyResourceGroup", +] -class MemberCreateParams(TypedDict, total=False): +class IamCreateMemberWithRoles(TypedDict, total=False): account_id: Required[str] email: Required[str] @@ -18,3 +25,39 @@ class MemberCreateParams(TypedDict, total=False): """Array of roles associated with this member.""" status: Literal["accepted", "pending"] + + +class IamCreateMemberWithPolicies(TypedDict, total=False): + account_id: Required[str] + + email: Required[str] + """The contact email address of the user.""" + + policies: Required[Iterable[IamCreateMemberWithPoliciesPolicy]] + """Array of policies associated with this member.""" + + status: Literal["accepted", "pending"] + + +class IamCreateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamCreateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamCreateMemberWithPoliciesPolicy(TypedDict, total=False): + access: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyPermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resource_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyResourceGroup]] + """A list of resource groups that the policy applies to.""" + + +MemberCreateParams = Union[IamCreateMemberWithRoles, IamCreateMemberWithPolicies] diff --git a/src/cloudflare/types/accounts/member_create_response.py b/src/cloudflare/types/accounts/member_create_response.py new file mode 100644 index 00000000000..02ed65d99c8 --- /dev/null +++ b/src/cloudflare/types/accounts/member_create_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +from ..._models import BaseModel +from ..shared.member import Member + +__all__ = ["MemberCreateResponse", "IamAPIResponseCommon"] + + +class IamAPIResponseCommon(BaseModel): + result: Optional[Member] = None + + +MemberCreateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] diff --git a/src/cloudflare/types/accounts/member_get_response.py b/src/cloudflare/types/accounts/member_get_response.py new file mode 100644 index 00000000000..b4ff99e9597 --- /dev/null +++ b/src/cloudflare/types/accounts/member_get_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +from ..._models import BaseModel +from ..shared.member import Member + +__all__ = ["MemberGetResponse", "IamAPIResponseCommon"] + + +class IamAPIResponseCommon(BaseModel): + result: Optional[Member] = None + + +MemberGetResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] diff --git a/src/cloudflare/types/accounts/member_list_response.py b/src/cloudflare/types/accounts/member_list_response.py deleted file mode 100644 index ca5c995cf44..00000000000 --- a/src/cloudflare/types/accounts/member_list_response.py +++ /dev/null @@ -1,26 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from typing_extensions import Literal - -from ..._models import BaseModel -from ..shared.role import Role - -__all__ = ["MemberListResponse"] - - -class MemberListResponse(BaseModel): - id: str - """Identifier""" - - email: str - """The contact email address of the user.""" - - name: Optional[str] = None - """Member Name.""" - - roles: List[Role] - """Roles assigned to this Member.""" - - status: Literal["accepted", "invited"] - """A member's status in the organization.""" diff --git a/src/cloudflare/types/accounts/member_update_params.py b/src/cloudflare/types/accounts/member_update_params.py index 48139d2a39b..851713903c8 100644 --- a/src/cloudflare/types/accounts/member_update_params.py +++ b/src/cloudflare/types/accounts/member_update_params.py @@ -2,19 +2,58 @@ from __future__ import annotations -from typing import Iterable -from typing_extensions import Required, TypedDict +from typing import Union, Iterable +from typing_extensions import Literal, Required, TypedDict -__all__ = ["MemberUpdateParams", "Role"] +__all__ = [ + "MemberUpdateParams", + "Member", + "MemberRole", + "IamUpdateMemberWithPolicies", + "IamUpdateMemberWithPoliciesPolicy", + "IamUpdateMemberWithPoliciesPolicyPermissionGroup", + "IamUpdateMemberWithPoliciesPolicyResourceGroup", +] -class MemberUpdateParams(TypedDict, total=False): +class Member(TypedDict, total=False): account_id: Required[str] - roles: Required[Iterable[Role]] + roles: Iterable[MemberRole] """Roles assigned to this member.""" -class Role(TypedDict, total=False): +class MemberRole(TypedDict, total=False): id: Required[str] """Role identifier tag.""" + + +class IamUpdateMemberWithPolicies(TypedDict, total=False): + account_id: Required[str] + + policies: Required[Iterable[IamUpdateMemberWithPoliciesPolicy]] + """Array of policies associated with this member.""" + + +class IamUpdateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamUpdateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamUpdateMemberWithPoliciesPolicy(TypedDict, total=False): + access: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyPermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resource_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyResourceGroup]] + """A list of resource groups that the policy applies to.""" + + +MemberUpdateParams = Union[Member, IamUpdateMemberWithPolicies] diff --git a/src/cloudflare/types/accounts/member_update_response.py b/src/cloudflare/types/accounts/member_update_response.py new file mode 100644 index 00000000000..47de5ca79fe --- /dev/null +++ b/src/cloudflare/types/accounts/member_update_response.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +from ..._models import BaseModel +from ..shared.member import Member + +__all__ = ["MemberUpdateResponse", "IamAPIResponseCommon"] + + +class IamAPIResponseCommon(BaseModel): + result: Optional[Member] = None + + +MemberUpdateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] diff --git a/src/cloudflare/types/accounts/role_get_response.py b/src/cloudflare/types/accounts/role_get_response.py deleted file mode 100644 index 50bca84535e..00000000000 --- a/src/cloudflare/types/accounts/role_get_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["RoleGetResponse"] - -RoleGetResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/accounts/user_with_invite_code.py b/src/cloudflare/types/accounts/user_with_invite_code.py deleted file mode 100644 index ab928845355..00000000000 --- a/src/cloudflare/types/accounts/user_with_invite_code.py +++ /dev/null @@ -1,82 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional - -from ..._models import BaseModel -from ..shared.permission_grant import PermissionGrant - -__all__ = ["UserWithInviteCode", "Role", "RolePermissions", "User"] - - -class RolePermissions(BaseModel): - analytics: Optional[PermissionGrant] = None - - billing: Optional[PermissionGrant] = None - - cache_purge: Optional[PermissionGrant] = None - - dns: Optional[PermissionGrant] = None - - dns_records: Optional[PermissionGrant] = None - - lb: Optional[PermissionGrant] = None - - logs: Optional[PermissionGrant] = None - - organization: Optional[PermissionGrant] = None - - ssl: Optional[PermissionGrant] = None - - waf: Optional[PermissionGrant] = None - - zone_settings: Optional[PermissionGrant] = None - - zones: Optional[PermissionGrant] = None - - -class Role(BaseModel): - id: str - """Role identifier tag.""" - - description: str - """Description of role's permissions.""" - - name: str - """Role name.""" - - permissions: RolePermissions - - -class User(BaseModel): - email: str - """The contact email address of the user.""" - - id: Optional[str] = None - """Identifier""" - - first_name: Optional[str] = None - """User's first name""" - - last_name: Optional[str] = None - """User's last name""" - - two_factor_authentication_enabled: Optional[bool] = None - """Indicates whether two-factor authentication is enabled for the user account. - - Does not apply to API authentication. - """ - - -class UserWithInviteCode(BaseModel): - id: str - """Membership identifier tag.""" - - roles: List[Role] - """Roles assigned to this member.""" - - status: object - - user: User - - code: Optional[str] = None - """The unique activation code for the account membership.""" diff --git a/src/cloudflare/types/memberships/membership.py b/src/cloudflare/types/memberships/membership.py index a820bdcb233..a7fb6720539 100644 --- a/src/cloudflare/types/memberships/membership.py +++ b/src/cloudflare/types/memberships/membership.py @@ -49,9 +49,6 @@ class Membership(BaseModel): given account. """ - code: Optional[str] = None - """The unique activation code for the account membership.""" - permissions: Optional[Permissions] = None """All access permissions for the user at the account.""" diff --git a/src/cloudflare/types/memberships/membership_get_response.py b/src/cloudflare/types/memberships/membership_get_response.py index 58aa5f5943b..e586b51180f 100644 --- a/src/cloudflare/types/memberships/membership_get_response.py +++ b/src/cloudflare/types/memberships/membership_get_response.py @@ -2,6 +2,14 @@ from typing import Union, Optional -__all__ = ["MembershipGetResponse"] +from ..._models import BaseModel +from .membership import Membership -MembershipGetResponse = Union[Optional[str], Optional[object]] +__all__ = ["MembershipGetResponse", "IamAPIResponseCommon"] + + +class IamAPIResponseCommon(BaseModel): + result: Optional[Membership] = None + + +MembershipGetResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] diff --git a/src/cloudflare/types/memberships/membership_update_response.py b/src/cloudflare/types/memberships/membership_update_response.py index adcc658f350..6aa89e9311b 100644 --- a/src/cloudflare/types/memberships/membership_update_response.py +++ b/src/cloudflare/types/memberships/membership_update_response.py @@ -2,6 +2,14 @@ from typing import Union, Optional -__all__ = ["MembershipUpdateResponse"] +from ..._models import BaseModel +from .membership import Membership -MembershipUpdateResponse = Union[Optional[str], Optional[object]] +__all__ = ["MembershipUpdateResponse", "IamAPIResponseCommon"] + + +class IamAPIResponseCommon(BaseModel): + result: Optional[Membership] = None + + +MembershipUpdateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] diff --git a/src/cloudflare/types/shared/member.py b/src/cloudflare/types/shared/member.py index 101555dd229..c4282582d50 100644 --- a/src/cloudflare/types/shared/member.py +++ b/src/cloudflare/types/shared/member.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel from .permission_grant import PermissionGrant @@ -68,12 +69,14 @@ class User(BaseModel): class Member(BaseModel): - id: str + id: Optional[str] = None """Membership identifier tag.""" - roles: List[Role] + roles: Optional[List[Role]] = None """Roles assigned to this member.""" - status: object + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" - user: User + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/user/__init__.py b/src/cloudflare/types/user/__init__.py index 986ee04d241..5b1b8c37ba1 100644 --- a/src/cloudflare/types/user/__init__.py +++ b/src/cloudflare/types/user/__init__.py @@ -6,30 +6,22 @@ from .cidr_list import CIDRList as CIDRList from .rate_plan import RatePlan as RatePlan from .organization import Organization as Organization -from .policy_param import PolicyParam as PolicyParam from .subscription import Subscription as Subscription from .rate_plan_param import RatePlanParam as RatePlanParam from .user_edit_params import UserEditParams as UserEditParams from .subscription_zone import SubscriptionZone as SubscriptionZone from .token_list_params import TokenListParams as TokenListParams -from .user_get_response import UserGetResponse as UserGetResponse from .invite_edit_params import InviteEditParams as InviteEditParams -from .token_get_response import TokenGetResponse as TokenGetResponse -from .user_edit_response import UserEditResponse as UserEditResponse -from .invite_get_response import InviteGetResponse as InviteGetResponse from .token_create_params import TokenCreateParams as TokenCreateParams from .token_update_params import TokenUpdateParams as TokenUpdateParams -from .invite_edit_response import InviteEditResponse as InviteEditResponse from .audit_log_list_params import AuditLogListParams as AuditLogListParams from .token_create_response import TokenCreateResponse as TokenCreateResponse from .token_delete_response import TokenDeleteResponse as TokenDeleteResponse -from .token_update_response import TokenUpdateResponse as TokenUpdateResponse from .token_verify_response import TokenVerifyResponse as TokenVerifyResponse from .subscription_component import SubscriptionComponent as SubscriptionComponent from .subscription_zone_param import SubscriptionZoneParam as SubscriptionZoneParam from .organization_list_params import OrganizationListParams as OrganizationListParams from .subscription_edit_params import SubscriptionEditParams as SubscriptionEditParams -from .organization_get_response import OrganizationGetResponse as OrganizationGetResponse from .subscription_get_response import SubscriptionGetResponse as SubscriptionGetResponse from .subscription_edit_response import SubscriptionEditResponse as SubscriptionEditResponse from .subscription_update_params import SubscriptionUpdateParams as SubscriptionUpdateParams diff --git a/src/cloudflare/types/user/invite_edit_response.py b/src/cloudflare/types/user/invite_edit_response.py deleted file mode 100644 index 646377ca831..00000000000 --- a/src/cloudflare/types/user/invite_edit_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["InviteEditResponse"] - -InviteEditResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/user/invite_get_response.py b/src/cloudflare/types/user/invite_get_response.py deleted file mode 100644 index 27a15f71311..00000000000 --- a/src/cloudflare/types/user/invite_get_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["InviteGetResponse"] - -InviteGetResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/user/organization.py b/src/cloudflare/types/user/organization.py index 6c1aa83f02d..3a690386174 100644 --- a/src/cloudflare/types/user/organization.py +++ b/src/cloudflare/types/user/organization.py @@ -23,4 +23,4 @@ class Organization(BaseModel): """List of roles that a user has within an organization.""" status: Optional[Status] = None - """Whether the user is a member of the organization or has an inivitation pending.""" + """Whether the user is a member of the organization or has an invitation pending.""" diff --git a/src/cloudflare/types/user/organization_get_response.py b/src/cloudflare/types/user/organization_get_response.py deleted file mode 100644 index 4ba74b46f85..00000000000 --- a/src/cloudflare/types/user/organization_get_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["OrganizationGetResponse"] - -OrganizationGetResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/user/policy_param.py b/src/cloudflare/types/user/policy_param.py deleted file mode 100644 index d9f62820fe7..00000000000 --- a/src/cloudflare/types/user/policy_param.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 Literal, Required, TypedDict - -__all__ = ["PolicyParam", "PermissionGroup"] - - -class PermissionGroup(TypedDict, total=False): - pass - - -class PolicyParam(TypedDict, total=False): - effect: Required[Literal["allow", "deny"]] - """Allow or deny operations against the resources.""" - - permission_groups: Required[Iterable[PermissionGroup]] - """A set of permission groups that are specified to the policy.""" - - resources: Required[object] - """A list of resource names that the policy applies to.""" diff --git a/src/cloudflare/types/user/token_create_params.py b/src/cloudflare/types/user/token_create_params.py index 4ab228c06c6..842eed61529 100644 --- a/src/cloudflare/types/user/token_create_params.py +++ b/src/cloudflare/types/user/token_create_params.py @@ -4,20 +4,19 @@ from typing import List, Union, Iterable from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypedDict from ..._utils import PropertyInfo from .cidr_list import CIDRList -from .policy_param import PolicyParam -__all__ = ["TokenCreateParams", "Condition", "ConditionRequestIP"] +__all__ = ["TokenCreateParams", "Policy", "PolicyPermissionGroup", "Condition", "ConditionRequestIP"] class TokenCreateParams(TypedDict, total=False): name: Required[str] """Token name.""" - policies: Required[Iterable[PolicyParam]] + policies: Required[Iterable[Policy]] """List of access policies assigned to the token.""" condition: Condition @@ -32,6 +31,21 @@ class TokenCreateParams(TypedDict, total=False): """The time before which the token MUST NOT be accepted for processing.""" +class PolicyPermissionGroup(TypedDict, total=False): + pass + + +class Policy(TypedDict, total=False): + effect: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[PolicyPermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resources: Required[object] + """A list of resource names that the policy applies to.""" + + _ConditionRequestIPReservedKeywords = TypedDict( "_ConditionRequestIPReservedKeywords", { diff --git a/src/cloudflare/types/user/token_get_response.py b/src/cloudflare/types/user/token_get_response.py deleted file mode 100644 index a45eff43263..00000000000 --- a/src/cloudflare/types/user/token_get_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["TokenGetResponse"] - -TokenGetResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/user/token_update_params.py b/src/cloudflare/types/user/token_update_params.py index d564213465b..9299975073e 100644 --- a/src/cloudflare/types/user/token_update_params.py +++ b/src/cloudflare/types/user/token_update_params.py @@ -8,16 +8,15 @@ from ..._utils import PropertyInfo from .cidr_list import CIDRList -from .policy_param import PolicyParam -__all__ = ["TokenUpdateParams", "Condition", "ConditionRequestIP"] +__all__ = ["TokenUpdateParams", "Policy", "PolicyPermissionGroup", "Condition", "ConditionRequestIP"] class TokenUpdateParams(TypedDict, total=False): name: Required[str] """Token name.""" - policies: Required[Iterable[PolicyParam]] + policies: Required[Iterable[Policy]] """List of access policies assigned to the token.""" status: Required[Literal["active", "disabled", "expired"]] @@ -35,6 +34,21 @@ class TokenUpdateParams(TypedDict, total=False): """The time before which the token MUST NOT be accepted for processing.""" +class PolicyPermissionGroup(TypedDict, total=False): + pass + + +class Policy(TypedDict, total=False): + effect: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[PolicyPermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resources: Required[object] + """A list of resource names that the policy applies to.""" + + _ConditionRequestIPReservedKeywords = TypedDict( "_ConditionRequestIPReservedKeywords", { diff --git a/src/cloudflare/types/user/token_update_response.py b/src/cloudflare/types/user/token_update_response.py deleted file mode 100644 index 4600c9aba02..00000000000 --- a/src/cloudflare/types/user/token_update_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["TokenUpdateResponse"] - -TokenUpdateResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/user/user_edit_response.py b/src/cloudflare/types/user/user_edit_response.py deleted file mode 100644 index e2077cf822d..00000000000 --- a/src/cloudflare/types/user/user_edit_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["UserEditResponse"] - -UserEditResponse = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/user/user_get_response.py b/src/cloudflare/types/user/user_get_response.py deleted file mode 100644 index 7a0f59652a5..00000000000 --- a/src/cloudflare/types/user/user_get_response.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional - -__all__ = ["UserGetResponse"] - -UserGetResponse = Union[Optional[str], Optional[object]] diff --git a/tests/api_resources/accounts/test_members.py b/tests/api_resources/accounts/test_members.py index 4b8885d1efd..05cb40faa08 100644 --- a/tests/api_resources/accounts/test_members.py +++ b/tests/api_resources/accounts/test_members.py @@ -12,9 +12,10 @@ from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from cloudflare.types.shared import Member from cloudflare.types.accounts import ( - MemberListResponse, - UserWithInviteCode, + MemberGetResponse, + MemberCreateResponse, MemberDeleteResponse, + MemberUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -24,7 +25,7 @@ class TestMembers: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - def test_method_create(self, client: Cloudflare) -> None: + def test_method_create_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.create( account_id="string", email="user@example.com", @@ -34,10 +35,10 @@ def test_method_create(self, client: Cloudflare) -> None: "3536bcfad5faccb999b47003c79917fb", ], ) - assert_matches_type(UserWithInviteCode, member, path=["response"]) + assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: + def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.create( account_id="string", email="user@example.com", @@ -48,10 +49,10 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ], status="accepted", ) - assert_matches_type(UserWithInviteCode, member, path=["response"]) + assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.create( account_id="string", email="user@example.com", @@ -65,10 +66,10 @@ 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" member = response.parse() - assert_matches_type(UserWithInviteCode, member, path=["response"]) + assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.create( account_id="string", email="user@example.com", @@ -82,12 +83,12 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(UserWithInviteCode, member, path=["response"]) + assert_matches_type(MemberCreateResponse, member, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: + def test_path_params_create_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.accounts.members.with_raw_response.create( account_id="", @@ -99,9 +100,259 @@ def test_path_params_create(self, client: Cloudflare) -> None: ], ) + @parametrize + def test_method_create_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.create( + account_id="string", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(MemberCreateResponse, member, path=["response"]) + + @parametrize + def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.create( + account_id="string", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + status="accepted", + ) + assert_matches_type(MemberCreateResponse, member, path=["response"]) + + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.accounts.members.with_raw_response.create( + account_id="string", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = response.parse() + assert_matches_type(MemberCreateResponse, member, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.accounts.members.with_streaming_response.create( + account_id="string", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = response.parse() + assert_matches_type(MemberCreateResponse, member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.accounts.members.with_raw_response.create( + account_id="", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_update(self, client: Cloudflare) -> None: + def test_method_update_overload_1(self, client: Cloudflare) -> None: + member = client.accounts.members.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="string", + ) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", @@ -111,57 +362,246 @@ def test_method_update(self, client: Cloudflare) -> None: {"id": "3536bcfad5faccb999b47003c79917fb"}, ], ) - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", - roles=[ - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = response.parse() + assert_matches_type(MemberUpdateResponse, member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: + with client.accounts.members.with_streaming_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = response.parse() + assert_matches_type(MemberUpdateResponse, member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): + client.accounts.members.with_raw_response.update( + "", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="string", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="string", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, ], ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", - roles=[ - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, ], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="", - roles=[ - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, ], ) @@ -169,10 +609,43 @@ def test_path_params_update(self, client: Cloudflare) -> None: client.accounts.members.with_raw_response.update( "", account_id="string", - roles=[ - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, ], ) @@ -181,7 +654,7 @@ def test_method_list(self, client: Cloudflare) -> None: member = client.accounts.members.list( account_id="string", ) - assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: @@ -193,7 +666,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: per_page=5, status="accepted", ) - assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -204,7 +677,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -215,7 +688,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -280,7 +753,7 @@ def test_method_get(self, client: Cloudflare) -> None: "4536bcfad5faccb111b47003c79917fa", account_id="string", ) - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberGetResponse, member, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -292,7 +765,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberGetResponse, member, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -304,7 +777,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberGetResponse, member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -327,7 +800,7 @@ class TestAsyncMembers: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( account_id="string", email="user@example.com", @@ -337,10 +810,10 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "3536bcfad5faccb999b47003c79917fb", ], ) - assert_matches_type(UserWithInviteCode, member, path=["response"]) + assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( account_id="string", email="user@example.com", @@ -351,10 +824,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ], status="accepted", ) - assert_matches_type(UserWithInviteCode, member, path=["response"]) + assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.create( account_id="string", email="user@example.com", @@ -368,10 +841,10 @@ 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" member = await response.parse() - assert_matches_type(UserWithInviteCode, member, path=["response"]) + assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.create( account_id="string", email="user@example.com", @@ -385,12 +858,12 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(UserWithInviteCode, member, path=["response"]) + assert_matches_type(MemberCreateResponse, member, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.accounts.members.with_raw_response.create( account_id="", @@ -402,9 +875,259 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: ], ) + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.create( + account_id="string", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(MemberCreateResponse, member, path=["response"]) + + @parametrize + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.create( + account_id="string", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + status="accepted", + ) + assert_matches_type(MemberCreateResponse, member, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.accounts.members.with_raw_response.create( + account_id="string", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = await response.parse() + assert_matches_type(MemberCreateResponse, member, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.accounts.members.with_streaming_response.create( + account_id="string", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = await response.parse() + assert_matches_type(MemberCreateResponse, member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.accounts.members.with_raw_response.create( + account_id="", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="string", + ) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", @@ -414,57 +1137,246 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: {"id": "3536bcfad5faccb999b47003c79917fb"}, ], ) - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", - roles=[ - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = await response.parse() + assert_matches_type(MemberUpdateResponse, member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.accounts.members.with_streaming_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = await response.parse() + assert_matches_type(MemberUpdateResponse, member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): + await async_client.accounts.members.with_raw_response.update( + "", + account_id="string", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="string", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="string", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, ], ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", - roles=[ - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, ], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberUpdateResponse, member, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="", - roles=[ - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, ], ) @@ -472,10 +1384,43 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: await async_client.accounts.members.with_raw_response.update( "", account_id="string", - roles=[ - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, - {"id": "3536bcfad5faccb999b47003c79917fb"}, + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, ], ) @@ -484,7 +1429,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.list( account_id="string", ) - assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -496,7 +1441,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) per_page=5, status="accepted", ) - assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +1452,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -518,7 +1463,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -583,7 +1528,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "4536bcfad5faccb111b47003c79917fa", account_id="string", ) - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberGetResponse, member, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -595,7 +1540,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberGetResponse, member, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -607,7 +1552,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(Member, member, path=["response"]) + assert_matches_type(MemberGetResponse, member, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/accounts/test_roles.py b/tests/api_resources/accounts/test_roles.py index 8da99847106..768327bb0a6 100644 --- a/tests/api_resources/accounts/test_roles.py +++ b/tests/api_resources/accounts/test_roles.py @@ -11,7 +11,6 @@ from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.shared import Role -from cloudflare.types.accounts import RoleGetResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -63,7 +62,7 @@ def test_method_get(self, client: Cloudflare) -> None: {}, account_id="string", ) - assert_matches_type(RoleGetResponse, role, path=["response"]) + assert_matches_type(object, role, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -75,7 +74,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" role = response.parse() - assert_matches_type(RoleGetResponse, role, path=["response"]) + assert_matches_type(object, role, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -87,7 +86,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" role = response.parse() - assert_matches_type(RoleGetResponse, role, path=["response"]) + assert_matches_type(object, role, path=["response"]) assert cast(Any, response.is_closed) is True @@ -147,7 +146,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: {}, account_id="string", ) - assert_matches_type(RoleGetResponse, role, path=["response"]) + assert_matches_type(object, role, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -159,7 +158,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" role = await response.parse() - assert_matches_type(RoleGetResponse, role, path=["response"]) + assert_matches_type(object, role, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -171,7 +170,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" role = await response.parse() - assert_matches_type(RoleGetResponse, role, path=["response"]) + assert_matches_type(object, role, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_accounts.py b/tests/api_resources/test_accounts.py index 19d397230d3..501299704c4 100644 --- a/tests/api_resources/test_accounts.py +++ b/tests/api_resources/test_accounts.py @@ -10,10 +10,6 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.accounts import ( - AccountGetResponse, - AccountUpdateResponse, -) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -27,7 +23,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_id={}, name="Demo Account", ) - assert_matches_type(AccountUpdateResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -40,7 +36,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "use_account_custom_ns_by_default": True, }, ) - assert_matches_type(AccountUpdateResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -52,7 +48,7 @@ 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" account = response.parse() - assert_matches_type(AccountUpdateResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -64,7 +60,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" account = response.parse() - assert_matches_type(AccountUpdateResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) assert cast(Any, response.is_closed) is True @@ -108,7 +104,7 @@ def test_method_get(self, client: Cloudflare) -> None: account = client.accounts.get( account_id={}, ) - assert_matches_type(AccountGetResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -119,7 +115,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" account = response.parse() - assert_matches_type(AccountGetResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -130,7 +126,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" account = response.parse() - assert_matches_type(AccountGetResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) assert cast(Any, response.is_closed) is True @@ -144,7 +140,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_id={}, name="Demo Account", ) - assert_matches_type(AccountUpdateResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -157,7 +153,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "use_account_custom_ns_by_default": True, }, ) - assert_matches_type(AccountUpdateResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -169,7 +165,7 @@ 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" account = await response.parse() - assert_matches_type(AccountUpdateResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -181,7 +177,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" account = await response.parse() - assert_matches_type(AccountUpdateResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) assert cast(Any, response.is_closed) is True @@ -225,7 +221,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: account = await async_client.accounts.get( account_id={}, ) - assert_matches_type(AccountGetResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -236,7 +232,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" account = await response.parse() - assert_matches_type(AccountGetResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -247,6 +243,6 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" account = await response.parse() - assert_matches_type(AccountGetResponse, account, path=["response"]) + assert_matches_type(object, account, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_memberships.py b/tests/api_resources/test_memberships.py index c833239e35c..f476c5a8e2f 100644 --- a/tests/api_resources/test_memberships.py +++ b/tests/api_resources/test_memberships.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -108,7 +108,7 @@ def test_method_delete(self, client: Cloudflare) -> None: membership = client.memberships.delete( "4536bcfad5faccb111b47003c79917fa", ) - assert_matches_type(MembershipDeleteResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipDeleteResponse], membership, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipDeleteResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipDeleteResponse], membership, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -130,7 +130,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipDeleteResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipDeleteResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True @@ -268,7 +268,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: membership = await async_client.memberships.delete( "4536bcfad5faccb111b47003c79917fa", ) - assert_matches_type(MembershipDeleteResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipDeleteResponse], membership, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -279,7 +279,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipDeleteResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipDeleteResponse], membership, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipDeleteResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipDeleteResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_user.py b/tests/api_resources/test_user.py index b8fc2776d01..1ffbb87e386 100644 --- a/tests/api_resources/test_user.py +++ b/tests/api_resources/test_user.py @@ -9,7 +9,6 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.user import UserGetResponse, UserEditResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -20,7 +19,7 @@ class TestUser: @parametrize def test_method_edit(self, client: Cloudflare) -> None: user = client.user.edit() - assert_matches_type(UserEditResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: @@ -31,7 +30,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: telephone="+1 123-123-1234", zipcode="12345", ) - assert_matches_type(UserEditResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: @@ -40,7 +39,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" user = response.parse() - assert_matches_type(UserEditResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: @@ -49,14 +48,14 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" user = response.parse() - assert_matches_type(UserEditResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_get(self, client: Cloudflare) -> None: user = client.user.get() - assert_matches_type(UserGetResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -65,7 +64,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" user = response.parse() - assert_matches_type(UserGetResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -74,7 +73,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" user = response.parse() - assert_matches_type(UserGetResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +84,7 @@ class TestAsyncUser: @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: user = await async_client.user.edit() - assert_matches_type(UserEditResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -96,7 +95,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) telephone="+1 123-123-1234", zipcode="12345", ) - assert_matches_type(UserEditResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -105,7 +104,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" user = await response.parse() - assert_matches_type(UserEditResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -114,14 +113,14 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" user = await response.parse() - assert_matches_type(UserEditResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: user = await async_client.user.get() - assert_matches_type(UserGetResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -130,7 +129,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" user = await response.parse() - assert_matches_type(UserGetResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -139,6 +138,6 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" user = await response.parse() - assert_matches_type(UserGetResponse, user, path=["response"]) + assert_matches_type(object, user, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/user/test_invites.py b/tests/api_resources/user/test_invites.py index 73926fbc056..a428b30e8f9 100644 --- a/tests/api_resources/user/test_invites.py +++ b/tests/api_resources/user/test_invites.py @@ -10,7 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.user import Invite, InviteGetResponse, InviteEditResponse +from cloudflare.types.user import Invite base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -49,7 +49,7 @@ def test_method_edit(self, client: Cloudflare) -> None: "4f5f0c14a2a41d5063dd301b2f829f04", status="accepted", ) - assert_matches_type(InviteEditResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" invite = response.parse() - assert_matches_type(InviteEditResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: @@ -73,7 +73,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" invite = response.parse() - assert_matches_type(InviteEditResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) assert cast(Any, response.is_closed) is True @@ -90,7 +90,7 @@ def test_method_get(self, client: Cloudflare) -> None: invite = client.user.invites.get( "4f5f0c14a2a41d5063dd301b2f829f04", ) - assert_matches_type(InviteGetResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" invite = response.parse() - assert_matches_type(InviteGetResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -112,7 +112,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" invite = response.parse() - assert_matches_type(InviteGetResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) assert cast(Any, response.is_closed) is True @@ -158,7 +158,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: "4f5f0c14a2a41d5063dd301b2f829f04", status="accepted", ) - assert_matches_type(InviteEditResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -170,7 +170,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" invite = await response.parse() - assert_matches_type(InviteEditResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -182,7 +182,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" invite = await response.parse() - assert_matches_type(InviteEditResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) assert cast(Any, response.is_closed) is True @@ -199,7 +199,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: invite = await async_client.user.invites.get( "4f5f0c14a2a41d5063dd301b2f829f04", ) - assert_matches_type(InviteGetResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -210,7 +210,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" invite = await response.parse() - assert_matches_type(InviteGetResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -221,7 +221,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" invite = await response.parse() - assert_matches_type(InviteGetResponse, invite, path=["response"]) + assert_matches_type(object, invite, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/user/test_organizations.py b/tests/api_resources/user/test_organizations.py index 336fa525726..c129ec550be 100644 --- a/tests/api_resources/user/test_organizations.py +++ b/tests/api_resources/user/test_organizations.py @@ -10,11 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.user import ( - Organization, - OrganizationGetResponse, - OrganizationDeleteResponse, -) +from cloudflare.types.user import Organization, OrganizationDeleteResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -103,7 +99,7 @@ def test_method_get(self, client: Cloudflare) -> None: organization = client.user.organizations.get( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(OrganizationGetResponse, organization, path=["response"]) + assert_matches_type(object, organization, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -114,7 +110,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" organization = response.parse() - assert_matches_type(OrganizationGetResponse, organization, path=["response"]) + assert_matches_type(object, organization, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -125,7 +121,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" organization = response.parse() - assert_matches_type(OrganizationGetResponse, organization, path=["response"]) + assert_matches_type(object, organization, path=["response"]) assert cast(Any, response.is_closed) is True @@ -221,7 +217,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: organization = await async_client.user.organizations.get( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(OrganizationGetResponse, organization, path=["response"]) + assert_matches_type(object, organization, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -232,7 +228,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" organization = await response.parse() - assert_matches_type(OrganizationGetResponse, organization, path=["response"]) + assert_matches_type(object, organization, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -243,7 +239,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" organization = await response.parse() - assert_matches_type(OrganizationGetResponse, organization, path=["response"]) + assert_matches_type(object, organization, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/user/test_tokens.py b/tests/api_resources/user/test_tokens.py index 608a7beeb51..c91fbe44f60 100644 --- a/tests/api_resources/user/test_tokens.py +++ b/tests/api_resources/user/test_tokens.py @@ -12,10 +12,8 @@ from cloudflare._utils import parse_datetime from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from cloudflare.types.user import ( - TokenGetResponse, TokenCreateResponse, TokenDeleteResponse, - TokenUpdateResponse, TokenVerifyResponse, ) @@ -57,7 +55,7 @@ def test_method_create(self, client: Cloudflare) -> None: }, ], ) - assert_matches_type(TokenCreateResponse, token, path=["response"]) + assert_matches_type(Optional[TokenCreateResponse], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -99,7 +97,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: expires_on=parse_datetime("2020-01-01T00:00:00Z"), not_before=parse_datetime("2018-07-01T05:20:00Z"), ) - assert_matches_type(TokenCreateResponse, token, path=["response"]) + assert_matches_type(Optional[TokenCreateResponse], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -137,7 +135,7 @@ 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" token = response.parse() - assert_matches_type(TokenCreateResponse, token, path=["response"]) + assert_matches_type(Optional[TokenCreateResponse], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -175,7 +173,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(TokenCreateResponse, token, path=["response"]) + assert_matches_type(Optional[TokenCreateResponse], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -213,7 +211,7 @@ def test_method_update(self, client: Cloudflare) -> None: ], status="active", ) - assert_matches_type(TokenUpdateResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -257,7 +255,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: expires_on=parse_datetime("2020-01-01T00:00:00Z"), not_before=parse_datetime("2018-07-01T05:20:00Z"), ) - assert_matches_type(TokenUpdateResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -297,7 +295,7 @@ 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" token = response.parse() - assert_matches_type(TokenUpdateResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -337,7 +335,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(TokenUpdateResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -411,7 +409,7 @@ def test_method_get(self, client: Cloudflare) -> None: token = client.user.tokens.get( {}, ) - assert_matches_type(TokenGetResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -422,7 +420,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(TokenGetResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -433,14 +431,14 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(TokenGetResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_method_verify(self, client: Cloudflare) -> None: token = client.user.tokens.verify() - assert_matches_type(TokenVerifyResponse, token, path=["response"]) + assert_matches_type(Optional[TokenVerifyResponse], token, path=["response"]) @parametrize def test_raw_response_verify(self, client: Cloudflare) -> None: @@ -449,7 +447,7 @@ def test_raw_response_verify(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(TokenVerifyResponse, token, path=["response"]) + assert_matches_type(Optional[TokenVerifyResponse], token, path=["response"]) @parametrize def test_streaming_response_verify(self, client: Cloudflare) -> None: @@ -458,7 +456,7 @@ def test_streaming_response_verify(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = response.parse() - assert_matches_type(TokenVerifyResponse, token, path=["response"]) + assert_matches_type(Optional[TokenVerifyResponse], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -498,7 +496,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: }, ], ) - assert_matches_type(TokenCreateResponse, token, path=["response"]) + assert_matches_type(Optional[TokenCreateResponse], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -540,7 +538,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare expires_on=parse_datetime("2020-01-01T00:00:00Z"), not_before=parse_datetime("2018-07-01T05:20:00Z"), ) - assert_matches_type(TokenCreateResponse, token, path=["response"]) + assert_matches_type(Optional[TokenCreateResponse], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -578,7 +576,7 @@ 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" token = await response.parse() - assert_matches_type(TokenCreateResponse, token, path=["response"]) + assert_matches_type(Optional[TokenCreateResponse], token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -616,7 +614,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(TokenCreateResponse, token, path=["response"]) + assert_matches_type(Optional[TokenCreateResponse], token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -654,7 +652,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: ], status="active", ) - assert_matches_type(TokenUpdateResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -698,7 +696,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare expires_on=parse_datetime("2020-01-01T00:00:00Z"), not_before=parse_datetime("2018-07-01T05:20:00Z"), ) - assert_matches_type(TokenUpdateResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -738,7 +736,7 @@ 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" token = await response.parse() - assert_matches_type(TokenUpdateResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -778,7 +776,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(TokenUpdateResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) assert cast(Any, response.is_closed) is True @@ -852,7 +850,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: token = await async_client.user.tokens.get( {}, ) - assert_matches_type(TokenGetResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -863,7 +861,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(TokenGetResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -874,14 +872,14 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(TokenGetResponse, token, path=["response"]) + assert_matches_type(object, token, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_method_verify(self, async_client: AsyncCloudflare) -> None: token = await async_client.user.tokens.verify() - assert_matches_type(TokenVerifyResponse, token, path=["response"]) + assert_matches_type(Optional[TokenVerifyResponse], token, path=["response"]) @parametrize async def test_raw_response_verify(self, async_client: AsyncCloudflare) -> None: @@ -890,7 +888,7 @@ async def test_raw_response_verify(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(TokenVerifyResponse, token, path=["response"]) + assert_matches_type(Optional[TokenVerifyResponse], token, path=["response"]) @parametrize async def test_streaming_response_verify(self, async_client: AsyncCloudflare) -> None: @@ -899,6 +897,6 @@ async def test_streaming_response_verify(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" token = await response.parse() - assert_matches_type(TokenVerifyResponse, token, path=["response"]) + assert_matches_type(Optional[TokenVerifyResponse], token, path=["response"]) assert cast(Any, response.is_closed) is True From 3009046a27c7966cb0ce01186c0d8acb7cfe3659 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:53:13 +0000 Subject: [PATCH 369/532] feat(api): OpenAPI spec update via Stainless API (#850) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 43ab45243cb..feabb37aca7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dae61c40e8505c826e518a64122325c0e12c78fe44961c1ff6a1e281b7095be3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-aae6ca53fe907112bf8cdbfa9d98476947ade2b9edc12746b59afbdc64c7df5d.yml From ce39f6aed053e6e2c771022c56f5f087cbf59f42 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:10:46 +0000 Subject: [PATCH 370/532] feat(api): OpenAPI spec update via Stainless API (#851) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index feabb37aca7..1e6f112cc7c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-aae6ca53fe907112bf8cdbfa9d98476947ade2b9edc12746b59afbdc64c7df5d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4992ff415e7c422b2b42f20ca3878860ea8d391b0bfde1b1b72adb858a383c17.yml From f48bf6350d26ea58a9f0122112644ac031c22677 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:43:51 +0000 Subject: [PATCH 371/532] feat(api): OpenAPI spec update via Stainless API (#852) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1e6f112cc7c..f5f614db49b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4992ff415e7c422b2b42f20ca3878860ea8d391b0bfde1b1b72adb858a383c17.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f2571965a066e5ec176e3f8cb83d9cbf8889e42380a250bad505db2d18a4a772.yml From 1c71964ca439e7d9df66e241bcb0fba0e747b1d2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:46:04 +0000 Subject: [PATCH 372/532] feat(api): OpenAPI spec update via Stainless API (#853) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f5f614db49b..1e6f112cc7c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f2571965a066e5ec176e3f8cb83d9cbf8889e42380a250bad505db2d18a4a772.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4992ff415e7c422b2b42f20ca3878860ea8d391b0bfde1b1b72adb858a383c17.yml From 8dca457d3413810a36aac11360f3a8ad1abc97b5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:54:36 +0000 Subject: [PATCH 373/532] feat(api): OpenAPI spec update via Stainless API (#854) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1e6f112cc7c..f5f614db49b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4992ff415e7c422b2b42f20ca3878860ea8d391b0bfde1b1b72adb858a383c17.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f2571965a066e5ec176e3f8cb83d9cbf8889e42380a250bad505db2d18a4a772.yml From 6048cc2ac18e1d180a66ac405e3fd48cf829539a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:56:42 +0000 Subject: [PATCH 374/532] feat(api): OpenAPI spec update via Stainless API (#855) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f5f614db49b..feabb37aca7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f2571965a066e5ec176e3f8cb83d9cbf8889e42380a250bad505db2d18a4a772.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-aae6ca53fe907112bf8cdbfa9d98476947ade2b9edc12746b59afbdc64c7df5d.yml From 0f546f597ae97e5b584c526a967fd26dfe8c5e3b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:58:52 +0000 Subject: [PATCH 375/532] feat(api): OpenAPI spec update via Stainless API (#856) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index feabb37aca7..f5f614db49b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-aae6ca53fe907112bf8cdbfa9d98476947ade2b9edc12746b59afbdc64c7df5d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f2571965a066e5ec176e3f8cb83d9cbf8889e42380a250bad505db2d18a4a772.yml From 96236a2dc34933de8b2c33cb0d2e6c5c49561d08 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:37:57 +0000 Subject: [PATCH 376/532] feat(api): OpenAPI spec update via Stainless API (#857) --- .stats.yml | 2 +- src/cloudflare/resources/warp_connector.py | 15 +++++++++++++++ .../resources/zero_trust/tunnels/tunnels.py | 15 +++++++++++++++ src/cloudflare/types/shared/cloudflare_tunnel.py | 2 +- .../warp_connector_create_response.py | 2 +- .../warp_connector_delete_response.py | 2 +- .../warp_connector_edit_response.py | 2 +- .../warp_connector/warp_connector_get_response.py | 2 +- .../warp_connector/warp_connector_list_params.py | 11 ++++++++++- .../warp_connector_list_response.py | 2 +- .../types/zero_trust/tunnel_edit_response.py | 2 +- .../types/zero_trust/tunnel_list_params.py | 11 ++++++++++- .../types/zero_trust/tunnel_list_response.py | 2 +- tests/api_resources/test_warp_connector.py | 2 ++ tests/api_resources/zero_trust/test_tunnels.py | 2 ++ 15 files changed, 63 insertions(+), 11 deletions(-) diff --git a/.stats.yml b/.stats.yml index f5f614db49b..1635b8c85ae 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f2571965a066e5ec176e3f8cb83d9cbf8889e42380a250bad505db2d18a4a772.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a077023d5a748c646073f33bc20264fc7235f7fe9ce157d1f50f9914a3927e1.yml diff --git a/src/cloudflare/resources/warp_connector.py b/src/cloudflare/resources/warp_connector.py index e614da171ef..b2df61979db 100644 --- a/src/cloudflare/resources/warp_connector.py +++ b/src/cloudflare/resources/warp_connector.py @@ -4,6 +4,7 @@ from typing import Any, Union, cast from datetime import datetime +from typing_extensions import Literal import httpx @@ -105,6 +106,7 @@ def list( name: str | NotGiven = NOT_GIVEN, page: float | NotGiven = NOT_GIVEN, per_page: float | NotGiven = NOT_GIVEN, + status: Literal["inactive", "degraded", "healthy", "down"] | NotGiven = NOT_GIVEN, uuid: str | NotGiven = NOT_GIVEN, was_active_at: Union[str, datetime] | NotGiven = NOT_GIVEN, was_inactive_at: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -133,6 +135,11 @@ def list( per_page: Number of results to display. + status: The status of the tunnel. Valid values are `inactive` (tunnel has never been + run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + state), `healthy` (tunnel is active and able to serve traffic), or `down` + (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + uuid: UUID of the tunnel. extra_headers: Send extra headers @@ -162,6 +169,7 @@ def list( "name": name, "page": page, "per_page": per_page, + "status": status, "uuid": uuid, "was_active_at": was_active_at, "was_inactive_at": was_inactive_at, @@ -456,6 +464,7 @@ def list( name: str | NotGiven = NOT_GIVEN, page: float | NotGiven = NOT_GIVEN, per_page: float | NotGiven = NOT_GIVEN, + status: Literal["inactive", "degraded", "healthy", "down"] | NotGiven = NOT_GIVEN, uuid: str | NotGiven = NOT_GIVEN, was_active_at: Union[str, datetime] | NotGiven = NOT_GIVEN, was_inactive_at: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -484,6 +493,11 @@ def list( per_page: Number of results to display. + status: The status of the tunnel. Valid values are `inactive` (tunnel has never been + run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + state), `healthy` (tunnel is active and able to serve traffic), or `down` + (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + uuid: UUID of the tunnel. extra_headers: Send extra headers @@ -513,6 +527,7 @@ def list( "name": name, "page": page, "per_page": per_page, + "status": status, "uuid": uuid, "was_active_at": was_active_at, "was_inactive_at": was_inactive_at, diff --git a/src/cloudflare/resources/zero_trust/tunnels/tunnels.py b/src/cloudflare/resources/zero_trust/tunnels/tunnels.py index 228c4044763..4133b87dcf2 100644 --- a/src/cloudflare/resources/zero_trust/tunnels/tunnels.py +++ b/src/cloudflare/resources/zero_trust/tunnels/tunnels.py @@ -4,6 +4,7 @@ from typing import Any, Type, Union, cast from datetime import datetime +from typing_extensions import Literal import httpx @@ -169,6 +170,7 @@ def list( name: str | NotGiven = NOT_GIVEN, page: float | NotGiven = NOT_GIVEN, per_page: float | NotGiven = NOT_GIVEN, + status: Literal["inactive", "degraded", "healthy", "down"] | NotGiven = NOT_GIVEN, tun_types: str | NotGiven = NOT_GIVEN, uuid: str | NotGiven = NOT_GIVEN, was_active_at: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -198,6 +200,11 @@ def list( per_page: Number of results to display. + status: The status of the tunnel. Valid values are `inactive` (tunnel has never been + run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + state), `healthy` (tunnel is active and able to serve traffic), or `down` + (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + tun_types: The types of tunnels to filter separated by a comma. uuid: UUID of the tunnel. @@ -229,6 +236,7 @@ def list( "name": name, "page": page, "per_page": per_page, + "status": status, "tun_types": tun_types, "uuid": uuid, "was_active_at": was_active_at, @@ -485,6 +493,7 @@ def list( name: str | NotGiven = NOT_GIVEN, page: float | NotGiven = NOT_GIVEN, per_page: float | NotGiven = NOT_GIVEN, + status: Literal["inactive", "degraded", "healthy", "down"] | NotGiven = NOT_GIVEN, tun_types: str | NotGiven = NOT_GIVEN, uuid: str | NotGiven = NOT_GIVEN, was_active_at: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -514,6 +523,11 @@ def list( per_page: Number of results to display. + status: The status of the tunnel. Valid values are `inactive` (tunnel has never been + run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + state), `healthy` (tunnel is active and able to serve traffic), or `down` + (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + tun_types: The types of tunnels to filter separated by a comma. uuid: UUID of the tunnel. @@ -545,6 +559,7 @@ def list( "name": name, "page": page, "per_page": per_page, + "status": status, "tun_types": tun_types, "uuid": uuid, "was_active_at": was_active_at, diff --git a/src/cloudflare/types/shared/cloudflare_tunnel.py b/src/cloudflare/types/shared/cloudflare_tunnel.py index 63f80cc424a..9fbc6e6c16a 100644 --- a/src/cloudflare/types/shared/cloudflare_tunnel.py +++ b/src/cloudflare/types/shared/cloudflare_tunnel.py @@ -83,7 +83,7 @@ class CloudflareTunnel(BaseModel): If `false`, the tunnel must be configured locally on the origin machine. """ - status: Optional[str] = None + status: Optional[Literal["inactive", "degraded", "healthy", "down"]] = None """The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is diff --git a/src/cloudflare/types/warp_connector/warp_connector_create_response.py b/src/cloudflare/types/warp_connector/warp_connector_create_response.py index f76eda94d7c..20c981ffbba 100644 --- a/src/cloudflare/types/warp_connector/warp_connector_create_response.py +++ b/src/cloudflare/types/warp_connector/warp_connector_create_response.py @@ -78,7 +78,7 @@ class TunnelWARPConnectorTunnel(BaseModel): name: Optional[str] = None """A user-friendly name for a tunnel.""" - status: Optional[str] = None + status: Optional[Literal["inactive", "degraded", "healthy", "down"]] = None """The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is diff --git a/src/cloudflare/types/warp_connector/warp_connector_delete_response.py b/src/cloudflare/types/warp_connector/warp_connector_delete_response.py index 22c9fd73ca3..6cbd9848ac0 100644 --- a/src/cloudflare/types/warp_connector/warp_connector_delete_response.py +++ b/src/cloudflare/types/warp_connector/warp_connector_delete_response.py @@ -78,7 +78,7 @@ class TunnelWARPConnectorTunnel(BaseModel): name: Optional[str] = None """A user-friendly name for a tunnel.""" - status: Optional[str] = None + status: Optional[Literal["inactive", "degraded", "healthy", "down"]] = None """The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is diff --git a/src/cloudflare/types/warp_connector/warp_connector_edit_response.py b/src/cloudflare/types/warp_connector/warp_connector_edit_response.py index 19ac4305497..1efce6cc9ab 100644 --- a/src/cloudflare/types/warp_connector/warp_connector_edit_response.py +++ b/src/cloudflare/types/warp_connector/warp_connector_edit_response.py @@ -78,7 +78,7 @@ class TunnelWARPConnectorTunnel(BaseModel): name: Optional[str] = None """A user-friendly name for a tunnel.""" - status: Optional[str] = None + status: Optional[Literal["inactive", "degraded", "healthy", "down"]] = None """The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is diff --git a/src/cloudflare/types/warp_connector/warp_connector_get_response.py b/src/cloudflare/types/warp_connector/warp_connector_get_response.py index aab7e8cfb2c..af11fb6dfbb 100644 --- a/src/cloudflare/types/warp_connector/warp_connector_get_response.py +++ b/src/cloudflare/types/warp_connector/warp_connector_get_response.py @@ -78,7 +78,7 @@ class TunnelWARPConnectorTunnel(BaseModel): name: Optional[str] = None """A user-friendly name for a tunnel.""" - status: Optional[str] = None + status: Optional[Literal["inactive", "degraded", "healthy", "down"]] = None """The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is diff --git a/src/cloudflare/types/warp_connector/warp_connector_list_params.py b/src/cloudflare/types/warp_connector/warp_connector_list_params.py index e58a6e75cc1..e02da6d9bed 100644 --- a/src/cloudflare/types/warp_connector/warp_connector_list_params.py +++ b/src/cloudflare/types/warp_connector/warp_connector_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypedDict from ..._utils import PropertyInfo @@ -40,6 +40,15 @@ class WARPConnectorListParams(TypedDict, total=False): per_page: float """Number of results to display.""" + status: Literal["inactive", "degraded", "healthy", "down"] + """The status of the tunnel. + + Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is + active and able to serve traffic but in an unhealthy state), `healthy` (tunnel + is active and able to serve traffic), or `down` (tunnel can not serve traffic as + it has no connections to the Cloudflare Edge). + """ + uuid: str """UUID of the tunnel.""" diff --git a/src/cloudflare/types/warp_connector/warp_connector_list_response.py b/src/cloudflare/types/warp_connector/warp_connector_list_response.py index a5b67df48c4..1412e8639ee 100644 --- a/src/cloudflare/types/warp_connector/warp_connector_list_response.py +++ b/src/cloudflare/types/warp_connector/warp_connector_list_response.py @@ -78,7 +78,7 @@ class TunnelWARPConnectorTunnel(BaseModel): name: Optional[str] = None """A user-friendly name for a tunnel.""" - status: Optional[str] = None + status: Optional[Literal["inactive", "degraded", "healthy", "down"]] = None """The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is diff --git a/src/cloudflare/types/zero_trust/tunnel_edit_response.py b/src/cloudflare/types/zero_trust/tunnel_edit_response.py index b1871e21042..6e910203a04 100644 --- a/src/cloudflare/types/zero_trust/tunnel_edit_response.py +++ b/src/cloudflare/types/zero_trust/tunnel_edit_response.py @@ -78,7 +78,7 @@ class TunnelWARPConnectorTunnel(BaseModel): name: Optional[str] = None """A user-friendly name for a tunnel.""" - status: Optional[str] = None + status: Optional[Literal["inactive", "degraded", "healthy", "down"]] = None """The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is diff --git a/src/cloudflare/types/zero_trust/tunnel_list_params.py b/src/cloudflare/types/zero_trust/tunnel_list_params.py index e5f6d43dd32..82934968056 100644 --- a/src/cloudflare/types/zero_trust/tunnel_list_params.py +++ b/src/cloudflare/types/zero_trust/tunnel_list_params.py @@ -4,7 +4,7 @@ from typing import Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypedDict from ..._utils import PropertyInfo @@ -40,6 +40,15 @@ class TunnelListParams(TypedDict, total=False): per_page: float """Number of results to display.""" + status: Literal["inactive", "degraded", "healthy", "down"] + """The status of the tunnel. + + Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is + active and able to serve traffic but in an unhealthy state), `healthy` (tunnel + is active and able to serve traffic), or `down` (tunnel can not serve traffic as + it has no connections to the Cloudflare Edge). + """ + tun_types: str """The types of tunnels to filter separated by a comma.""" diff --git a/src/cloudflare/types/zero_trust/tunnel_list_response.py b/src/cloudflare/types/zero_trust/tunnel_list_response.py index ab94c69f9b7..60b42e47af8 100644 --- a/src/cloudflare/types/zero_trust/tunnel_list_response.py +++ b/src/cloudflare/types/zero_trust/tunnel_list_response.py @@ -78,7 +78,7 @@ class TunnelWARPConnectorTunnel(BaseModel): name: Optional[str] = None """A user-friendly name for a tunnel.""" - status: Optional[str] = None + status: Optional[Literal["inactive", "degraded", "healthy", "down"]] = None """The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is diff --git a/tests/api_resources/test_warp_connector.py b/tests/api_resources/test_warp_connector.py index d94380162cd..7db50a0d321 100644 --- a/tests/api_resources/test_warp_connector.py +++ b/tests/api_resources/test_warp_connector.py @@ -86,6 +86,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: name="blog", page=1, per_page=1, + status="healthy", uuid="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", was_active_at=parse_datetime("2009-11-10T23:00:00Z"), was_inactive_at=parse_datetime("2009-11-10T23:00:00Z"), @@ -389,6 +390,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) name="blog", page=1, per_page=1, + status="healthy", uuid="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", was_active_at=parse_datetime("2009-11-10T23:00:00Z"), was_inactive_at=parse_datetime("2009-11-10T23:00:00Z"), diff --git a/tests/api_resources/zero_trust/test_tunnels.py b/tests/api_resources/zero_trust/test_tunnels.py index ee77b47c681..c00bfff850e 100644 --- a/tests/api_resources/zero_trust/test_tunnels.py +++ b/tests/api_resources/zero_trust/test_tunnels.py @@ -89,6 +89,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: name="blog", page=1, per_page=1, + status="healthy", tun_types="cfd_tunnel,warp_connector", uuid="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", was_active_at=parse_datetime("2009-11-10T23:00:00Z"), @@ -349,6 +350,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) name="blog", page=1, per_page=1, + status="healthy", tun_types="cfd_tunnel,warp_connector", uuid="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", was_active_at=parse_datetime("2009-11-10T23:00:00Z"), From 789689195f9ca252ad900eead2afd79bcb49dae3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:47:11 +0000 Subject: [PATCH 377/532] feat(api): OpenAPI spec update via Stainless API (#858) --- .stats.yml | 2 +- api.md | 2 +- .../zero_trust/access/logs/access_requests.py | 51 ++++++++++++++++++- .../types/zero_trust/access/logs/__init__.py | 1 + .../access/logs/access_request_list_params.py | 28 ++++++++++ .../access/logs/test_access_requests.py | 23 +++++++++ 6 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py diff --git a/.stats.yml b/.stats.yml index 1635b8c85ae..9e4464c0c57 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a077023d5a748c646073f33bc20264fc7235f7fe9ce157d1f50f9914a3927e1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bc197b361ec3d5030fd853cb37172adbed55aa014ca7a5ac89fb498a88a8e5cb.yml diff --git a/api.md b/api.md index c514a7f3a0a..81d0684fe74 100644 --- a/api.md +++ b/api.md @@ -5545,7 +5545,7 @@ from cloudflare.types.zero_trust.access.logs import AccessRequests, AccessReques Methods: -- client.zero_trust.access.logs.access_requests.list(\*, account_id) -> Optional +- client.zero_trust.access.logs.access_requests.list(\*, account_id, \*\*params) -> Optional ### Users diff --git a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py index 9b90990d9cc..64cd98c6c50 100644 --- a/src/cloudflare/resources/zero_trust/access/logs/access_requests.py +++ b/src/cloudflare/resources/zero_trust/access/logs/access_requests.py @@ -2,11 +2,17 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Type, Union, Optional, cast +from datetime import datetime +from typing_extensions import Literal import httpx from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ....._utils import ( + maybe_transform, + async_maybe_transform, +) from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource from ....._response import ( @@ -19,6 +25,7 @@ from ....._base_client import ( make_request_options, ) +from .....types.zero_trust.access.logs import access_request_list_params from .....types.zero_trust.access.logs.access_request_list_response import AccessRequestListResponse __all__ = ["AccessRequestsResource", "AsyncAccessRequestsResource"] @@ -37,6 +44,10 @@ def list( self, *, account_id: str, + direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, @@ -50,6 +61,14 @@ def list( Args: account_id: Identifier + direction: The chronological sorting order for the logs. + + limit: The maximum number of log entries to retrieve. + + since: The earliest event timestamp to query. + + until: The latest event timestamp to query. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -67,6 +86,15 @@ def list( extra_query=extra_query, extra_body=extra_body, timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "limit": limit, + "since": since, + "until": until, + }, + access_request_list_params.AccessRequestListParams, + ), post_parser=ResultWrapper[Optional[AccessRequestListResponse]]._unwrapper, ), cast_to=cast(Type[Optional[AccessRequestListResponse]], ResultWrapper[AccessRequestListResponse]), @@ -86,6 +114,10 @@ async def list( self, *, account_id: str, + direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, + limit: int | NotGiven = NOT_GIVEN, + since: Union[str, datetime] | NotGiven = NOT_GIVEN, + until: Union[str, datetime] | 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, @@ -99,6 +131,14 @@ async def list( Args: account_id: Identifier + direction: The chronological sorting order for the logs. + + limit: The maximum number of log entries to retrieve. + + since: The earliest event timestamp to query. + + until: The latest event timestamp to query. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -116,6 +156,15 @@ async def list( extra_query=extra_query, extra_body=extra_body, timeout=timeout, + query=await async_maybe_transform( + { + "direction": direction, + "limit": limit, + "since": since, + "until": until, + }, + access_request_list_params.AccessRequestListParams, + ), post_parser=ResultWrapper[Optional[AccessRequestListResponse]]._unwrapper, ), cast_to=cast(Type[Optional[AccessRequestListResponse]], ResultWrapper[AccessRequestListResponse]), diff --git a/src/cloudflare/types/zero_trust/access/logs/__init__.py b/src/cloudflare/types/zero_trust/access/logs/__init__.py index 8044ec713b3..6054daa920f 100644 --- a/src/cloudflare/types/zero_trust/access/logs/__init__.py +++ b/src/cloudflare/types/zero_trust/access/logs/__init__.py @@ -3,4 +3,5 @@ from __future__ import annotations from .access_requests import AccessRequests as AccessRequests +from .access_request_list_params import AccessRequestListParams as AccessRequestListParams from .access_request_list_response import AccessRequestListResponse as AccessRequestListResponse diff --git a/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py b/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py new file mode 100644 index 00000000000..13be0a7d46b --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/logs/access_request_list_params.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import datetime +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ....._utils import PropertyInfo + +__all__ = ["AccessRequestListParams"] + + +class AccessRequestListParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + direction: Literal["desc", "asc"] + """The chronological sorting order for the logs.""" + + limit: int + """The maximum number of log entries to retrieve.""" + + since: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """The earliest event timestamp to query.""" + + until: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + """The latest event timestamp to query.""" diff --git a/tests/api_resources/zero_trust/access/logs/test_access_requests.py b/tests/api_resources/zero_trust/access/logs/test_access_requests.py index 88f7703f1a6..3eafad4f1a6 100644 --- a/tests/api_resources/zero_trust/access/logs/test_access_requests.py +++ b/tests/api_resources/zero_trust/access/logs/test_access_requests.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.types.zero_trust.access.logs import AccessRequestListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -24,6 +25,17 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + access_request = client.zero_trust.access.logs.access_requests.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + limit=0, + since=parse_datetime("2020-07-01T05:20:00Z"), + until=parse_datetime("2020-10-01T05:20:00Z"), + ) + assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.access.logs.access_requests.with_raw_response.list( @@ -66,6 +78,17 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + access_request = await async_client.zero_trust.access.logs.access_requests.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + limit=0, + since=parse_datetime("2020-07-01T05:20:00Z"), + until=parse_datetime("2020-10-01T05:20:00Z"), + ) + assert_matches_type(Optional[AccessRequestListResponse], access_request, path=["response"]) + @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.access.logs.access_requests.with_raw_response.list( From 131db3e1b0f52edd381ac67dac65c477b867a503 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 20:02:31 +0000 Subject: [PATCH 378/532] feat(api): OpenAPI spec update via Stainless API (#859) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9e4464c0c57..5cc013e4dcc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bc197b361ec3d5030fd853cb37172adbed55aa014ca7a5ac89fb498a88a8e5cb.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-efdb1c15faba015f2904e7db0946e71b5bd84a6e4b96256aed210e7e0113cf17.yml From baf75e216f9f996d1ee4a004465cbdc36fa2d724 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 20:25:00 +0000 Subject: [PATCH 379/532] feat(api): OpenAPI spec update via Stainless API (#860) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5cc013e4dcc..c32afbab59d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-efdb1c15faba015f2904e7db0946e71b5bd84a6e4b96256aed210e7e0113cf17.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7d5c5ef81ab6fb46d0069fbaee2804fb9260e09c325145e407c67613ba76732f.yml From b6421e4f37ee9f6a3b3f9ad356c4c0a2ebfac0ef Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 20:27:13 +0000 Subject: [PATCH 380/532] feat(api): OpenAPI spec update via Stainless API (#861) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c32afbab59d..5cc013e4dcc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1336 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7d5c5ef81ab6fb46d0069fbaee2804fb9260e09c325145e407c67613ba76732f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-efdb1c15faba015f2904e7db0946e71b5bd84a6e4b96256aed210e7e0113cf17.yml From 8c548f7bb0b4447f013db23642bfaff5357d5244 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 23:21:30 +0000 Subject: [PATCH 381/532] feat(api): update via SDK Studio (#862) --- .stats.yml | 2 +- api.md | 43 +- src/cloudflare/resources/dns/__init__.py | 14 + src/cloudflare/resources/dns/dns.py | 32 + src/cloudflare/resources/dns/settings.py | 311 +++++++ .../resources/zero_trust/access/__init__.py | 14 + .../resources/zero_trust/access/access.py | 32 + .../resources/zero_trust/access/policies.py | 784 ++++++++++++++++++ src/cloudflare/types/dns/__init__.py | 7 + src/cloudflare/types/dns/dns_setting.py | 76 ++ src/cloudflare/types/dns/dns_setting_param.py | 76 ++ src/cloudflare/types/dns/nameserver.py | 12 + src/cloudflare/types/dns/nameserver_param.py | 12 + .../types/dns/setting_edit_params.py | 19 + .../types/dns/setting_edit_response.py | 12 + .../types/dns/setting_get_response.py | 12 + .../types/zero_trust/access/__init__.py | 7 + .../zero_trust/access/policy_create_params.py | 70 ++ .../access/policy_create_response.py | 79 ++ .../access/policy_delete_response.py | 12 + .../zero_trust/access/policy_get_response.py | 79 ++ .../zero_trust/access/policy_list_response.py | 79 ++ .../zero_trust/access/policy_update_params.py | 70 ++ .../access/policy_update_response.py | 79 ++ tests/api_resources/dns/test_settings.py | 256 ++++++ .../zero_trust/access/test_policies.py | 761 +++++++++++++++++ 26 files changed, 2941 insertions(+), 9 deletions(-) create mode 100644 src/cloudflare/resources/dns/settings.py create mode 100644 src/cloudflare/resources/zero_trust/access/policies.py create mode 100644 src/cloudflare/types/dns/dns_setting.py create mode 100644 src/cloudflare/types/dns/dns_setting_param.py create mode 100644 src/cloudflare/types/dns/nameserver.py create mode 100644 src/cloudflare/types/dns/nameserver_param.py create mode 100644 src/cloudflare/types/dns/setting_edit_params.py create mode 100644 src/cloudflare/types/dns/setting_edit_response.py create mode 100644 src/cloudflare/types/dns/setting_get_response.py create mode 100644 src/cloudflare/types/zero_trust/access/policy_create_params.py create mode 100644 src/cloudflare/types/zero_trust/access/policy_create_response.py create mode 100644 src/cloudflare/types/zero_trust/access/policy_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/access/policy_get_response.py create mode 100644 src/cloudflare/types/zero_trust/access/policy_list_response.py create mode 100644 src/cloudflare/types/zero_trust/access/policy_update_params.py create mode 100644 src/cloudflare/types/zero_trust/access/policy_update_response.py create mode 100644 tests/api_resources/dns/test_settings.py create mode 100644 tests/api_resources/zero_trust/access/test_policies.py diff --git a/.stats.yml b/.stats.yml index 5cc013e4dcc..563ec8b4af0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1336 +configured_endpoints: 1343 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-efdb1c15faba015f2904e7db0946e71b5bd84a6e4b96256aed210e7e0113cf17.yml diff --git a/api.md b/api.md index 81d0684fe74..c59b31a84a1 100644 --- a/api.md +++ b/api.md @@ -303,14 +303,6 @@ Methods: - client.zones.activation_check.trigger(\*, zone_id) -> Optional -## DNSSettings - -Types: - -```python -from cloudflare.types.zones import DNSSetting, Nameserver -``` - ## Settings ### ZeroRTT @@ -1650,6 +1642,19 @@ Methods: - client.dns.records.import\_(\*, zone_id, \*\*params) -> Optional - client.dns.records.scan(\*, zone_id, \*\*params) -> Optional +## Settings + +Types: + +```python +from cloudflare.types.dns import DNSSetting, Nameserver, SettingEditResponse, SettingGetResponse +``` + +Methods: + +- client.dns.settings.edit(\*, account_id, zone_id, \*\*params) -> Optional +- client.dns.settings.get(\*, account_id, zone_id) -> Optional + ## Analytics ### Reports @@ -5635,6 +5640,28 @@ Methods: - client.zero_trust.access.tags.delete(tag_name, \*, account_id) -> Optional - client.zero_trust.access.tags.get(tag_name, \*, account_id) -> Optional +### Policies + +Types: + +```python +from cloudflare.types.zero_trust.access import ( + PolicyCreateResponse, + PolicyUpdateResponse, + PolicyListResponse, + PolicyDeleteResponse, + PolicyGetResponse, +) +``` + +Methods: + +- client.zero_trust.access.policies.create(\*, account_id, \*\*params) -> Optional +- client.zero_trust.access.policies.update(policy_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.access.policies.list(\*, account_id) -> SyncSinglePage[PolicyListResponse] +- client.zero_trust.access.policies.delete(policy_id, \*, account_id) -> Optional +- client.zero_trust.access.policies.get(policy_id, \*, account_id) -> Optional + ## DEX Types: diff --git a/src/cloudflare/resources/dns/__init__.py b/src/cloudflare/resources/dns/__init__.py index 6f835256c8d..7e394f00159 100644 --- a/src/cloudflare/resources/dns/__init__.py +++ b/src/cloudflare/resources/dns/__init__.py @@ -24,6 +24,14 @@ FirewallResourceWithStreamingResponse, AsyncFirewallResourceWithStreamingResponse, ) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) from .analytics import ( AnalyticsResource, AsyncAnalyticsResource, @@ -40,6 +48,12 @@ "AsyncRecordsResourceWithRawResponse", "RecordsResourceWithStreamingResponse", "AsyncRecordsResourceWithStreamingResponse", + "SettingsResource", + "AsyncSettingsResource", + "SettingsResourceWithRawResponse", + "AsyncSettingsResourceWithRawResponse", + "SettingsResourceWithStreamingResponse", + "AsyncSettingsResourceWithStreamingResponse", "AnalyticsResource", "AsyncAnalyticsResource", "AnalyticsResourceWithRawResponse", diff --git a/src/cloudflare/resources/dns/dns.py b/src/cloudflare/resources/dns/dns.py index 2f71f123a84..7f758f9e906 100644 --- a/src/cloudflare/resources/dns/dns.py +++ b/src/cloudflare/resources/dns/dns.py @@ -18,6 +18,14 @@ FirewallResourceWithStreamingResponse, AsyncFirewallResourceWithStreamingResponse, ) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) from ..._compat import cached_property from .analytics import ( AnalyticsResource, @@ -39,6 +47,10 @@ class DNSResource(SyncAPIResource): def records(self) -> RecordsResource: return RecordsResource(self._client) + @cached_property + def settings(self) -> SettingsResource: + return SettingsResource(self._client) + @cached_property def analytics(self) -> AnalyticsResource: return AnalyticsResource(self._client) @@ -61,6 +73,10 @@ class AsyncDNSResource(AsyncAPIResource): def records(self) -> AsyncRecordsResource: return AsyncRecordsResource(self._client) + @cached_property + def settings(self) -> AsyncSettingsResource: + return AsyncSettingsResource(self._client) + @cached_property def analytics(self) -> AsyncAnalyticsResource: return AsyncAnalyticsResource(self._client) @@ -86,6 +102,10 @@ def __init__(self, dns: DNSResource) -> None: def records(self) -> RecordsResourceWithRawResponse: return RecordsResourceWithRawResponse(self._dns.records) + @cached_property + def settings(self) -> SettingsResourceWithRawResponse: + return SettingsResourceWithRawResponse(self._dns.settings) + @cached_property def analytics(self) -> AnalyticsResourceWithRawResponse: return AnalyticsResourceWithRawResponse(self._dns.analytics) @@ -103,6 +123,10 @@ def __init__(self, dns: AsyncDNSResource) -> None: def records(self) -> AsyncRecordsResourceWithRawResponse: return AsyncRecordsResourceWithRawResponse(self._dns.records) + @cached_property + def settings(self) -> AsyncSettingsResourceWithRawResponse: + return AsyncSettingsResourceWithRawResponse(self._dns.settings) + @cached_property def analytics(self) -> AsyncAnalyticsResourceWithRawResponse: return AsyncAnalyticsResourceWithRawResponse(self._dns.analytics) @@ -120,6 +144,10 @@ def __init__(self, dns: DNSResource) -> None: def records(self) -> RecordsResourceWithStreamingResponse: return RecordsResourceWithStreamingResponse(self._dns.records) + @cached_property + def settings(self) -> SettingsResourceWithStreamingResponse: + return SettingsResourceWithStreamingResponse(self._dns.settings) + @cached_property def analytics(self) -> AnalyticsResourceWithStreamingResponse: return AnalyticsResourceWithStreamingResponse(self._dns.analytics) @@ -137,6 +165,10 @@ def __init__(self, dns: AsyncDNSResource) -> None: def records(self) -> AsyncRecordsResourceWithStreamingResponse: return AsyncRecordsResourceWithStreamingResponse(self._dns.records) + @cached_property + def settings(self) -> AsyncSettingsResourceWithStreamingResponse: + return AsyncSettingsResourceWithStreamingResponse(self._dns.settings) + @cached_property def analytics(self) -> AsyncAnalyticsResourceWithStreamingResponse: return AsyncAnalyticsResourceWithStreamingResponse(self._dns.analytics) diff --git a/src/cloudflare/resources/dns/settings.py b/src/cloudflare/resources/dns/settings.py new file mode 100644 index 00000000000..635b4b77250 --- /dev/null +++ b/src/cloudflare/resources/dns/settings.py @@ -0,0 +1,311 @@ +# 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 ..._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 ...types.dns import setting_edit_params +from ..._base_client import ( + make_request_options, +) +from ...types.dns.dns_setting_param import DNSSettingParam +from ...types.dns.setting_get_response import SettingGetResponse +from ...types.dns.setting_edit_response import SettingEditResponse + +__all__ = ["SettingsResource", "AsyncSettingsResource"] + + +class SettingsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SettingsResourceWithRawResponse: + return SettingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: + return SettingsResourceWithStreamingResponse(self) + + def edit( + self, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + zone_defaults: DNSSettingParam | 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[SettingEditResponse]: + """ + Update DNS settings for an account or zone + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._patch( + f"/{account_or_zone}/{account_or_zone_id}/dns_settings", + body=maybe_transform({"zone_defaults": zone_defaults}, setting_edit_params.SettingEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingEditResponse]], ResultWrapper[SettingEditResponse]), + ) + + def get( + self, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[SettingGetResponse]: + """ + Show DNS settings for an account or zone + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._get( + f"/{account_or_zone}/{account_or_zone_id}/dns_settings", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingGetResponse]], ResultWrapper[SettingGetResponse]), + ) + + +class AsyncSettingsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSettingsResourceWithRawResponse: + return AsyncSettingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: + return AsyncSettingsResourceWithStreamingResponse(self) + + async def edit( + self, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + zone_defaults: DNSSettingParam | 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[SettingEditResponse]: + """ + Update DNS settings for an account or zone + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._patch( + f"/{account_or_zone}/{account_or_zone_id}/dns_settings", + body=await async_maybe_transform({"zone_defaults": zone_defaults}, setting_edit_params.SettingEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingEditResponse]], ResultWrapper[SettingEditResponse]), + ) + + async def get( + self, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[SettingGetResponse]: + """ + Show DNS settings for an account or zone + + Args: + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + if not zone_id: + raise ValueError("You must provide either account_id or zone_id") + + account_or_zone = "zones" + account_or_zone_id = zone_id + return await self._get( + f"/{account_or_zone}/{account_or_zone_id}/dns_settings", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingGetResponse]], ResultWrapper[SettingGetResponse]), + ) + + +class SettingsResourceWithRawResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + self.edit = to_raw_response_wrapper( + settings.edit, + ) + self.get = to_raw_response_wrapper( + settings.get, + ) + + +class AsyncSettingsResourceWithRawResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + self.edit = async_to_raw_response_wrapper( + settings.edit, + ) + self.get = async_to_raw_response_wrapper( + settings.get, + ) + + +class SettingsResourceWithStreamingResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + self.edit = to_streamed_response_wrapper( + settings.edit, + ) + self.get = to_streamed_response_wrapper( + settings.get, + ) + + +class AsyncSettingsResourceWithStreamingResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + self.edit = async_to_streamed_response_wrapper( + settings.edit, + ) + self.get = async_to_streamed_response_wrapper( + settings.get, + ) diff --git a/src/cloudflare/resources/zero_trust/access/__init__.py b/src/cloudflare/resources/zero_trust/access/__init__.py index b34af407a86..d3fe1996f9d 100644 --- a/src/cloudflare/resources/zero_trust/access/__init__.py +++ b/src/cloudflare/resources/zero_trust/access/__init__.py @@ -48,6 +48,14 @@ GroupsResourceWithStreamingResponse, AsyncGroupsResourceWithStreamingResponse, ) +from .policies import ( + PoliciesResource, + AsyncPoliciesResource, + PoliciesResourceWithRawResponse, + AsyncPoliciesResourceWithRawResponse, + PoliciesResourceWithStreamingResponse, + AsyncPoliciesResourceWithStreamingResponse, +) from .bookmarks import ( BookmarksResource, AsyncBookmarksResource, @@ -150,6 +158,12 @@ "AsyncTagsResourceWithRawResponse", "TagsResourceWithStreamingResponse", "AsyncTagsResourceWithStreamingResponse", + "PoliciesResource", + "AsyncPoliciesResource", + "PoliciesResourceWithRawResponse", + "AsyncPoliciesResourceWithRawResponse", + "PoliciesResourceWithStreamingResponse", + "AsyncPoliciesResourceWithStreamingResponse", "AccessResource", "AsyncAccessResource", "AccessResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/access/access.py b/src/cloudflare/resources/zero_trust/access/access.py index 6707c0f7745..b0be13c5cb8 100644 --- a/src/cloudflare/resources/zero_trust/access/access.py +++ b/src/cloudflare/resources/zero_trust/access/access.py @@ -42,6 +42,14 @@ GroupsResourceWithStreamingResponse, AsyncGroupsResourceWithStreamingResponse, ) +from .policies import ( + PoliciesResource, + AsyncPoliciesResource, + PoliciesResourceWithRawResponse, + AsyncPoliciesResourceWithRawResponse, + PoliciesResourceWithStreamingResponse, + AsyncPoliciesResourceWithStreamingResponse, +) from .bookmarks import ( BookmarksResource, AsyncBookmarksResource, @@ -133,6 +141,10 @@ def custom_pages(self) -> CustomPagesResource: def tags(self) -> TagsResource: return TagsResource(self._client) + @cached_property + def policies(self) -> PoliciesResource: + return PoliciesResource(self._client) + @cached_property def with_raw_response(self) -> AccessResourceWithRawResponse: return AccessResourceWithRawResponse(self) @@ -183,6 +195,10 @@ def custom_pages(self) -> AsyncCustomPagesResource: def tags(self) -> AsyncTagsResource: return AsyncTagsResource(self._client) + @cached_property + def policies(self) -> AsyncPoliciesResource: + return AsyncPoliciesResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAccessResourceWithRawResponse: return AsyncAccessResourceWithRawResponse(self) @@ -236,6 +252,10 @@ def custom_pages(self) -> CustomPagesResourceWithRawResponse: def tags(self) -> TagsResourceWithRawResponse: return TagsResourceWithRawResponse(self._access.tags) + @cached_property + def policies(self) -> PoliciesResourceWithRawResponse: + return PoliciesResourceWithRawResponse(self._access.policies) + class AsyncAccessResourceWithRawResponse: def __init__(self, access: AsyncAccessResource) -> None: @@ -281,6 +301,10 @@ def custom_pages(self) -> AsyncCustomPagesResourceWithRawResponse: def tags(self) -> AsyncTagsResourceWithRawResponse: return AsyncTagsResourceWithRawResponse(self._access.tags) + @cached_property + def policies(self) -> AsyncPoliciesResourceWithRawResponse: + return AsyncPoliciesResourceWithRawResponse(self._access.policies) + class AccessResourceWithStreamingResponse: def __init__(self, access: AccessResource) -> None: @@ -326,6 +350,10 @@ def custom_pages(self) -> CustomPagesResourceWithStreamingResponse: def tags(self) -> TagsResourceWithStreamingResponse: return TagsResourceWithStreamingResponse(self._access.tags) + @cached_property + def policies(self) -> PoliciesResourceWithStreamingResponse: + return PoliciesResourceWithStreamingResponse(self._access.policies) + class AsyncAccessResourceWithStreamingResponse: def __init__(self, access: AsyncAccessResource) -> None: @@ -370,3 +398,7 @@ def custom_pages(self) -> AsyncCustomPagesResourceWithStreamingResponse: @cached_property def tags(self) -> AsyncTagsResourceWithStreamingResponse: return AsyncTagsResourceWithStreamingResponse(self._access.tags) + + @cached_property + def policies(self) -> AsyncPoliciesResourceWithStreamingResponse: + return AsyncPoliciesResourceWithStreamingResponse(self._access.policies) diff --git a/src/cloudflare/resources/zero_trust/access/policies.py b/src/cloudflare/resources/zero_trust/access/policies.py new file mode 100644 index 00000000000..6cddea86c29 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/access/policies.py @@ -0,0 +1,784 @@ +# 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 ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.zero_trust.access import Decision, policy_create_params, policy_update_params +from ....types.zero_trust.access.decision import Decision +from ....types.zero_trust.access_rule_param import AccessRuleParam +from ....types.zero_trust.access.policy_get_response import PolicyGetResponse +from ....types.zero_trust.access.policy_list_response import PolicyListResponse +from ....types.zero_trust.access.policy_create_response import PolicyCreateResponse +from ....types.zero_trust.access.policy_delete_response import PolicyDeleteResponse +from ....types.zero_trust.access.policy_update_response import PolicyUpdateResponse +from ....types.zero_trust.access.applications.approval_group_param import ApprovalGroupParam + +__all__ = ["PoliciesResource", "AsyncPoliciesResource"] + + +class PoliciesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PoliciesResourceWithRawResponse: + return PoliciesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: + return PoliciesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + decision: Decision, + include: Iterable[AccessRuleParam], + name: str, + approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, + approval_required: bool | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + isolation_required: bool | NotGiven = NOT_GIVEN, + purpose_justification_prompt: str | NotGiven = NOT_GIVEN, + purpose_justification_required: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + session_duration: 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[PolicyCreateResponse]: + """ + Creates a new Access reusable policy. + + Args: + account_id: Identifier + + decision: The action Access will take if a user matches this policy. + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access policy. + + approval_groups: Administrators who can approve a temporary authentication request. + + approval_required: Requires the user to request access from an administrator at the start of each + session. + + exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot + meet any of the Exclude rules. + + isolation_required: Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + + purpose_justification_prompt: A custom message that will appear on the purpose justification screen. + + purpose_justification_required: Require users to enter a justification when they log in to the application. + + require: Rules evaluated with an AND logical operator. To match the policy, a user must + meet all of the Require rules. + + session_duration: The amount of time that tokens issued for the application will be valid. Must be + in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + m, h. + + 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}/access/policies", + body=maybe_transform( + { + "decision": decision, + "include": include, + "name": name, + "approval_groups": approval_groups, + "approval_required": approval_required, + "exclude": exclude, + "isolation_required": isolation_required, + "purpose_justification_prompt": purpose_justification_prompt, + "purpose_justification_required": purpose_justification_required, + "require": require, + "session_duration": session_duration, + }, + 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[PolicyCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), + ) + + def update( + self, + policy_id: str, + *, + account_id: str, + decision: Decision, + include: Iterable[AccessRuleParam], + name: str, + approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, + approval_required: bool | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + isolation_required: bool | NotGiven = NOT_GIVEN, + purpose_justification_prompt: str | NotGiven = NOT_GIVEN, + purpose_justification_required: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + session_duration: 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[PolicyUpdateResponse]: + """ + Updates a Access reusable policy. + + Args: + account_id: Identifier + + policy_id: The UUID of the policy + + decision: The action Access will take if a user matches this policy. + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access policy. + + approval_groups: Administrators who can approve a temporary authentication request. + + approval_required: Requires the user to request access from an administrator at the start of each + session. + + exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot + meet any of the Exclude rules. + + isolation_required: Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + + purpose_justification_prompt: A custom message that will appear on the purpose justification screen. + + purpose_justification_required: Require users to enter a justification when they log in to the application. + + require: Rules evaluated with an AND logical operator. To match the policy, a user must + meet all of the Require rules. + + session_duration: The amount of time that tokens issued for the application will be valid. Must be + in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + m, h. + + 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._put( + f"/accounts/{account_id}/access/policies/{policy_id}", + body=maybe_transform( + { + "decision": decision, + "include": include, + "name": name, + "approval_groups": approval_groups, + "approval_required": approval_required, + "exclude": exclude, + "isolation_required": isolation_required, + "purpose_justification_prompt": purpose_justification_prompt, + "purpose_justification_required": purpose_justification_required, + "require": require, + "session_duration": session_duration, + }, + policy_update_params.PolicyUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), + ) + + 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[PolicyListResponse]: + """ + Lists Access reusable policies. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/policies", + page=SyncSinglePage[PolicyListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=PolicyListResponse, + ) + + 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 an Access reusable policy. + + Args: + account_id: Identifier + + policy_id: The UUID of the policy + + 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}/access/policies/{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 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[PolicyGetResponse]: + """ + Fetches a single Access reusable policy. + + Args: + account_id: Identifier + + policy_id: The UUID of the policy + + 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}/access/policies/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), + ) + + +class AsyncPoliciesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPoliciesResourceWithRawResponse: + return AsyncPoliciesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: + return AsyncPoliciesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + decision: Decision, + include: Iterable[AccessRuleParam], + name: str, + approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, + approval_required: bool | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + isolation_required: bool | NotGiven = NOT_GIVEN, + purpose_justification_prompt: str | NotGiven = NOT_GIVEN, + purpose_justification_required: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + session_duration: 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[PolicyCreateResponse]: + """ + Creates a new Access reusable policy. + + Args: + account_id: Identifier + + decision: The action Access will take if a user matches this policy. + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access policy. + + approval_groups: Administrators who can approve a temporary authentication request. + + approval_required: Requires the user to request access from an administrator at the start of each + session. + + exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot + meet any of the Exclude rules. + + isolation_required: Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + + purpose_justification_prompt: A custom message that will appear on the purpose justification screen. + + purpose_justification_required: Require users to enter a justification when they log in to the application. + + require: Rules evaluated with an AND logical operator. To match the policy, a user must + meet all of the Require rules. + + session_duration: The amount of time that tokens issued for the application will be valid. Must be + in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + m, h. + + 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}/access/policies", + body=await async_maybe_transform( + { + "decision": decision, + "include": include, + "name": name, + "approval_groups": approval_groups, + "approval_required": approval_required, + "exclude": exclude, + "isolation_required": isolation_required, + "purpose_justification_prompt": purpose_justification_prompt, + "purpose_justification_required": purpose_justification_required, + "require": require, + "session_duration": session_duration, + }, + 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[PolicyCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), + ) + + async def update( + self, + policy_id: str, + *, + account_id: str, + decision: Decision, + include: Iterable[AccessRuleParam], + name: str, + approval_groups: Iterable[ApprovalGroupParam] | NotGiven = NOT_GIVEN, + approval_required: bool | NotGiven = NOT_GIVEN, + exclude: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + isolation_required: bool | NotGiven = NOT_GIVEN, + purpose_justification_prompt: str | NotGiven = NOT_GIVEN, + purpose_justification_required: bool | NotGiven = NOT_GIVEN, + require: Iterable[AccessRuleParam] | NotGiven = NOT_GIVEN, + session_duration: 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[PolicyUpdateResponse]: + """ + Updates a Access reusable policy. + + Args: + account_id: Identifier + + policy_id: The UUID of the policy + + decision: The action Access will take if a user matches this policy. + + include: Rules evaluated with an OR logical operator. A user needs to meet only one of + the Include rules. + + name: The name of the Access policy. + + approval_groups: Administrators who can approve a temporary authentication request. + + approval_required: Requires the user to request access from an administrator at the start of each + session. + + exclude: Rules evaluated with a NOT logical operator. To match the policy, a user cannot + meet any of the Exclude rules. + + isolation_required: Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + + purpose_justification_prompt: A custom message that will appear on the purpose justification screen. + + purpose_justification_required: Require users to enter a justification when they log in to the application. + + require: Rules evaluated with an AND logical operator. To match the policy, a user must + meet all of the Require rules. + + session_duration: The amount of time that tokens issued for the application will be valid. Must be + in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + m, h. + + 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._put( + f"/accounts/{account_id}/access/policies/{policy_id}", + body=await async_maybe_transform( + { + "decision": decision, + "include": include, + "name": name, + "approval_groups": approval_groups, + "approval_required": approval_required, + "exclude": exclude, + "isolation_required": isolation_required, + "purpose_justification_prompt": purpose_justification_prompt, + "purpose_justification_required": purpose_justification_required, + "require": require, + "session_duration": session_duration, + }, + policy_update_params.PolicyUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), + ) + + 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[PolicyListResponse, AsyncSinglePage[PolicyListResponse]]: + """ + Lists Access reusable policies. + + Args: + account_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/access/policies", + page=AsyncSinglePage[PolicyListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=PolicyListResponse, + ) + + 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 an Access reusable policy. + + Args: + account_id: Identifier + + policy_id: The UUID of the policy + + 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}/access/policies/{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 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[PolicyGetResponse]: + """ + Fetches a single Access reusable policy. + + Args: + account_id: Identifier + + policy_id: The UUID of the policy + + 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}/access/policies/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), + ) + + +class PoliciesResourceWithRawResponse: + def __init__(self, policies: PoliciesResource) -> None: + self._policies = policies + + self.create = to_raw_response_wrapper( + policies.create, + ) + self.update = to_raw_response_wrapper( + policies.update, + ) + self.list = to_raw_response_wrapper( + policies.list, + ) + self.delete = to_raw_response_wrapper( + policies.delete, + ) + self.get = to_raw_response_wrapper( + policies.get, + ) + + +class AsyncPoliciesResourceWithRawResponse: + def __init__(self, policies: AsyncPoliciesResource) -> None: + self._policies = policies + + self.create = async_to_raw_response_wrapper( + policies.create, + ) + self.update = async_to_raw_response_wrapper( + policies.update, + ) + self.list = async_to_raw_response_wrapper( + policies.list, + ) + self.delete = async_to_raw_response_wrapper( + policies.delete, + ) + self.get = async_to_raw_response_wrapper( + policies.get, + ) + + +class PoliciesResourceWithStreamingResponse: + def __init__(self, policies: PoliciesResource) -> None: + self._policies = policies + + self.create = to_streamed_response_wrapper( + policies.create, + ) + self.update = to_streamed_response_wrapper( + policies.update, + ) + self.list = to_streamed_response_wrapper( + policies.list, + ) + self.delete = to_streamed_response_wrapper( + policies.delete, + ) + self.get = to_streamed_response_wrapper( + policies.get, + ) + + +class AsyncPoliciesResourceWithStreamingResponse: + def __init__(self, policies: AsyncPoliciesResource) -> None: + self._policies = policies + + self.create = async_to_streamed_response_wrapper( + policies.create, + ) + self.update = async_to_streamed_response_wrapper( + policies.update, + ) + self.list = async_to_streamed_response_wrapper( + policies.list, + ) + self.delete = async_to_streamed_response_wrapper( + policies.delete, + ) + self.get = async_to_streamed_response_wrapper( + policies.get, + ) diff --git a/src/cloudflare/types/dns/__init__.py b/src/cloudflare/types/dns/__init__.py index 5966582d8bf..3b3aa6dfb0b 100644 --- a/src/cloudflare/types/dns/__init__.py +++ b/src/cloudflare/types/dns/__init__.py @@ -12,12 +12,14 @@ from .ttl_param import TTLParam as TTLParam from .caa_record import CAARecord as CAARecord from .loc_record import LOCRecord as LOCRecord +from .nameserver import Nameserver as Nameserver from .ptr_record import PTRRecord as PTRRecord from .srv_record import SRVRecord as SRVRecord from .txt_record import TXTRecord as TXTRecord from .uri_record import URIRecord as URIRecord from .aaaa_record import AAAARecord as AAAARecord from .cert_record import CERTRecord as CERTRecord +from .dns_setting import DNSSetting as DNSSetting from .record_tags import RecordTags as RecordTags from .svcb_record import SVCBRecord as SVCBRecord from .tlsa_record import TLSARecord as TLSARecord @@ -30,20 +32,25 @@ from .dnskey_record import DNSKEYRecord as DNSKEYRecord from .smimea_record import SMIMEARecord as SMIMEARecord from .record_metadata import RecordMetadata as RecordMetadata +from .nameserver_param import NameserverParam as NameserverParam from .attack_mitigation import AttackMitigation as AttackMitigation +from .dns_setting_param import DNSSettingParam as DNSSettingParam from .firewall_ips_param import FirewallIPsParam as FirewallIPsParam from .record_edit_params import RecordEditParams as RecordEditParams from .record_list_params import RecordListParams as RecordListParams from .record_scan_params import RecordScanParams as RecordScanParams from .upstream_ips_param import UpstreamIPsParam as UpstreamIPsParam from .dns_analytics_query import DNSAnalyticsQuery as DNSAnalyticsQuery +from .setting_edit_params import SettingEditParams as SettingEditParams from .firewall_edit_params import FirewallEditParams as FirewallEditParams from .firewall_list_params import FirewallListParams as FirewallListParams from .record_create_params import RecordCreateParams as RecordCreateParams from .record_import_params import RecordImportParams as RecordImportParams from .record_scan_response import RecordScanResponse as RecordScanResponse from .record_update_params import RecordUpdateParams as RecordUpdateParams +from .setting_get_response import SettingGetResponse as SettingGetResponse from .record_process_timing import RecordProcessTiming as RecordProcessTiming +from .setting_edit_response import SettingEditResponse as SettingEditResponse from .firewall_create_params import FirewallCreateParams as FirewallCreateParams from .record_delete_response import RecordDeleteResponse as RecordDeleteResponse from .record_export_response import RecordExportResponse as RecordExportResponse diff --git a/src/cloudflare/types/dns/dns_setting.py b/src/cloudflare/types/dns/dns_setting.py new file mode 100644 index 00000000000..c96b14afb67 --- /dev/null +++ b/src/cloudflare/types/dns/dns_setting.py @@ -0,0 +1,76 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ..._models import BaseModel +from .nameserver import Nameserver + +__all__ = ["DNSSetting", "SOA"] + + +class SOA(BaseModel): + expire: float + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: float + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: str + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: float + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: float + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: str + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: float + """The time to live (TTL) of the SOA record itself.""" + + +class DNSSetting(BaseModel): + foundation_dns: Optional[bool] = None + """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" + + multi_provider: Optional[bool] = None + """ + Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + """ + + nameservers: Optional[Nameserver] = None + """ + Settings determining the nameservers through which the zone should be available. + """ + + ns_ttl: Optional[float] = None + """The time to live (TTL) of the zone's nameserver (NS) records.""" + + secondary_overrides: Optional[bool] = None + """ + Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + """ + + soa: Optional[SOA] = None + """Components of the zone's SOA record.""" + + zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]] = None + """Whether the zone mode is a regular or CDN/DNS only zone.""" diff --git a/src/cloudflare/types/dns/dns_setting_param.py b/src/cloudflare/types/dns/dns_setting_param.py new file mode 100644 index 00000000000..127be3c6a83 --- /dev/null +++ b/src/cloudflare/types/dns/dns_setting_param.py @@ -0,0 +1,76 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from .nameserver_param import NameserverParam + +__all__ = ["DNSSettingParam", "SOA"] + + +class SOA(TypedDict, total=False): + expire: Required[float] + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: Required[float] + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: Required[str] + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: Required[float] + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: Required[float] + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: Required[str] + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: Required[float] + """The time to live (TTL) of the SOA record itself.""" + + +class DNSSettingParam(TypedDict, total=False): + foundation_dns: bool + """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" + + multi_provider: bool + """ + Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + """ + + nameservers: NameserverParam + """ + Settings determining the nameservers through which the zone should be available. + """ + + ns_ttl: float + """The time to live (TTL) of the zone's nameserver (NS) records.""" + + secondary_overrides: bool + """ + Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + """ + + soa: SOA + """Components of the zone's SOA record.""" + + zone_mode: Literal["standard", "cdn_only", "dns_only"] + """Whether the zone mode is a regular or CDN/DNS only zone.""" diff --git a/src/cloudflare/types/dns/nameserver.py b/src/cloudflare/types/dns/nameserver.py new file mode 100644 index 00000000000..3076da16fbd --- /dev/null +++ b/src/cloudflare/types/dns/nameserver.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["Nameserver"] + + +class Nameserver(BaseModel): + type: Literal["cloudflare.standard"] + """Nameserver type""" diff --git a/src/cloudflare/types/dns/nameserver_param.py b/src/cloudflare/types/dns/nameserver_param.py new file mode 100644 index 00000000000..6d73075a2ae --- /dev/null +++ b/src/cloudflare/types/dns/nameserver_param.py @@ -0,0 +1,12 @@ +# 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__ = ["NameserverParam"] + + +class NameserverParam(TypedDict, total=False): + type: Required[Literal["cloudflare.standard"]] + """Nameserver type""" diff --git a/src/cloudflare/types/dns/setting_edit_params.py b/src/cloudflare/types/dns/setting_edit_params.py new file mode 100644 index 00000000000..1ac1ba3eeae --- /dev/null +++ b/src/cloudflare/types/dns/setting_edit_params.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +from .dns_setting_param import DNSSettingParam + +__all__ = ["SettingEditParams"] + + +class SettingEditParams(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + zone_defaults: DNSSettingParam diff --git a/src/cloudflare/types/dns/setting_edit_response.py b/src/cloudflare/types/dns/setting_edit_response.py new file mode 100644 index 00000000000..87a73a5356f --- /dev/null +++ b/src/cloudflare/types/dns/setting_edit_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel +from .dns_setting import DNSSetting + +__all__ = ["SettingEditResponse"] + + +class SettingEditResponse(BaseModel): + zone_defaults: Optional[DNSSetting] = None diff --git a/src/cloudflare/types/dns/setting_get_response.py b/src/cloudflare/types/dns/setting_get_response.py new file mode 100644 index 00000000000..42c33600842 --- /dev/null +++ b/src/cloudflare/types/dns/setting_get_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel +from .dns_setting import DNSSetting + +__all__ = ["SettingGetResponse"] + + +class SettingGetResponse(BaseModel): + zone_defaults: Optional[DNSSetting] = None diff --git a/src/cloudflare/types/zero_trust/access/__init__.py b/src/cloudflare/types/zero_trust/access/__init__.py index 8b8d5c829cf..16436e0e937 100644 --- a/src/cloudflare/types/zero_trust/access/__init__.py +++ b/src/cloudflare/types/zero_trust/access/__init__.py @@ -28,15 +28,22 @@ from .group_update_params import GroupUpdateParams as GroupUpdateParams from .key_rotate_response import KeyRotateResponse as KeyRotateResponse from .key_update_response import KeyUpdateResponse as KeyUpdateResponse +from .policy_get_response import PolicyGetResponse as PolicyGetResponse from .saml_saas_app_param import SAMLSaaSAppParam as SAMLSaaSAppParam from .self_hosted_domains import SelfHostedDomains as SelfHostedDomains from .tag_delete_response import TagDeleteResponse as TagDeleteResponse from .associated_hostnames import AssociatedHostnames as AssociatedHostnames +from .policy_create_params import PolicyCreateParams as PolicyCreateParams +from .policy_list_response import PolicyListResponse as PolicyListResponse +from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams from .saas_app_name_format import SaaSAppNameFormat as SaaSAppNameFormat from .group_delete_response import GroupDeleteResponse as GroupDeleteResponse from .saas_app_source_param import SaaSAppSourceParam as SaaSAppSourceParam from .bookmark_create_params import BookmarkCreateParams as BookmarkCreateParams from .bookmark_update_params import BookmarkUpdateParams as BookmarkUpdateParams +from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse +from .policy_delete_response import PolicyDeleteResponse as PolicyDeleteResponse +from .policy_update_response import PolicyUpdateResponse as PolicyUpdateResponse from .saas_app_name_id_format import SaaSAppNameIDFormat as SaaSAppNameIDFormat from .application_get_response import ApplicationGetResponse as ApplicationGetResponse from .bookmark_delete_response import BookmarkDeleteResponse as BookmarkDeleteResponse diff --git a/src/cloudflare/types/zero_trust/access/policy_create_params.py b/src/cloudflare/types/zero_trust/access/policy_create_params.py new file mode 100644 index 00000000000..a575b5e16a6 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/policy_create_params.py @@ -0,0 +1,70 @@ +# 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 .decision import Decision +from ..access_rule_param import AccessRuleParam +from .applications.approval_group_param import ApprovalGroupParam + +__all__ = ["PolicyCreateParams"] + + +class PolicyCreateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + decision: Required[Decision] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ diff --git a/src/cloudflare/types/zero_trust/access/policy_create_response.py b/src/cloudflare/types/zero_trust/access/policy_create_response.py new file mode 100644 index 00000000000..767b4f9bc18 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/policy_create_response.py @@ -0,0 +1,79 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .decision import Decision +from ...._models import BaseModel +from ..access_rule import AccessRule +from .applications.approval_group import ApprovalGroup + +__all__ = ["PolicyCreateResponse"] + + +class PolicyCreateResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" + + app_count: Optional[int] = None + """Number of access applications currently using this policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + reusable: Optional[Literal[True]] = None + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/policy_delete_response.py b/src/cloudflare/types/zero_trust/access/policy_delete_response.py new file mode 100644 index 00000000000..638056e64fd --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/policy_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["PolicyDeleteResponse"] + + +class PolicyDeleteResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" diff --git a/src/cloudflare/types/zero_trust/access/policy_get_response.py b/src/cloudflare/types/zero_trust/access/policy_get_response.py new file mode 100644 index 00000000000..b4476baf1d0 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/policy_get_response.py @@ -0,0 +1,79 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .decision import Decision +from ...._models import BaseModel +from ..access_rule import AccessRule +from .applications.approval_group import ApprovalGroup + +__all__ = ["PolicyGetResponse"] + + +class PolicyGetResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" + + app_count: Optional[int] = None + """Number of access applications currently using this policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + reusable: Optional[Literal[True]] = None + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/policy_list_response.py b/src/cloudflare/types/zero_trust/access/policy_list_response.py new file mode 100644 index 00000000000..2a2272663c7 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/policy_list_response.py @@ -0,0 +1,79 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .decision import Decision +from ...._models import BaseModel +from ..access_rule import AccessRule +from .applications.approval_group import ApprovalGroup + +__all__ = ["PolicyListResponse"] + + +class PolicyListResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" + + app_count: Optional[int] = None + """Number of access applications currently using this policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + reusable: Optional[Literal[True]] = None + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/access/policy_update_params.py b/src/cloudflare/types/zero_trust/access/policy_update_params.py new file mode 100644 index 00000000000..7ac64eebe4c --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/policy_update_params.py @@ -0,0 +1,70 @@ +# 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 .decision import Decision +from ..access_rule_param import AccessRuleParam +from .applications.approval_group_param import ApprovalGroupParam + +__all__ = ["PolicyUpdateParams"] + + +class PolicyUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + decision: Required[Decision] + """The action Access will take if a user matches this policy.""" + + include: Required[Iterable[AccessRuleParam]] + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + name: Required[str] + """The name of the Access policy.""" + + approval_groups: Iterable[ApprovalGroupParam] + """Administrators who can approve a temporary authentication request.""" + + approval_required: bool + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + exclude: Iterable[AccessRuleParam] + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + isolation_required: bool + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + purpose_justification_prompt: str + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: bool + """Require users to enter a justification when they log in to the application.""" + + require: Iterable[AccessRuleParam] + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + session_duration: str + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ diff --git a/src/cloudflare/types/zero_trust/access/policy_update_response.py b/src/cloudflare/types/zero_trust/access/policy_update_response.py new file mode 100644 index 00000000000..8582785d404 --- /dev/null +++ b/src/cloudflare/types/zero_trust/access/policy_update_response.py @@ -0,0 +1,79 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .decision import Decision +from ...._models import BaseModel +from ..access_rule import AccessRule +from .applications.approval_group import ApprovalGroup + +__all__ = ["PolicyUpdateResponse"] + + +class PolicyUpdateResponse(BaseModel): + id: Optional[str] = None + """The UUID of the policy""" + + app_count: Optional[int] = None + """Number of access applications currently using this policy.""" + + approval_groups: Optional[List[ApprovalGroup]] = None + """Administrators who can approve a temporary authentication request.""" + + approval_required: Optional[bool] = None + """ + Requires the user to request access from an administrator at the start of each + session. + """ + + created_at: Optional[datetime] = None + + decision: Optional[Decision] = None + """The action Access will take if a user matches this policy.""" + + exclude: Optional[List[AccessRule]] = None + """Rules evaluated with a NOT logical operator. + + To match the policy, a user cannot meet any of the Exclude rules. + """ + + include: Optional[List[AccessRule]] = None + """Rules evaluated with an OR logical operator. + + A user needs to meet only one of the Include rules. + """ + + isolation_required: Optional[bool] = None + """ + Require this application to be served in an isolated browser for users matching + this policy. 'Client Web Isolation' must be on for the account in order to use + this feature. + """ + + name: Optional[str] = None + """The name of the Access policy.""" + + purpose_justification_prompt: Optional[str] = None + """A custom message that will appear on the purpose justification screen.""" + + purpose_justification_required: Optional[bool] = None + """Require users to enter a justification when they log in to the application.""" + + require: Optional[List[AccessRule]] = None + """Rules evaluated with an AND logical operator. + + To match the policy, a user must meet all of the Require rules. + """ + + reusable: Optional[Literal[True]] = None + + session_duration: Optional[str] = None + """The amount of time that tokens issued for the application will be valid. + + Must be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), + ms, s, m, h. + """ + + updated_at: Optional[datetime] = None diff --git a/tests/api_resources/dns/test_settings.py b/tests/api_resources/dns/test_settings.py new file mode 100644 index 00000000000..955b284427b --- /dev/null +++ b/tests/api_resources/dns/test_settings.py @@ -0,0 +1,256 @@ +# 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.dns import SettingGetResponse, SettingEditResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSettings: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + setting = client.dns.settings.edit( + account_id="string", + ) + assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + setting = client.dns.settings.edit( + account_id="string", + zone_defaults={ + "foundation_dns": False, + "multi_provider": False, + "nameservers": {"type": "cloudflare.standard"}, + "ns_ttl": 86400, + "secondary_overrides": False, + "soa": { + "expire": 604800, + "min_ttl": 1800, + "mname": "kristina.ns.cloudflare.com", + "refresh": 10000, + "retry": 2400, + "rname": "admin.example.com", + "ttl": 3600, + }, + "zone_mode": "dns_only", + }, + ) + assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.dns.settings.with_raw_response.edit( + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = response.parse() + assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.dns.settings.with_streaming_response.edit( + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = response.parse() + assert_matches_type(Optional[SettingEditResponse], setting, 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.dns.settings.with_raw_response.edit( + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.dns.settings.with_raw_response.edit( + account_id="string", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + setting = client.dns.settings.get( + account_id="string", + ) + assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + setting = client.dns.settings.get( + account_id="string", + ) + assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.dns.settings.with_raw_response.get( + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = response.parse() + assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.dns.settings.with_streaming_response.get( + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = response.parse() + assert_matches_type(Optional[SettingGetResponse], setting, 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.dns.settings.with_raw_response.get( + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.dns.settings.with_raw_response.get( + account_id="string", + ) + + +class TestAsyncSettings: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.dns.settings.edit( + account_id="string", + ) + assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.dns.settings.edit( + account_id="string", + zone_defaults={ + "foundation_dns": False, + "multi_provider": False, + "nameservers": {"type": "cloudflare.standard"}, + "ns_ttl": 86400, + "secondary_overrides": False, + "soa": { + "expire": 604800, + "min_ttl": 1800, + "mname": "kristina.ns.cloudflare.com", + "refresh": 10000, + "retry": 2400, + "rname": "admin.example.com", + "ttl": 3600, + }, + "zone_mode": "dns_only", + }, + ) + assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.settings.with_raw_response.edit( + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = await response.parse() + assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.settings.with_streaming_response.edit( + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = await response.parse() + assert_matches_type(Optional[SettingEditResponse], setting, 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.dns.settings.with_raw_response.edit( + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.dns.settings.with_raw_response.edit( + account_id="string", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.dns.settings.get( + account_id="string", + ) + assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + setting = await async_client.dns.settings.get( + account_id="string", + ) + assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.settings.with_raw_response.get( + account_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + setting = await response.parse() + assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.settings.with_streaming_response.get( + account_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + setting = await response.parse() + assert_matches_type(Optional[SettingGetResponse], setting, 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.dns.settings.with_raw_response.get( + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.dns.settings.with_raw_response.get( + account_id="string", + ) diff --git a/tests/api_resources/zero_trust/access/test_policies.py b/tests/api_resources/zero_trust/access/test_policies.py new file mode 100644 index 00000000000..dd11538c159 --- /dev/null +++ b/tests/api_resources/zero_trust/access/test_policies.py @@ -0,0 +1,761 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.access import ( + PolicyGetResponse, + PolicyListResponse, + PolicyCreateResponse, + PolicyDeleteResponse, + PolicyUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestPolicies: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.policies.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.policies.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + approval_groups=[ + { + "approvals_needed": 1, + "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "string", + }, + { + "approvals_needed": 3, + "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", + }, + ], + approval_required=True, + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + isolation_required=False, + purpose_justification_prompt="Please enter a justification for entering this protected domain.", + purpose_justification_required=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + session_duration="24h", + ) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.access.policies.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.access.policies.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.access.policies.with_raw_response.create( + account_id="", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.policies.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.policies.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + approval_groups=[ + { + "approvals_needed": 1, + "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "string", + }, + { + "approvals_needed": 3, + "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", + }, + ], + approval_required=True, + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + isolation_required=False, + purpose_justification_prompt="Please enter a justification for entering this protected domain.", + purpose_justification_required=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + session_duration="24h", + ) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.access.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.access.policies.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(Optional[PolicyUpdateResponse], policy, 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.access.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + client.zero_trust.access.policies.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.policies.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.access.policies.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.access.policies.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, 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.access.policies.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.policies.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.access.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + 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"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.access.policies.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) 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"]) + + 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.access.policies.with_raw_response.delete( + "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.access.policies.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + policy = client.zero_trust.access.policies.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.access.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = response.parse() + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.access.policies.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + policy = response.parse() + assert_matches_type(Optional[PolicyGetResponse], 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.access.policies.with_raw_response.get( + "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.access.policies.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncPolicies: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.policies.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.policies.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + approval_groups=[ + { + "approvals_needed": 1, + "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "string", + }, + { + "approvals_needed": 3, + "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", + }, + ], + approval_required=True, + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + isolation_required=False, + purpose_justification_prompt="Please enter a justification for entering this protected domain.", + purpose_justification_required=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + session_duration="24h", + ) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.policies.with_raw_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.policies.with_streaming_response.create( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) 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[PolicyCreateResponse], policy, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.access.policies.with_raw_response.create( + account_id="", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.policies.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.policies.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + approval_groups=[ + { + "approvals_needed": 1, + "email_addresses": ["test1@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "string", + }, + { + "approvals_needed": 3, + "email_addresses": ["test@cloudflare.com", "test2@cloudflare.com"], + "email_list_uuid": "597147a1-976b-4ef2-9af0-81d5d007fc34", + }, + ], + approval_required=True, + exclude=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + isolation_required=False, + purpose_justification_prompt="Please enter a justification for entering this protected domain.", + purpose_justification_required=True, + require=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + session_duration="24h", + ) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.policies.with_streaming_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) 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[PolicyUpdateResponse], policy, 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.access.policies.with_raw_response.update( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + await async_client.zero_trust.access.policies.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + decision="allow", + include=[ + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + {"email": {"email": "test@example.com"}}, + ], + name="Allow devs", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.policies.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.policies.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.policies.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) 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[PolicyListResponse], policy, 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.access.policies.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.policies.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.policies.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + 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"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.policies.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) 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"]) + + 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.access.policies.with_raw_response.delete( + "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.access.policies.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + policy = await async_client.zero_trust.access.policies.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.access.policies.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + policy = await response.parse() + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.access.policies.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) 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[PolicyGetResponse], 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.access.policies.with_raw_response.get( + "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.access.policies.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) From 992e3d68e7e40ae34819190a7deb9ef9b63d97ac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:00:47 +0000 Subject: [PATCH 382/532] feat(api): update via SDK Studio (#863) --- api.md | 2 +- .../access/applications/applications.py | 72 ++-- .../zero_trust/identity_providers.py | 122 +++---- src/cloudflare/types/zero_trust/__init__.py | 4 +- .../access/application_create_params.py | 336 +++++++++--------- .../access/application_create_response.py | 336 +++++++++--------- .../access/application_get_response.py | 336 +++++++++--------- .../access/application_list_response.py | 336 +++++++++--------- .../access/application_update_params.py | 336 +++++++++--------- .../access/application_update_response.py | 336 +++++++++--------- src/cloudflare/types/zero_trust/azure_ad.py | 4 +- .../types/zero_trust/identity_provider.py | 28 +- .../identity_provider_create_params.py | 30 +- .../identity_provider_list_response.py | 26 +- .../identity_provider_update_params.py | 30 +- .../types/zero_trust/scim_config.py | 4 +- .../types/zero_trust/scim_config_param.py | 4 +- 17 files changed, 1171 insertions(+), 1171 deletions(-) diff --git a/api.md b/api.md index c59b31a84a1..5295390d972 100644 --- a/api.md +++ b/api.md @@ -5266,7 +5266,7 @@ from cloudflare.types.zero_trust import ( GenericOAuthConfig, IdentityProvider, IdentityProviderType, - ScimConfig, + SCIMConfig, IdentityProviderListResponse, IdentityProviderDeleteResponse, ) diff --git a/src/cloudflare/resources/zero_trust/access/applications/applications.py b/src/cloudflare/resources/zero_trust/access/applications/applications.py index cb837d07265..10d54f8e800 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/applications.py +++ b/src/cloudflare/resources/zero_trust/access/applications/applications.py @@ -114,7 +114,7 @@ def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SelfHostedApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -227,7 +227,7 @@ def create( name: str | NotGiven = NOT_GIVEN, policies: List[application_create_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_create_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, - scim_config: application_create_params.SaaSApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SaaSApplicationSCIMConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -306,7 +306,7 @@ def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.BrowserSSHApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserSSHApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -430,7 +430,7 @@ def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.BrowserVncApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserVncApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -539,7 +539,7 @@ def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_create_params.AppLauncherApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.AppLauncherApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -595,7 +595,7 @@ def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_create_params.DeviceEnrollmentPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.DeviceEnrollmentPermissionsApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -651,7 +651,7 @@ def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_create_params.BrowserIsolationPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserIsolationPermissionsApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -707,7 +707,7 @@ def create( domain: str | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.BookmarkApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BookmarkApplicationSCIMConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -775,7 +775,7 @@ def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SelfHostedApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -875,7 +875,7 @@ def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SelfHostedApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -991,7 +991,7 @@ def update( name: str | NotGiven = NOT_GIVEN, policies: List[application_update_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_update_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, - scim_config: application_update_params.SaaSApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SaaSApplicationSCIMConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1073,7 +1073,7 @@ def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.BrowserSSHApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserSSHApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -1200,7 +1200,7 @@ def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.BrowserVncApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserVncApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -1312,7 +1312,7 @@ def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_update_params.AppLauncherApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.AppLauncherApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1371,7 +1371,7 @@ def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_update_params.DeviceEnrollmentPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.DeviceEnrollmentPermissionsApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1430,7 +1430,7 @@ def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_update_params.BrowserIsolationPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserIsolationPermissionsApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -1489,7 +1489,7 @@ def update( domain: str | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.BookmarkApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BookmarkApplicationSCIMConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -1560,7 +1560,7 @@ def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SelfHostedApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -1900,7 +1900,7 @@ async def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SelfHostedApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2013,7 +2013,7 @@ async def create( name: str | NotGiven = NOT_GIVEN, policies: List[application_create_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_create_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, - scim_config: application_create_params.SaaSApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SaaSApplicationSCIMConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -2092,7 +2092,7 @@ async def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.BrowserSSHApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserSSHApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2216,7 +2216,7 @@ async def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.BrowserVncApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserVncApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2325,7 +2325,7 @@ async def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_create_params.AppLauncherApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.AppLauncherApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2381,7 +2381,7 @@ async def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_create_params.DeviceEnrollmentPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.DeviceEnrollmentPermissionsApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2437,7 +2437,7 @@ async def create( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_create_params.BrowserIsolationPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BrowserIsolationPermissionsApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -2493,7 +2493,7 @@ async def create( domain: str | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.BookmarkApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.BookmarkApplicationSCIMConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -2561,7 +2561,7 @@ async def create( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_create_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_create_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_create_params.SelfHostedApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2661,7 +2661,7 @@ async def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SelfHostedApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2777,7 +2777,7 @@ async def update( name: str | NotGiven = NOT_GIVEN, policies: List[application_update_params.SaaSApplicationPolicy] | NotGiven = NOT_GIVEN, saas_app: application_update_params.SaaSApplicationSaaSApp | NotGiven = NOT_GIVEN, - scim_config: application_update_params.SaaSApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SaaSApplicationSCIMConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -2859,7 +2859,7 @@ async def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserSSHApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.BrowserSSHApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserSSHApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -2986,7 +2986,7 @@ async def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserVncApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.BrowserVncApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserVncApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, @@ -3098,7 +3098,7 @@ async def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.AppLauncherApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_update_params.AppLauncherApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.AppLauncherApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -3157,7 +3157,7 @@ async def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.DeviceEnrollmentPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_update_params.DeviceEnrollmentPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.DeviceEnrollmentPermissionsApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -3216,7 +3216,7 @@ async def update( allowed_idps: List[AllowedIdPs] | NotGiven = NOT_GIVEN, auto_redirect_to_identity: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.BrowserIsolationPermissionsApplicationPolicy] | NotGiven = NOT_GIVEN, - scim_config: application_update_params.BrowserIsolationPermissionsApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BrowserIsolationPermissionsApplicationSCIMConfig | NotGiven = NOT_GIVEN, session_duration: 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. @@ -3275,7 +3275,7 @@ async def update( domain: str | NotGiven = NOT_GIVEN, logo_url: str | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.BookmarkApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.BookmarkApplicationSCIMConfig | NotGiven = NOT_GIVEN, tags: List[str] | NotGiven = NOT_GIVEN, type: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -3346,7 +3346,7 @@ async def update( path_cookie_attribute: bool | NotGiven = NOT_GIVEN, policies: List[application_update_params.SelfHostedApplicationPolicy] | NotGiven = NOT_GIVEN, same_site_cookie_attribute: str | NotGiven = NOT_GIVEN, - scim_config: application_update_params.SelfHostedApplicationScimConfig | NotGiven = NOT_GIVEN, + scim_config: application_update_params.SelfHostedApplicationSCIMConfig | NotGiven = NOT_GIVEN, self_hosted_domains: List[SelfHostedDomains] | NotGiven = NOT_GIVEN, service_auth_401_redirect: bool | NotGiven = NOT_GIVEN, session_duration: str | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/resources/zero_trust/identity_providers.py b/src/cloudflare/resources/zero_trust/identity_providers.py index d90f719e232..f3d72e3068d 100644 --- a/src/cloudflare/resources/zero_trust/identity_providers.py +++ b/src/cloudflare/resources/zero_trust/identity_providers.py @@ -32,7 +32,7 @@ identity_provider_update_params, ) from ...types.zero_trust.identity_provider import IdentityProvider -from ...types.zero_trust.scim_config_param import ScimConfigParam +from ...types.zero_trust.scim_config_param import SCIMConfigParam from ...types.zero_trust.identity_provider_type import IdentityProviderType from ...types.zero_trust.generic_oauth_config_param import GenericOAuthConfigParam from ...types.zero_trust.identity_provider_list_response import IdentityProviderListResponse @@ -59,7 +59,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -107,7 +107,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -155,7 +155,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -203,7 +203,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -251,7 +251,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -299,7 +299,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -347,7 +347,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -395,7 +395,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -443,7 +443,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -491,7 +491,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -539,7 +539,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -587,7 +587,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -635,7 +635,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -683,7 +683,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -741,7 +741,7 @@ def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -797,7 +797,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -848,7 +848,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -899,7 +899,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -950,7 +950,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1001,7 +1001,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1052,7 +1052,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1103,7 +1103,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1154,7 +1154,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1205,7 +1205,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1256,7 +1256,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1307,7 +1307,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1358,7 +1358,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1409,7 +1409,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1460,7 +1460,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1521,7 +1521,7 @@ def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1764,7 +1764,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1812,7 +1812,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1860,7 +1860,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1908,7 +1908,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -1956,7 +1956,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2004,7 +2004,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2052,7 +2052,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2100,7 +2100,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2148,7 +2148,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2196,7 +2196,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2244,7 +2244,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2292,7 +2292,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2340,7 +2340,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2388,7 +2388,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2446,7 +2446,7 @@ async def create( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2502,7 +2502,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2553,7 +2553,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2604,7 +2604,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2655,7 +2655,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2706,7 +2706,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2757,7 +2757,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2808,7 +2808,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2859,7 +2859,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2910,7 +2910,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -2961,7 +2961,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -3012,7 +3012,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -3063,7 +3063,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -3114,7 +3114,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -3165,7 +3165,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | 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, @@ -3226,7 +3226,7 @@ async def update( type: IdentityProviderType, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, - scim_config: ScimConfigParam | NotGiven = NOT_GIVEN, + scim_config: SCIMConfigParam | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/cloudflare/types/zero_trust/__init__.py b/src/cloudflare/types/zero_trust/__init__.py index fe2de93ed13..8981ad5974d 100644 --- a/src/cloudflare/types/zero_trust/__init__.py +++ b/src/cloudflare/types/zero_trust/__init__.py @@ -12,7 +12,7 @@ from .access_rule import AccessRule as AccessRule from .domain_rule import DomainRule as DomainRule from .percentiles import Percentiles as Percentiles -from .scim_config import ScimConfig as ScimConfig +from .scim_config import SCIMConfig as SCIMConfig from .country_rule import CountryRule as CountryRule from .ip_list_rule import IPListRule as IPListRule from .login_design import LoginDesign as LoginDesign @@ -32,7 +32,7 @@ from .domain_rule_param import DomainRuleParam as DomainRuleParam from .gsuite_group_rule import GSuiteGroupRule as GSuiteGroupRule from .identity_provider import IdentityProvider as IdentityProvider -from .scim_config_param import ScimConfigParam as ScimConfigParam +from .scim_config_param import SCIMConfigParam as SCIMConfigParam from .country_rule_param import CountryRuleParam as CountryRuleParam from .ip_list_rule_param import IPListRuleParam as IPListRuleParam from .login_design_param import LoginDesignParam as LoginDesignParam diff --git a/src/cloudflare/types/zero_trust/access/application_create_params.py b/src/cloudflare/types/zero_trust/access/application_create_params.py index 8db6908028c..6456faaed7c 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_params.py +++ b/src/cloudflare/types/zero_trust/access/application_create_params.py @@ -20,13 +20,13 @@ "SelfHostedApplicationPolicy", "SelfHostedApplicationPolicyAccessAppPolicyLink", "SelfHostedApplicationPolicyUnionMember2", - "SelfHostedApplicationScimConfig", - "SelfHostedApplicationScimConfigAuthentication", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SelfHostedApplicationScimConfigMapping", - "SelfHostedApplicationScimConfigMappingOperations", + "SelfHostedApplicationSCIMConfig", + "SelfHostedApplicationSCIMConfigAuthentication", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SelfHostedApplicationSCIMConfigMapping", + "SelfHostedApplicationSCIMConfigMappingOperations", "SaaSApplication", "SaaSApplicationPolicy", "SaaSApplicationPolicyAccessAppPolicyLink", @@ -37,76 +37,76 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", - "SaaSApplicationScimConfig", - "SaaSApplicationScimConfigAuthentication", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SaaSApplicationScimConfigMapping", - "SaaSApplicationScimConfigMappingOperations", + "SaaSApplicationSCIMConfig", + "SaaSApplicationSCIMConfigAuthentication", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SaaSApplicationSCIMConfigMapping", + "SaaSApplicationSCIMConfigMappingOperations", "BrowserSSHApplication", "BrowserSSHApplicationPolicy", "BrowserSSHApplicationPolicyAccessAppPolicyLink", "BrowserSSHApplicationPolicyUnionMember2", - "BrowserSSHApplicationScimConfig", - "BrowserSSHApplicationScimConfigAuthentication", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserSSHApplicationScimConfigMapping", - "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserSSHApplicationSCIMConfig", + "BrowserSSHApplicationSCIMConfigAuthentication", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserSSHApplicationSCIMConfigMapping", + "BrowserSSHApplicationSCIMConfigMappingOperations", "BrowserVncApplication", "BrowserVncApplicationPolicy", "BrowserVncApplicationPolicyAccessAppPolicyLink", "BrowserVncApplicationPolicyUnionMember2", - "BrowserVncApplicationScimConfig", - "BrowserVncApplicationScimConfigAuthentication", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserVncApplicationScimConfigMapping", - "BrowserVncApplicationScimConfigMappingOperations", + "BrowserVncApplicationSCIMConfig", + "BrowserVncApplicationSCIMConfigAuthentication", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserVncApplicationSCIMConfigMapping", + "BrowserVncApplicationSCIMConfigMappingOperations", "AppLauncherApplication", "AppLauncherApplicationPolicy", "AppLauncherApplicationPolicyAccessAppPolicyLink", "AppLauncherApplicationPolicyUnionMember2", - "AppLauncherApplicationScimConfig", - "AppLauncherApplicationScimConfigAuthentication", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "AppLauncherApplicationScimConfigMapping", - "AppLauncherApplicationScimConfigMappingOperations", + "AppLauncherApplicationSCIMConfig", + "AppLauncherApplicationSCIMConfigAuthentication", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "AppLauncherApplicationSCIMConfigMapping", + "AppLauncherApplicationSCIMConfigMappingOperations", "DeviceEnrollmentPermissionsApplication", "DeviceEnrollmentPermissionsApplicationPolicy", "DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink", "DeviceEnrollmentPermissionsApplicationPolicyUnionMember2", - "DeviceEnrollmentPermissionsApplicationScimConfig", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "DeviceEnrollmentPermissionsApplicationScimConfigMapping", - "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplicationSCIMConfig", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMapping", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations", "BrowserIsolationPermissionsApplication", "BrowserIsolationPermissionsApplicationPolicy", "BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink", "BrowserIsolationPermissionsApplicationPolicyUnionMember2", - "BrowserIsolationPermissionsApplicationScimConfig", - "BrowserIsolationPermissionsApplicationScimConfigAuthentication", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserIsolationPermissionsApplicationScimConfigMapping", - "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplicationSCIMConfig", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthentication", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationSCIMConfigMapping", + "BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations", "BookmarkApplication", - "BookmarkApplicationScimConfig", - "BookmarkApplicationScimConfigAuthentication", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BookmarkApplicationScimConfigMapping", - "BookmarkApplicationScimConfigMappingOperations", + "BookmarkApplicationSCIMConfig", + "BookmarkApplicationSCIMConfigAuthentication", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BookmarkApplicationSCIMConfigMapping", + "BookmarkApplicationSCIMConfigMappingOperations", ] @@ -218,7 +218,7 @@ class SelfHostedApplication(TypedDict, total=False): attacks. """ - scim_config: SelfHostedApplicationScimConfig + scim_config: SelfHostedApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -327,7 +327,7 @@ class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): ] -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -338,7 +338,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -348,7 +348,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -380,14 +380,14 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -SelfHostedApplicationScimConfigAuthentication = Union[ - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SelfHostedApplicationSCIMConfigAuthentication = Union[ + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SelfHostedApplicationScimConfigMappingOperations(TypedDict, total=False): +class SelfHostedApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -398,7 +398,7 @@ class SelfHostedApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SelfHostedApplicationScimConfigMapping(TypedDict, total=False): +class SelfHostedApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -412,7 +412,7 @@ class SelfHostedApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: SelfHostedApplicationScimConfigMappingOperations + operations: SelfHostedApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -422,7 +422,7 @@ class SelfHostedApplicationScimConfigMapping(TypedDict, total=False): """ -class SelfHostedApplicationScimConfig(TypedDict, total=False): +class SelfHostedApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -432,7 +432,7 @@ class SelfHostedApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: SelfHostedApplicationScimConfigAuthentication + authentication: SelfHostedApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -448,7 +448,7 @@ class SelfHostedApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[SelfHostedApplicationScimConfigMapping] + mappings: Iterable[SelfHostedApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -497,7 +497,7 @@ class SaaSApplication(TypedDict, total=False): saas_app: SaaSApplicationSaaSApp - scim_config: SaaSApplicationScimConfig + scim_config: SaaSApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -683,7 +683,7 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): SaaSApplicationSaaSApp = Union[SAMLSaaSAppParam, SaaSApplicationSaaSAppAccessOIDCSaaSApp] -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -694,7 +694,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPB """User name used to authenticate with the remote SCIM service.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(TypedDict, total=False): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(TypedDict, total=False): token: Required[str] """Token used to authenticate with the remote SCIM service.""" @@ -702,7 +702,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuth """The authentication scheme to use when making SCIM requests to this application.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -734,14 +734,14 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth """ -SaaSApplicationScimConfigAuthentication = Union[ - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SaaSApplicationSCIMConfigAuthentication = Union[ + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SaaSApplicationScimConfigMappingOperations(TypedDict, total=False): +class SaaSApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -752,7 +752,7 @@ class SaaSApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SaaSApplicationScimConfigMapping(TypedDict, total=False): +class SaaSApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -766,7 +766,7 @@ class SaaSApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: SaaSApplicationScimConfigMappingOperations + operations: SaaSApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -776,7 +776,7 @@ class SaaSApplicationScimConfigMapping(TypedDict, total=False): """ -class SaaSApplicationScimConfig(TypedDict, total=False): +class SaaSApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -786,7 +786,7 @@ class SaaSApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: SaaSApplicationScimConfigAuthentication + authentication: SaaSApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -802,7 +802,7 @@ class SaaSApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[SaaSApplicationScimConfigMapping] + mappings: Iterable[SaaSApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -917,7 +917,7 @@ class BrowserSSHApplication(TypedDict, total=False): attacks. """ - scim_config: BrowserSSHApplicationScimConfig + scim_config: BrowserSSHApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1026,7 +1026,7 @@ class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): ] -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -1037,7 +1037,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -1047,7 +1047,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -1079,14 +1079,14 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserSSHApplicationScimConfigAuthentication = Union[ - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserSSHApplicationSCIMConfigAuthentication = Union[ + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserSSHApplicationScimConfigMappingOperations(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -1097,7 +1097,7 @@ class BrowserSSHApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserSSHApplicationScimConfigMapping(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -1111,7 +1111,7 @@ class BrowserSSHApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: BrowserSSHApplicationScimConfigMappingOperations + operations: BrowserSSHApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -1121,7 +1121,7 @@ class BrowserSSHApplicationScimConfigMapping(TypedDict, total=False): """ -class BrowserSSHApplicationScimConfig(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1131,7 +1131,7 @@ class BrowserSSHApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: BrowserSSHApplicationScimConfigAuthentication + authentication: BrowserSSHApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1147,7 +1147,7 @@ class BrowserSSHApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[BrowserSSHApplicationScimConfigMapping] + mappings: Iterable[BrowserSSHApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1262,7 +1262,7 @@ class BrowserVncApplication(TypedDict, total=False): attacks. """ - scim_config: BrowserVncApplicationScimConfig + scim_config: BrowserVncApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1371,7 +1371,7 @@ class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): ] -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -1382,7 +1382,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -1392,7 +1392,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -1424,14 +1424,14 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserVncApplicationScimConfigAuthentication = Union[ - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserVncApplicationSCIMConfigAuthentication = Union[ + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserVncApplicationScimConfigMappingOperations(TypedDict, total=False): +class BrowserVncApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -1442,7 +1442,7 @@ class BrowserVncApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserVncApplicationScimConfigMapping(TypedDict, total=False): +class BrowserVncApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -1456,7 +1456,7 @@ class BrowserVncApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: BrowserVncApplicationScimConfigMappingOperations + operations: BrowserVncApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -1466,7 +1466,7 @@ class BrowserVncApplicationScimConfigMapping(TypedDict, total=False): """ -class BrowserVncApplicationScimConfig(TypedDict, total=False): +class BrowserVncApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1476,7 +1476,7 @@ class BrowserVncApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: BrowserVncApplicationScimConfigAuthentication + authentication: BrowserVncApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1492,7 +1492,7 @@ class BrowserVncApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[BrowserVncApplicationScimConfigMapping] + mappings: Iterable[BrowserVncApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1530,7 +1530,7 @@ class AppLauncherApplication(TypedDict, total=False): exclusive to the application. """ - scim_config: AppLauncherApplicationScimConfig + scim_config: AppLauncherApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1624,7 +1624,7 @@ class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): ] -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -1635,7 +1635,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """User name used to authenticate with the remote SCIM service.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -1645,7 +1645,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """The authentication scheme to use when making SCIM requests to this application.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -1677,14 +1677,14 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """ -AppLauncherApplicationScimConfigAuthentication = Union[ - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +AppLauncherApplicationSCIMConfigAuthentication = Union[ + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class AppLauncherApplicationScimConfigMappingOperations(TypedDict, total=False): +class AppLauncherApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -1695,7 +1695,7 @@ class AppLauncherApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class AppLauncherApplicationScimConfigMapping(TypedDict, total=False): +class AppLauncherApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -1709,7 +1709,7 @@ class AppLauncherApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: AppLauncherApplicationScimConfigMappingOperations + operations: AppLauncherApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -1719,7 +1719,7 @@ class AppLauncherApplicationScimConfigMapping(TypedDict, total=False): """ -class AppLauncherApplicationScimConfig(TypedDict, total=False): +class AppLauncherApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1729,7 +1729,7 @@ class AppLauncherApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: AppLauncherApplicationScimConfigAuthentication + authentication: AppLauncherApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1745,7 +1745,7 @@ class AppLauncherApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[AppLauncherApplicationScimConfigMapping] + mappings: Iterable[AppLauncherApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1783,7 +1783,7 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): exclusive to the application. """ - scim_config: DeviceEnrollmentPermissionsApplicationScimConfig + scim_config: DeviceEnrollmentPermissionsApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1879,7 +1879,7 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total= ] -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic( TypedDict, total=False ): password: Required[str] @@ -1892,7 +1892,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -1902,7 +1902,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2( TypedDict, total=False ): authorization_url: Required[str] @@ -1936,14 +1936,14 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(TypedDict, total=False): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -1954,7 +1954,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(TypedDic """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class DeviceEnrollmentPermissionsApplicationScimConfigMapping(TypedDict, total=False): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -1968,7 +1968,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(TypedDict, total=F that matches resources that should be provisioned to this application. """ - operations: DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations + operations: DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -1978,7 +1978,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(TypedDict, total=F """ -class DeviceEnrollmentPermissionsApplicationScimConfig(TypedDict, total=False): +class DeviceEnrollmentPermissionsApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1988,7 +1988,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: DeviceEnrollmentPermissionsApplicationScimConfigAuthentication + authentication: DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2004,7 +2004,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[DeviceEnrollmentPermissionsApplicationScimConfigMapping] + mappings: Iterable[DeviceEnrollmentPermissionsApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2042,7 +2042,7 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): exclusive to the application. """ - scim_config: BrowserIsolationPermissionsApplicationScimConfig + scim_config: BrowserIsolationPermissionsApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -2138,7 +2138,7 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total= ] -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic( TypedDict, total=False ): password: Required[str] @@ -2151,7 +2151,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -2161,7 +2161,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2( TypedDict, total=False ): authorization_url: Required[str] @@ -2195,14 +2195,14 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserIsolationPermissionsApplicationSCIMConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -2213,7 +2213,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(TypedDic """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserIsolationPermissionsApplicationScimConfigMapping(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -2227,7 +2227,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(TypedDict, total=F that matches resources that should be provisioned to this application. """ - operations: BrowserIsolationPermissionsApplicationScimConfigMappingOperations + operations: BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -2237,7 +2237,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(TypedDict, total=F """ -class BrowserIsolationPermissionsApplicationScimConfig(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2247,7 +2247,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: BrowserIsolationPermissionsApplicationScimConfigAuthentication + authentication: BrowserIsolationPermissionsApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2263,7 +2263,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[BrowserIsolationPermissionsApplicationScimConfigMapping] + mappings: Iterable[BrowserIsolationPermissionsApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2289,7 +2289,7 @@ class BookmarkApplication(TypedDict, total=False): name: str """The name of the application.""" - scim_config: BookmarkApplicationScimConfig + scim_config: BookmarkApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -2305,7 +2305,7 @@ class BookmarkApplication(TypedDict, total=False): """The application type.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -2316,7 +2316,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationH """User name used to authenticate with the remote SCIM service.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(TypedDict, total=False): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(TypedDict, total=False): token: Required[str] """Token used to authenticate with the remote SCIM service.""" @@ -2324,7 +2324,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """The authentication scheme to use when making SCIM requests to this application.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -2356,14 +2356,14 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """ -BookmarkApplicationScimConfigAuthentication = Union[ - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BookmarkApplicationSCIMConfigAuthentication = Union[ + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BookmarkApplicationScimConfigMappingOperations(TypedDict, total=False): +class BookmarkApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -2374,7 +2374,7 @@ class BookmarkApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BookmarkApplicationScimConfigMapping(TypedDict, total=False): +class BookmarkApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -2388,7 +2388,7 @@ class BookmarkApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: BookmarkApplicationScimConfigMappingOperations + operations: BookmarkApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -2398,7 +2398,7 @@ class BookmarkApplicationScimConfigMapping(TypedDict, total=False): """ -class BookmarkApplicationScimConfig(TypedDict, total=False): +class BookmarkApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2408,7 +2408,7 @@ class BookmarkApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: BookmarkApplicationScimConfigAuthentication + authentication: BookmarkApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2424,7 +2424,7 @@ class BookmarkApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[BookmarkApplicationScimConfigMapping] + mappings: Iterable[BookmarkApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. diff --git a/src/cloudflare/types/zero_trust/access/application_create_response.py b/src/cloudflare/types/zero_trust/access/application_create_response.py index 5723338d66f..f6c58d8012b 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_response.py +++ b/src/cloudflare/types/zero_trust/access/application_create_response.py @@ -20,13 +20,13 @@ "ApplicationCreateResponse", "SelfHostedApplication", "SelfHostedApplicationPolicy", - "SelfHostedApplicationScimConfig", - "SelfHostedApplicationScimConfigAuthentication", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SelfHostedApplicationScimConfigMapping", - "SelfHostedApplicationScimConfigMappingOperations", + "SelfHostedApplicationSCIMConfig", + "SelfHostedApplicationSCIMConfigAuthentication", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SelfHostedApplicationSCIMConfigMapping", + "SelfHostedApplicationSCIMConfigMappingOperations", "SaaSApplication", "SaaSApplicationPolicy", "SaaSApplicationSaaSApp", @@ -35,66 +35,66 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", - "SaaSApplicationScimConfig", - "SaaSApplicationScimConfigAuthentication", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SaaSApplicationScimConfigMapping", - "SaaSApplicationScimConfigMappingOperations", + "SaaSApplicationSCIMConfig", + "SaaSApplicationSCIMConfigAuthentication", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SaaSApplicationSCIMConfigMapping", + "SaaSApplicationSCIMConfigMappingOperations", "BrowserSSHApplication", "BrowserSSHApplicationPolicy", - "BrowserSSHApplicationScimConfig", - "BrowserSSHApplicationScimConfigAuthentication", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserSSHApplicationScimConfigMapping", - "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserSSHApplicationSCIMConfig", + "BrowserSSHApplicationSCIMConfigAuthentication", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserSSHApplicationSCIMConfigMapping", + "BrowserSSHApplicationSCIMConfigMappingOperations", "BrowserVncApplication", "BrowserVncApplicationPolicy", - "BrowserVncApplicationScimConfig", - "BrowserVncApplicationScimConfigAuthentication", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserVncApplicationScimConfigMapping", - "BrowserVncApplicationScimConfigMappingOperations", + "BrowserVncApplicationSCIMConfig", + "BrowserVncApplicationSCIMConfigAuthentication", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserVncApplicationSCIMConfigMapping", + "BrowserVncApplicationSCIMConfigMappingOperations", "AppLauncherApplication", "AppLauncherApplicationPolicy", - "AppLauncherApplicationScimConfig", - "AppLauncherApplicationScimConfigAuthentication", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "AppLauncherApplicationScimConfigMapping", - "AppLauncherApplicationScimConfigMappingOperations", + "AppLauncherApplicationSCIMConfig", + "AppLauncherApplicationSCIMConfigAuthentication", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "AppLauncherApplicationSCIMConfigMapping", + "AppLauncherApplicationSCIMConfigMappingOperations", "DeviceEnrollmentPermissionsApplication", "DeviceEnrollmentPermissionsApplicationPolicy", - "DeviceEnrollmentPermissionsApplicationScimConfig", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "DeviceEnrollmentPermissionsApplicationScimConfigMapping", - "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplicationSCIMConfig", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMapping", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations", "BrowserIsolationPermissionsApplication", "BrowserIsolationPermissionsApplicationPolicy", - "BrowserIsolationPermissionsApplicationScimConfig", - "BrowserIsolationPermissionsApplicationScimConfigAuthentication", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserIsolationPermissionsApplicationScimConfigMapping", - "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplicationSCIMConfig", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthentication", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationSCIMConfigMapping", + "BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations", "BookmarkApplication", - "BookmarkApplicationScimConfig", - "BookmarkApplicationScimConfigAuthentication", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BookmarkApplicationScimConfigMapping", - "BookmarkApplicationScimConfigMappingOperations", + "BookmarkApplicationSCIMConfig", + "BookmarkApplicationSCIMConfigAuthentication", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BookmarkApplicationSCIMConfigMapping", + "BookmarkApplicationSCIMConfigMappingOperations", ] @@ -160,7 +160,7 @@ class SelfHostedApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -171,7 +171,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -179,7 +179,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -211,14 +211,14 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -SelfHostedApplicationScimConfigAuthentication = Union[ - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SelfHostedApplicationSCIMConfigAuthentication = Union[ + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SelfHostedApplicationScimConfigMappingOperations(BaseModel): +class SelfHostedApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -229,7 +229,7 @@ class SelfHostedApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SelfHostedApplicationScimConfigMapping(BaseModel): +class SelfHostedApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -243,7 +243,7 @@ class SelfHostedApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[SelfHostedApplicationScimConfigMappingOperations] = None + operations: Optional[SelfHostedApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -253,7 +253,7 @@ class SelfHostedApplicationScimConfigMapping(BaseModel): """ -class SelfHostedApplicationScimConfig(BaseModel): +class SelfHostedApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -263,7 +263,7 @@ class SelfHostedApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[SelfHostedApplicationScimConfigAuthentication] = None + authentication: Optional[SelfHostedApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -279,7 +279,7 @@ class SelfHostedApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[SelfHostedApplicationScimConfigMapping]] = None + mappings: Optional[List[SelfHostedApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -391,7 +391,7 @@ class SelfHostedApplication(BaseModel): attacks. """ - scim_config: Optional[SelfHostedApplicationScimConfig] = None + scim_config: Optional[SelfHostedApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -580,7 +580,7 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -591,7 +591,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPB """User name used to authenticate with the remote SCIM service.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -599,7 +599,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuth """The authentication scheme to use when making SCIM requests to this application.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -631,14 +631,14 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth """ -SaaSApplicationScimConfigAuthentication = Union[ - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SaaSApplicationSCIMConfigAuthentication = Union[ + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SaaSApplicationScimConfigMappingOperations(BaseModel): +class SaaSApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -649,7 +649,7 @@ class SaaSApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SaaSApplicationScimConfigMapping(BaseModel): +class SaaSApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -663,7 +663,7 @@ class SaaSApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[SaaSApplicationScimConfigMappingOperations] = None + operations: Optional[SaaSApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -673,7 +673,7 @@ class SaaSApplicationScimConfigMapping(BaseModel): """ -class SaaSApplicationScimConfig(BaseModel): +class SaaSApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -683,7 +683,7 @@ class SaaSApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[SaaSApplicationScimConfigAuthentication] = None + authentication: Optional[SaaSApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -699,7 +699,7 @@ class SaaSApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[SaaSApplicationScimConfigMapping]] = None + mappings: Optional[List[SaaSApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -745,7 +745,7 @@ class SaaSApplication(BaseModel): saas_app: Optional[SaaSApplicationSaaSApp] = None - scim_config: Optional[SaaSApplicationScimConfig] = None + scim_config: Optional[SaaSApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -825,7 +825,7 @@ class BrowserSSHApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -836,7 +836,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -844,7 +844,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -876,14 +876,14 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserSSHApplicationScimConfigAuthentication = Union[ - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserSSHApplicationSCIMConfigAuthentication = Union[ + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): +class BrowserSSHApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -894,7 +894,7 @@ class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserSSHApplicationScimConfigMapping(BaseModel): +class BrowserSSHApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -908,7 +908,7 @@ class BrowserSSHApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserSSHApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserSSHApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -918,7 +918,7 @@ class BrowserSSHApplicationScimConfigMapping(BaseModel): """ -class BrowserSSHApplicationScimConfig(BaseModel): +class BrowserSSHApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -928,7 +928,7 @@ class BrowserSSHApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserSSHApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserSSHApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -944,7 +944,7 @@ class BrowserSSHApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserSSHApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserSSHApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1056,7 +1056,7 @@ class BrowserSSHApplication(BaseModel): attacks. """ - scim_config: Optional[BrowserSSHApplicationScimConfig] = None + scim_config: Optional[BrowserSSHApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1149,7 +1149,7 @@ class BrowserVncApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1160,7 +1160,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -1168,7 +1168,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1200,14 +1200,14 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserVncApplicationScimConfigAuthentication = Union[ - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserVncApplicationSCIMConfigAuthentication = Union[ + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserVncApplicationScimConfigMappingOperations(BaseModel): +class BrowserVncApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1218,7 +1218,7 @@ class BrowserVncApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserVncApplicationScimConfigMapping(BaseModel): +class BrowserVncApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1232,7 +1232,7 @@ class BrowserVncApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserVncApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserVncApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1242,7 +1242,7 @@ class BrowserVncApplicationScimConfigMapping(BaseModel): """ -class BrowserVncApplicationScimConfig(BaseModel): +class BrowserVncApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1252,7 +1252,7 @@ class BrowserVncApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserVncApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserVncApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1268,7 +1268,7 @@ class BrowserVncApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserVncApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserVncApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1380,7 +1380,7 @@ class BrowserVncApplication(BaseModel): attacks. """ - scim_config: Optional[BrowserVncApplicationScimConfig] = None + scim_config: Optional[BrowserVncApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1473,7 +1473,7 @@ class AppLauncherApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1484,7 +1484,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """User name used to authenticate with the remote SCIM service.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -1492,7 +1492,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """The authentication scheme to use when making SCIM requests to this application.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1524,14 +1524,14 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """ -AppLauncherApplicationScimConfigAuthentication = Union[ - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +AppLauncherApplicationSCIMConfigAuthentication = Union[ + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class AppLauncherApplicationScimConfigMappingOperations(BaseModel): +class AppLauncherApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1542,7 +1542,7 @@ class AppLauncherApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class AppLauncherApplicationScimConfigMapping(BaseModel): +class AppLauncherApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1556,7 +1556,7 @@ class AppLauncherApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[AppLauncherApplicationScimConfigMappingOperations] = None + operations: Optional[AppLauncherApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1566,7 +1566,7 @@ class AppLauncherApplicationScimConfigMapping(BaseModel): """ -class AppLauncherApplicationScimConfig(BaseModel): +class AppLauncherApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1576,7 +1576,7 @@ class AppLauncherApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[AppLauncherApplicationScimConfigAuthentication] = None + authentication: Optional[AppLauncherApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1592,7 +1592,7 @@ class AppLauncherApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[AppLauncherApplicationScimConfigMapping]] = None + mappings: Optional[List[AppLauncherApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1637,7 +1637,7 @@ class AppLauncherApplication(BaseModel): policies: Optional[List[AppLauncherApplicationPolicy]] = None - scim_config: Optional[AppLauncherApplicationScimConfig] = None + scim_config: Optional[AppLauncherApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1715,7 +1715,7 @@ class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1726,7 +1726,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( BaseModel ): token: str @@ -1736,7 +1736,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1768,14 +1768,14 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1786,7 +1786,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseMode """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1800,7 +1800,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations] = None + operations: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1810,7 +1810,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): """ -class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1820,7 +1820,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[DeviceEnrollmentPermissionsApplicationScimConfigAuthentication] = None + authentication: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1836,7 +1836,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[DeviceEnrollmentPermissionsApplicationScimConfigMapping]] = None + mappings: Optional[List[DeviceEnrollmentPermissionsApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1881,7 +1881,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): policies: Optional[List[DeviceEnrollmentPermissionsApplicationPolicy]] = None - scim_config: Optional[DeviceEnrollmentPermissionsApplicationScimConfig] = None + scim_config: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1959,7 +1959,7 @@ class BrowserIsolationPermissionsApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1970,7 +1970,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( BaseModel ): token: str @@ -1980,7 +1980,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -2012,14 +2012,14 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserIsolationPermissionsApplicationSCIMConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -2030,7 +2030,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseMode """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -2044,7 +2044,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserIsolationPermissionsApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -2054,7 +2054,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): """ -class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2064,7 +2064,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserIsolationPermissionsApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserIsolationPermissionsApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2080,7 +2080,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserIsolationPermissionsApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserIsolationPermissionsApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2125,7 +2125,7 @@ class BrowserIsolationPermissionsApplication(BaseModel): policies: Optional[List[BrowserIsolationPermissionsApplicationPolicy]] = None - scim_config: Optional[BrowserIsolationPermissionsApplicationScimConfig] = None + scim_config: Optional[BrowserIsolationPermissionsApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -2141,7 +2141,7 @@ class BrowserIsolationPermissionsApplication(BaseModel): updated_at: Optional[datetime] = None -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -2152,7 +2152,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationH """User name used to authenticate with the remote SCIM service.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -2160,7 +2160,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """The authentication scheme to use when making SCIM requests to this application.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -2192,14 +2192,14 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """ -BookmarkApplicationScimConfigAuthentication = Union[ - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BookmarkApplicationSCIMConfigAuthentication = Union[ + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BookmarkApplicationScimConfigMappingOperations(BaseModel): +class BookmarkApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -2210,7 +2210,7 @@ class BookmarkApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BookmarkApplicationScimConfigMapping(BaseModel): +class BookmarkApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -2224,7 +2224,7 @@ class BookmarkApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BookmarkApplicationScimConfigMappingOperations] = None + operations: Optional[BookmarkApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -2234,7 +2234,7 @@ class BookmarkApplicationScimConfigMapping(BaseModel): """ -class BookmarkApplicationScimConfig(BaseModel): +class BookmarkApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2244,7 +2244,7 @@ class BookmarkApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BookmarkApplicationScimConfigAuthentication] = None + authentication: Optional[BookmarkApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2260,7 +2260,7 @@ class BookmarkApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BookmarkApplicationScimConfigMapping]] = None + mappings: Optional[List[BookmarkApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2288,7 +2288,7 @@ class BookmarkApplication(BaseModel): name: Optional[str] = None """The name of the application.""" - scim_config: Optional[BookmarkApplicationScimConfig] = None + scim_config: Optional[BookmarkApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. diff --git a/src/cloudflare/types/zero_trust/access/application_get_response.py b/src/cloudflare/types/zero_trust/access/application_get_response.py index 5fd2d5a2925..e4990e3e2b2 100644 --- a/src/cloudflare/types/zero_trust/access/application_get_response.py +++ b/src/cloudflare/types/zero_trust/access/application_get_response.py @@ -20,13 +20,13 @@ "ApplicationGetResponse", "SelfHostedApplication", "SelfHostedApplicationPolicy", - "SelfHostedApplicationScimConfig", - "SelfHostedApplicationScimConfigAuthentication", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SelfHostedApplicationScimConfigMapping", - "SelfHostedApplicationScimConfigMappingOperations", + "SelfHostedApplicationSCIMConfig", + "SelfHostedApplicationSCIMConfigAuthentication", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SelfHostedApplicationSCIMConfigMapping", + "SelfHostedApplicationSCIMConfigMappingOperations", "SaaSApplication", "SaaSApplicationPolicy", "SaaSApplicationSaaSApp", @@ -35,66 +35,66 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", - "SaaSApplicationScimConfig", - "SaaSApplicationScimConfigAuthentication", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SaaSApplicationScimConfigMapping", - "SaaSApplicationScimConfigMappingOperations", + "SaaSApplicationSCIMConfig", + "SaaSApplicationSCIMConfigAuthentication", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SaaSApplicationSCIMConfigMapping", + "SaaSApplicationSCIMConfigMappingOperations", "BrowserSSHApplication", "BrowserSSHApplicationPolicy", - "BrowserSSHApplicationScimConfig", - "BrowserSSHApplicationScimConfigAuthentication", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserSSHApplicationScimConfigMapping", - "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserSSHApplicationSCIMConfig", + "BrowserSSHApplicationSCIMConfigAuthentication", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserSSHApplicationSCIMConfigMapping", + "BrowserSSHApplicationSCIMConfigMappingOperations", "BrowserVncApplication", "BrowserVncApplicationPolicy", - "BrowserVncApplicationScimConfig", - "BrowserVncApplicationScimConfigAuthentication", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserVncApplicationScimConfigMapping", - "BrowserVncApplicationScimConfigMappingOperations", + "BrowserVncApplicationSCIMConfig", + "BrowserVncApplicationSCIMConfigAuthentication", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserVncApplicationSCIMConfigMapping", + "BrowserVncApplicationSCIMConfigMappingOperations", "AppLauncherApplication", "AppLauncherApplicationPolicy", - "AppLauncherApplicationScimConfig", - "AppLauncherApplicationScimConfigAuthentication", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "AppLauncherApplicationScimConfigMapping", - "AppLauncherApplicationScimConfigMappingOperations", + "AppLauncherApplicationSCIMConfig", + "AppLauncherApplicationSCIMConfigAuthentication", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "AppLauncherApplicationSCIMConfigMapping", + "AppLauncherApplicationSCIMConfigMappingOperations", "DeviceEnrollmentPermissionsApplication", "DeviceEnrollmentPermissionsApplicationPolicy", - "DeviceEnrollmentPermissionsApplicationScimConfig", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "DeviceEnrollmentPermissionsApplicationScimConfigMapping", - "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplicationSCIMConfig", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMapping", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations", "BrowserIsolationPermissionsApplication", "BrowserIsolationPermissionsApplicationPolicy", - "BrowserIsolationPermissionsApplicationScimConfig", - "BrowserIsolationPermissionsApplicationScimConfigAuthentication", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserIsolationPermissionsApplicationScimConfigMapping", - "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplicationSCIMConfig", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthentication", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationSCIMConfigMapping", + "BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations", "BookmarkApplication", - "BookmarkApplicationScimConfig", - "BookmarkApplicationScimConfigAuthentication", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BookmarkApplicationScimConfigMapping", - "BookmarkApplicationScimConfigMappingOperations", + "BookmarkApplicationSCIMConfig", + "BookmarkApplicationSCIMConfigAuthentication", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BookmarkApplicationSCIMConfigMapping", + "BookmarkApplicationSCIMConfigMappingOperations", ] @@ -160,7 +160,7 @@ class SelfHostedApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -171,7 +171,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -179,7 +179,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -211,14 +211,14 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -SelfHostedApplicationScimConfigAuthentication = Union[ - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SelfHostedApplicationSCIMConfigAuthentication = Union[ + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SelfHostedApplicationScimConfigMappingOperations(BaseModel): +class SelfHostedApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -229,7 +229,7 @@ class SelfHostedApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SelfHostedApplicationScimConfigMapping(BaseModel): +class SelfHostedApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -243,7 +243,7 @@ class SelfHostedApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[SelfHostedApplicationScimConfigMappingOperations] = None + operations: Optional[SelfHostedApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -253,7 +253,7 @@ class SelfHostedApplicationScimConfigMapping(BaseModel): """ -class SelfHostedApplicationScimConfig(BaseModel): +class SelfHostedApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -263,7 +263,7 @@ class SelfHostedApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[SelfHostedApplicationScimConfigAuthentication] = None + authentication: Optional[SelfHostedApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -279,7 +279,7 @@ class SelfHostedApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[SelfHostedApplicationScimConfigMapping]] = None + mappings: Optional[List[SelfHostedApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -391,7 +391,7 @@ class SelfHostedApplication(BaseModel): attacks. """ - scim_config: Optional[SelfHostedApplicationScimConfig] = None + scim_config: Optional[SelfHostedApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -580,7 +580,7 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -591,7 +591,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPB """User name used to authenticate with the remote SCIM service.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -599,7 +599,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuth """The authentication scheme to use when making SCIM requests to this application.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -631,14 +631,14 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth """ -SaaSApplicationScimConfigAuthentication = Union[ - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SaaSApplicationSCIMConfigAuthentication = Union[ + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SaaSApplicationScimConfigMappingOperations(BaseModel): +class SaaSApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -649,7 +649,7 @@ class SaaSApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SaaSApplicationScimConfigMapping(BaseModel): +class SaaSApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -663,7 +663,7 @@ class SaaSApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[SaaSApplicationScimConfigMappingOperations] = None + operations: Optional[SaaSApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -673,7 +673,7 @@ class SaaSApplicationScimConfigMapping(BaseModel): """ -class SaaSApplicationScimConfig(BaseModel): +class SaaSApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -683,7 +683,7 @@ class SaaSApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[SaaSApplicationScimConfigAuthentication] = None + authentication: Optional[SaaSApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -699,7 +699,7 @@ class SaaSApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[SaaSApplicationScimConfigMapping]] = None + mappings: Optional[List[SaaSApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -745,7 +745,7 @@ class SaaSApplication(BaseModel): saas_app: Optional[SaaSApplicationSaaSApp] = None - scim_config: Optional[SaaSApplicationScimConfig] = None + scim_config: Optional[SaaSApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -825,7 +825,7 @@ class BrowserSSHApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -836,7 +836,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -844,7 +844,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -876,14 +876,14 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserSSHApplicationScimConfigAuthentication = Union[ - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserSSHApplicationSCIMConfigAuthentication = Union[ + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): +class BrowserSSHApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -894,7 +894,7 @@ class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserSSHApplicationScimConfigMapping(BaseModel): +class BrowserSSHApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -908,7 +908,7 @@ class BrowserSSHApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserSSHApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserSSHApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -918,7 +918,7 @@ class BrowserSSHApplicationScimConfigMapping(BaseModel): """ -class BrowserSSHApplicationScimConfig(BaseModel): +class BrowserSSHApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -928,7 +928,7 @@ class BrowserSSHApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserSSHApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserSSHApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -944,7 +944,7 @@ class BrowserSSHApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserSSHApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserSSHApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1056,7 +1056,7 @@ class BrowserSSHApplication(BaseModel): attacks. """ - scim_config: Optional[BrowserSSHApplicationScimConfig] = None + scim_config: Optional[BrowserSSHApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1149,7 +1149,7 @@ class BrowserVncApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1160,7 +1160,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -1168,7 +1168,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1200,14 +1200,14 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserVncApplicationScimConfigAuthentication = Union[ - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserVncApplicationSCIMConfigAuthentication = Union[ + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserVncApplicationScimConfigMappingOperations(BaseModel): +class BrowserVncApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1218,7 +1218,7 @@ class BrowserVncApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserVncApplicationScimConfigMapping(BaseModel): +class BrowserVncApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1232,7 +1232,7 @@ class BrowserVncApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserVncApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserVncApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1242,7 +1242,7 @@ class BrowserVncApplicationScimConfigMapping(BaseModel): """ -class BrowserVncApplicationScimConfig(BaseModel): +class BrowserVncApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1252,7 +1252,7 @@ class BrowserVncApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserVncApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserVncApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1268,7 +1268,7 @@ class BrowserVncApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserVncApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserVncApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1380,7 +1380,7 @@ class BrowserVncApplication(BaseModel): attacks. """ - scim_config: Optional[BrowserVncApplicationScimConfig] = None + scim_config: Optional[BrowserVncApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1473,7 +1473,7 @@ class AppLauncherApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1484,7 +1484,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """User name used to authenticate with the remote SCIM service.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -1492,7 +1492,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """The authentication scheme to use when making SCIM requests to this application.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1524,14 +1524,14 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """ -AppLauncherApplicationScimConfigAuthentication = Union[ - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +AppLauncherApplicationSCIMConfigAuthentication = Union[ + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class AppLauncherApplicationScimConfigMappingOperations(BaseModel): +class AppLauncherApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1542,7 +1542,7 @@ class AppLauncherApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class AppLauncherApplicationScimConfigMapping(BaseModel): +class AppLauncherApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1556,7 +1556,7 @@ class AppLauncherApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[AppLauncherApplicationScimConfigMappingOperations] = None + operations: Optional[AppLauncherApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1566,7 +1566,7 @@ class AppLauncherApplicationScimConfigMapping(BaseModel): """ -class AppLauncherApplicationScimConfig(BaseModel): +class AppLauncherApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1576,7 +1576,7 @@ class AppLauncherApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[AppLauncherApplicationScimConfigAuthentication] = None + authentication: Optional[AppLauncherApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1592,7 +1592,7 @@ class AppLauncherApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[AppLauncherApplicationScimConfigMapping]] = None + mappings: Optional[List[AppLauncherApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1637,7 +1637,7 @@ class AppLauncherApplication(BaseModel): policies: Optional[List[AppLauncherApplicationPolicy]] = None - scim_config: Optional[AppLauncherApplicationScimConfig] = None + scim_config: Optional[AppLauncherApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1715,7 +1715,7 @@ class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1726,7 +1726,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( BaseModel ): token: str @@ -1736,7 +1736,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1768,14 +1768,14 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1786,7 +1786,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseMode """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1800,7 +1800,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations] = None + operations: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1810,7 +1810,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): """ -class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1820,7 +1820,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[DeviceEnrollmentPermissionsApplicationScimConfigAuthentication] = None + authentication: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1836,7 +1836,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[DeviceEnrollmentPermissionsApplicationScimConfigMapping]] = None + mappings: Optional[List[DeviceEnrollmentPermissionsApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1881,7 +1881,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): policies: Optional[List[DeviceEnrollmentPermissionsApplicationPolicy]] = None - scim_config: Optional[DeviceEnrollmentPermissionsApplicationScimConfig] = None + scim_config: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1959,7 +1959,7 @@ class BrowserIsolationPermissionsApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1970,7 +1970,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( BaseModel ): token: str @@ -1980,7 +1980,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -2012,14 +2012,14 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserIsolationPermissionsApplicationSCIMConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -2030,7 +2030,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseMode """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -2044,7 +2044,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserIsolationPermissionsApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -2054,7 +2054,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): """ -class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2064,7 +2064,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserIsolationPermissionsApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserIsolationPermissionsApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2080,7 +2080,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserIsolationPermissionsApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserIsolationPermissionsApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2125,7 +2125,7 @@ class BrowserIsolationPermissionsApplication(BaseModel): policies: Optional[List[BrowserIsolationPermissionsApplicationPolicy]] = None - scim_config: Optional[BrowserIsolationPermissionsApplicationScimConfig] = None + scim_config: Optional[BrowserIsolationPermissionsApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -2141,7 +2141,7 @@ class BrowserIsolationPermissionsApplication(BaseModel): updated_at: Optional[datetime] = None -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -2152,7 +2152,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationH """User name used to authenticate with the remote SCIM service.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -2160,7 +2160,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """The authentication scheme to use when making SCIM requests to this application.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -2192,14 +2192,14 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """ -BookmarkApplicationScimConfigAuthentication = Union[ - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BookmarkApplicationSCIMConfigAuthentication = Union[ + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BookmarkApplicationScimConfigMappingOperations(BaseModel): +class BookmarkApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -2210,7 +2210,7 @@ class BookmarkApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BookmarkApplicationScimConfigMapping(BaseModel): +class BookmarkApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -2224,7 +2224,7 @@ class BookmarkApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BookmarkApplicationScimConfigMappingOperations] = None + operations: Optional[BookmarkApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -2234,7 +2234,7 @@ class BookmarkApplicationScimConfigMapping(BaseModel): """ -class BookmarkApplicationScimConfig(BaseModel): +class BookmarkApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2244,7 +2244,7 @@ class BookmarkApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BookmarkApplicationScimConfigAuthentication] = None + authentication: Optional[BookmarkApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2260,7 +2260,7 @@ class BookmarkApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BookmarkApplicationScimConfigMapping]] = None + mappings: Optional[List[BookmarkApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2288,7 +2288,7 @@ class BookmarkApplication(BaseModel): name: Optional[str] = None """The name of the application.""" - scim_config: Optional[BookmarkApplicationScimConfig] = None + scim_config: Optional[BookmarkApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. diff --git a/src/cloudflare/types/zero_trust/access/application_list_response.py b/src/cloudflare/types/zero_trust/access/application_list_response.py index 9cbe550e5ac..f2b23a70eae 100644 --- a/src/cloudflare/types/zero_trust/access/application_list_response.py +++ b/src/cloudflare/types/zero_trust/access/application_list_response.py @@ -20,13 +20,13 @@ "ApplicationListResponse", "SelfHostedApplication", "SelfHostedApplicationPolicy", - "SelfHostedApplicationScimConfig", - "SelfHostedApplicationScimConfigAuthentication", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SelfHostedApplicationScimConfigMapping", - "SelfHostedApplicationScimConfigMappingOperations", + "SelfHostedApplicationSCIMConfig", + "SelfHostedApplicationSCIMConfigAuthentication", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SelfHostedApplicationSCIMConfigMapping", + "SelfHostedApplicationSCIMConfigMappingOperations", "SaaSApplication", "SaaSApplicationPolicy", "SaaSApplicationSaaSApp", @@ -35,66 +35,66 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", - "SaaSApplicationScimConfig", - "SaaSApplicationScimConfigAuthentication", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SaaSApplicationScimConfigMapping", - "SaaSApplicationScimConfigMappingOperations", + "SaaSApplicationSCIMConfig", + "SaaSApplicationSCIMConfigAuthentication", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SaaSApplicationSCIMConfigMapping", + "SaaSApplicationSCIMConfigMappingOperations", "BrowserSSHApplication", "BrowserSSHApplicationPolicy", - "BrowserSSHApplicationScimConfig", - "BrowserSSHApplicationScimConfigAuthentication", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserSSHApplicationScimConfigMapping", - "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserSSHApplicationSCIMConfig", + "BrowserSSHApplicationSCIMConfigAuthentication", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserSSHApplicationSCIMConfigMapping", + "BrowserSSHApplicationSCIMConfigMappingOperations", "BrowserVncApplication", "BrowserVncApplicationPolicy", - "BrowserVncApplicationScimConfig", - "BrowserVncApplicationScimConfigAuthentication", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserVncApplicationScimConfigMapping", - "BrowserVncApplicationScimConfigMappingOperations", + "BrowserVncApplicationSCIMConfig", + "BrowserVncApplicationSCIMConfigAuthentication", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserVncApplicationSCIMConfigMapping", + "BrowserVncApplicationSCIMConfigMappingOperations", "AppLauncherApplication", "AppLauncherApplicationPolicy", - "AppLauncherApplicationScimConfig", - "AppLauncherApplicationScimConfigAuthentication", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "AppLauncherApplicationScimConfigMapping", - "AppLauncherApplicationScimConfigMappingOperations", + "AppLauncherApplicationSCIMConfig", + "AppLauncherApplicationSCIMConfigAuthentication", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "AppLauncherApplicationSCIMConfigMapping", + "AppLauncherApplicationSCIMConfigMappingOperations", "DeviceEnrollmentPermissionsApplication", "DeviceEnrollmentPermissionsApplicationPolicy", - "DeviceEnrollmentPermissionsApplicationScimConfig", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "DeviceEnrollmentPermissionsApplicationScimConfigMapping", - "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplicationSCIMConfig", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMapping", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations", "BrowserIsolationPermissionsApplication", "BrowserIsolationPermissionsApplicationPolicy", - "BrowserIsolationPermissionsApplicationScimConfig", - "BrowserIsolationPermissionsApplicationScimConfigAuthentication", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserIsolationPermissionsApplicationScimConfigMapping", - "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplicationSCIMConfig", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthentication", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationSCIMConfigMapping", + "BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations", "BookmarkApplication", - "BookmarkApplicationScimConfig", - "BookmarkApplicationScimConfigAuthentication", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BookmarkApplicationScimConfigMapping", - "BookmarkApplicationScimConfigMappingOperations", + "BookmarkApplicationSCIMConfig", + "BookmarkApplicationSCIMConfigAuthentication", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BookmarkApplicationSCIMConfigMapping", + "BookmarkApplicationSCIMConfigMappingOperations", ] @@ -160,7 +160,7 @@ class SelfHostedApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -171,7 +171,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -179,7 +179,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -211,14 +211,14 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -SelfHostedApplicationScimConfigAuthentication = Union[ - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SelfHostedApplicationSCIMConfigAuthentication = Union[ + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SelfHostedApplicationScimConfigMappingOperations(BaseModel): +class SelfHostedApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -229,7 +229,7 @@ class SelfHostedApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SelfHostedApplicationScimConfigMapping(BaseModel): +class SelfHostedApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -243,7 +243,7 @@ class SelfHostedApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[SelfHostedApplicationScimConfigMappingOperations] = None + operations: Optional[SelfHostedApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -253,7 +253,7 @@ class SelfHostedApplicationScimConfigMapping(BaseModel): """ -class SelfHostedApplicationScimConfig(BaseModel): +class SelfHostedApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -263,7 +263,7 @@ class SelfHostedApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[SelfHostedApplicationScimConfigAuthentication] = None + authentication: Optional[SelfHostedApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -279,7 +279,7 @@ class SelfHostedApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[SelfHostedApplicationScimConfigMapping]] = None + mappings: Optional[List[SelfHostedApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -391,7 +391,7 @@ class SelfHostedApplication(BaseModel): attacks. """ - scim_config: Optional[SelfHostedApplicationScimConfig] = None + scim_config: Optional[SelfHostedApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -580,7 +580,7 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -591,7 +591,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPB """User name used to authenticate with the remote SCIM service.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -599,7 +599,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuth """The authentication scheme to use when making SCIM requests to this application.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -631,14 +631,14 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth """ -SaaSApplicationScimConfigAuthentication = Union[ - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SaaSApplicationSCIMConfigAuthentication = Union[ + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SaaSApplicationScimConfigMappingOperations(BaseModel): +class SaaSApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -649,7 +649,7 @@ class SaaSApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SaaSApplicationScimConfigMapping(BaseModel): +class SaaSApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -663,7 +663,7 @@ class SaaSApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[SaaSApplicationScimConfigMappingOperations] = None + operations: Optional[SaaSApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -673,7 +673,7 @@ class SaaSApplicationScimConfigMapping(BaseModel): """ -class SaaSApplicationScimConfig(BaseModel): +class SaaSApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -683,7 +683,7 @@ class SaaSApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[SaaSApplicationScimConfigAuthentication] = None + authentication: Optional[SaaSApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -699,7 +699,7 @@ class SaaSApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[SaaSApplicationScimConfigMapping]] = None + mappings: Optional[List[SaaSApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -745,7 +745,7 @@ class SaaSApplication(BaseModel): saas_app: Optional[SaaSApplicationSaaSApp] = None - scim_config: Optional[SaaSApplicationScimConfig] = None + scim_config: Optional[SaaSApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -825,7 +825,7 @@ class BrowserSSHApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -836,7 +836,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -844,7 +844,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -876,14 +876,14 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserSSHApplicationScimConfigAuthentication = Union[ - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserSSHApplicationSCIMConfigAuthentication = Union[ + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): +class BrowserSSHApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -894,7 +894,7 @@ class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserSSHApplicationScimConfigMapping(BaseModel): +class BrowserSSHApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -908,7 +908,7 @@ class BrowserSSHApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserSSHApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserSSHApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -918,7 +918,7 @@ class BrowserSSHApplicationScimConfigMapping(BaseModel): """ -class BrowserSSHApplicationScimConfig(BaseModel): +class BrowserSSHApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -928,7 +928,7 @@ class BrowserSSHApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserSSHApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserSSHApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -944,7 +944,7 @@ class BrowserSSHApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserSSHApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserSSHApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1056,7 +1056,7 @@ class BrowserSSHApplication(BaseModel): attacks. """ - scim_config: Optional[BrowserSSHApplicationScimConfig] = None + scim_config: Optional[BrowserSSHApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1149,7 +1149,7 @@ class BrowserVncApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1160,7 +1160,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -1168,7 +1168,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1200,14 +1200,14 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserVncApplicationScimConfigAuthentication = Union[ - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserVncApplicationSCIMConfigAuthentication = Union[ + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserVncApplicationScimConfigMappingOperations(BaseModel): +class BrowserVncApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1218,7 +1218,7 @@ class BrowserVncApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserVncApplicationScimConfigMapping(BaseModel): +class BrowserVncApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1232,7 +1232,7 @@ class BrowserVncApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserVncApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserVncApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1242,7 +1242,7 @@ class BrowserVncApplicationScimConfigMapping(BaseModel): """ -class BrowserVncApplicationScimConfig(BaseModel): +class BrowserVncApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1252,7 +1252,7 @@ class BrowserVncApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserVncApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserVncApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1268,7 +1268,7 @@ class BrowserVncApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserVncApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserVncApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1380,7 +1380,7 @@ class BrowserVncApplication(BaseModel): attacks. """ - scim_config: Optional[BrowserVncApplicationScimConfig] = None + scim_config: Optional[BrowserVncApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1473,7 +1473,7 @@ class AppLauncherApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1484,7 +1484,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """User name used to authenticate with the remote SCIM service.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -1492,7 +1492,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """The authentication scheme to use when making SCIM requests to this application.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1524,14 +1524,14 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """ -AppLauncherApplicationScimConfigAuthentication = Union[ - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +AppLauncherApplicationSCIMConfigAuthentication = Union[ + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class AppLauncherApplicationScimConfigMappingOperations(BaseModel): +class AppLauncherApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1542,7 +1542,7 @@ class AppLauncherApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class AppLauncherApplicationScimConfigMapping(BaseModel): +class AppLauncherApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1556,7 +1556,7 @@ class AppLauncherApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[AppLauncherApplicationScimConfigMappingOperations] = None + operations: Optional[AppLauncherApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1566,7 +1566,7 @@ class AppLauncherApplicationScimConfigMapping(BaseModel): """ -class AppLauncherApplicationScimConfig(BaseModel): +class AppLauncherApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1576,7 +1576,7 @@ class AppLauncherApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[AppLauncherApplicationScimConfigAuthentication] = None + authentication: Optional[AppLauncherApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1592,7 +1592,7 @@ class AppLauncherApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[AppLauncherApplicationScimConfigMapping]] = None + mappings: Optional[List[AppLauncherApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1637,7 +1637,7 @@ class AppLauncherApplication(BaseModel): policies: Optional[List[AppLauncherApplicationPolicy]] = None - scim_config: Optional[AppLauncherApplicationScimConfig] = None + scim_config: Optional[AppLauncherApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1715,7 +1715,7 @@ class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1726,7 +1726,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( BaseModel ): token: str @@ -1736,7 +1736,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1768,14 +1768,14 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1786,7 +1786,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseMode """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1800,7 +1800,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations] = None + operations: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1810,7 +1810,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): """ -class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1820,7 +1820,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[DeviceEnrollmentPermissionsApplicationScimConfigAuthentication] = None + authentication: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1836,7 +1836,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[DeviceEnrollmentPermissionsApplicationScimConfigMapping]] = None + mappings: Optional[List[DeviceEnrollmentPermissionsApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1881,7 +1881,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): policies: Optional[List[DeviceEnrollmentPermissionsApplicationPolicy]] = None - scim_config: Optional[DeviceEnrollmentPermissionsApplicationScimConfig] = None + scim_config: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1959,7 +1959,7 @@ class BrowserIsolationPermissionsApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1970,7 +1970,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( BaseModel ): token: str @@ -1980,7 +1980,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -2012,14 +2012,14 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserIsolationPermissionsApplicationSCIMConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -2030,7 +2030,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseMode """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -2044,7 +2044,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserIsolationPermissionsApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -2054,7 +2054,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): """ -class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2064,7 +2064,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserIsolationPermissionsApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserIsolationPermissionsApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2080,7 +2080,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserIsolationPermissionsApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserIsolationPermissionsApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2125,7 +2125,7 @@ class BrowserIsolationPermissionsApplication(BaseModel): policies: Optional[List[BrowserIsolationPermissionsApplicationPolicy]] = None - scim_config: Optional[BrowserIsolationPermissionsApplicationScimConfig] = None + scim_config: Optional[BrowserIsolationPermissionsApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -2141,7 +2141,7 @@ class BrowserIsolationPermissionsApplication(BaseModel): updated_at: Optional[datetime] = None -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -2152,7 +2152,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationH """User name used to authenticate with the remote SCIM service.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -2160,7 +2160,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """The authentication scheme to use when making SCIM requests to this application.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -2192,14 +2192,14 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """ -BookmarkApplicationScimConfigAuthentication = Union[ - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BookmarkApplicationSCIMConfigAuthentication = Union[ + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BookmarkApplicationScimConfigMappingOperations(BaseModel): +class BookmarkApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -2210,7 +2210,7 @@ class BookmarkApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BookmarkApplicationScimConfigMapping(BaseModel): +class BookmarkApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -2224,7 +2224,7 @@ class BookmarkApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BookmarkApplicationScimConfigMappingOperations] = None + operations: Optional[BookmarkApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -2234,7 +2234,7 @@ class BookmarkApplicationScimConfigMapping(BaseModel): """ -class BookmarkApplicationScimConfig(BaseModel): +class BookmarkApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2244,7 +2244,7 @@ class BookmarkApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BookmarkApplicationScimConfigAuthentication] = None + authentication: Optional[BookmarkApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2260,7 +2260,7 @@ class BookmarkApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BookmarkApplicationScimConfigMapping]] = None + mappings: Optional[List[BookmarkApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2288,7 +2288,7 @@ class BookmarkApplication(BaseModel): name: Optional[str] = None """The name of the application.""" - scim_config: Optional[BookmarkApplicationScimConfig] = None + scim_config: Optional[BookmarkApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. diff --git a/src/cloudflare/types/zero_trust/access/application_update_params.py b/src/cloudflare/types/zero_trust/access/application_update_params.py index 0f45c59a354..2dc5938e715 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_params.py +++ b/src/cloudflare/types/zero_trust/access/application_update_params.py @@ -20,13 +20,13 @@ "SelfHostedApplicationPolicy", "SelfHostedApplicationPolicyAccessAppPolicyLink", "SelfHostedApplicationPolicyUnionMember2", - "SelfHostedApplicationScimConfig", - "SelfHostedApplicationScimConfigAuthentication", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SelfHostedApplicationScimConfigMapping", - "SelfHostedApplicationScimConfigMappingOperations", + "SelfHostedApplicationSCIMConfig", + "SelfHostedApplicationSCIMConfigAuthentication", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SelfHostedApplicationSCIMConfigMapping", + "SelfHostedApplicationSCIMConfigMappingOperations", "SaaSApplication", "SaaSApplicationPolicy", "SaaSApplicationPolicyAccessAppPolicyLink", @@ -37,76 +37,76 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", - "SaaSApplicationScimConfig", - "SaaSApplicationScimConfigAuthentication", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SaaSApplicationScimConfigMapping", - "SaaSApplicationScimConfigMappingOperations", + "SaaSApplicationSCIMConfig", + "SaaSApplicationSCIMConfigAuthentication", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SaaSApplicationSCIMConfigMapping", + "SaaSApplicationSCIMConfigMappingOperations", "BrowserSSHApplication", "BrowserSSHApplicationPolicy", "BrowserSSHApplicationPolicyAccessAppPolicyLink", "BrowserSSHApplicationPolicyUnionMember2", - "BrowserSSHApplicationScimConfig", - "BrowserSSHApplicationScimConfigAuthentication", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserSSHApplicationScimConfigMapping", - "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserSSHApplicationSCIMConfig", + "BrowserSSHApplicationSCIMConfigAuthentication", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserSSHApplicationSCIMConfigMapping", + "BrowserSSHApplicationSCIMConfigMappingOperations", "BrowserVncApplication", "BrowserVncApplicationPolicy", "BrowserVncApplicationPolicyAccessAppPolicyLink", "BrowserVncApplicationPolicyUnionMember2", - "BrowserVncApplicationScimConfig", - "BrowserVncApplicationScimConfigAuthentication", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserVncApplicationScimConfigMapping", - "BrowserVncApplicationScimConfigMappingOperations", + "BrowserVncApplicationSCIMConfig", + "BrowserVncApplicationSCIMConfigAuthentication", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserVncApplicationSCIMConfigMapping", + "BrowserVncApplicationSCIMConfigMappingOperations", "AppLauncherApplication", "AppLauncherApplicationPolicy", "AppLauncherApplicationPolicyAccessAppPolicyLink", "AppLauncherApplicationPolicyUnionMember2", - "AppLauncherApplicationScimConfig", - "AppLauncherApplicationScimConfigAuthentication", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "AppLauncherApplicationScimConfigMapping", - "AppLauncherApplicationScimConfigMappingOperations", + "AppLauncherApplicationSCIMConfig", + "AppLauncherApplicationSCIMConfigAuthentication", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "AppLauncherApplicationSCIMConfigMapping", + "AppLauncherApplicationSCIMConfigMappingOperations", "DeviceEnrollmentPermissionsApplication", "DeviceEnrollmentPermissionsApplicationPolicy", "DeviceEnrollmentPermissionsApplicationPolicyAccessAppPolicyLink", "DeviceEnrollmentPermissionsApplicationPolicyUnionMember2", - "DeviceEnrollmentPermissionsApplicationScimConfig", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "DeviceEnrollmentPermissionsApplicationScimConfigMapping", - "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplicationSCIMConfig", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMapping", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations", "BrowserIsolationPermissionsApplication", "BrowserIsolationPermissionsApplicationPolicy", "BrowserIsolationPermissionsApplicationPolicyAccessAppPolicyLink", "BrowserIsolationPermissionsApplicationPolicyUnionMember2", - "BrowserIsolationPermissionsApplicationScimConfig", - "BrowserIsolationPermissionsApplicationScimConfigAuthentication", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserIsolationPermissionsApplicationScimConfigMapping", - "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplicationSCIMConfig", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthentication", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationSCIMConfigMapping", + "BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations", "BookmarkApplication", - "BookmarkApplicationScimConfig", - "BookmarkApplicationScimConfigAuthentication", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BookmarkApplicationScimConfigMapping", - "BookmarkApplicationScimConfigMappingOperations", + "BookmarkApplicationSCIMConfig", + "BookmarkApplicationSCIMConfigAuthentication", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BookmarkApplicationSCIMConfigMapping", + "BookmarkApplicationSCIMConfigMappingOperations", ] @@ -218,7 +218,7 @@ class SelfHostedApplication(TypedDict, total=False): attacks. """ - scim_config: SelfHostedApplicationScimConfig + scim_config: SelfHostedApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -327,7 +327,7 @@ class SelfHostedApplicationPolicyUnionMember2(TypedDict, total=False): ] -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -338,7 +338,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -348,7 +348,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -380,14 +380,14 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -SelfHostedApplicationScimConfigAuthentication = Union[ - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SelfHostedApplicationSCIMConfigAuthentication = Union[ + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SelfHostedApplicationScimConfigMappingOperations(TypedDict, total=False): +class SelfHostedApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -398,7 +398,7 @@ class SelfHostedApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SelfHostedApplicationScimConfigMapping(TypedDict, total=False): +class SelfHostedApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -412,7 +412,7 @@ class SelfHostedApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: SelfHostedApplicationScimConfigMappingOperations + operations: SelfHostedApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -422,7 +422,7 @@ class SelfHostedApplicationScimConfigMapping(TypedDict, total=False): """ -class SelfHostedApplicationScimConfig(TypedDict, total=False): +class SelfHostedApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -432,7 +432,7 @@ class SelfHostedApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: SelfHostedApplicationScimConfigAuthentication + authentication: SelfHostedApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -448,7 +448,7 @@ class SelfHostedApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[SelfHostedApplicationScimConfigMapping] + mappings: Iterable[SelfHostedApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -497,7 +497,7 @@ class SaaSApplication(TypedDict, total=False): saas_app: SaaSApplicationSaaSApp - scim_config: SaaSApplicationScimConfig + scim_config: SaaSApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -683,7 +683,7 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): SaaSApplicationSaaSApp = Union[SAMLSaaSAppParam, SaaSApplicationSaaSAppAccessOIDCSaaSApp] -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -694,7 +694,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPB """User name used to authenticate with the remote SCIM service.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(TypedDict, total=False): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(TypedDict, total=False): token: Required[str] """Token used to authenticate with the remote SCIM service.""" @@ -702,7 +702,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuth """The authentication scheme to use when making SCIM requests to this application.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -734,14 +734,14 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth """ -SaaSApplicationScimConfigAuthentication = Union[ - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SaaSApplicationSCIMConfigAuthentication = Union[ + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SaaSApplicationScimConfigMappingOperations(TypedDict, total=False): +class SaaSApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -752,7 +752,7 @@ class SaaSApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SaaSApplicationScimConfigMapping(TypedDict, total=False): +class SaaSApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -766,7 +766,7 @@ class SaaSApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: SaaSApplicationScimConfigMappingOperations + operations: SaaSApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -776,7 +776,7 @@ class SaaSApplicationScimConfigMapping(TypedDict, total=False): """ -class SaaSApplicationScimConfig(TypedDict, total=False): +class SaaSApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -786,7 +786,7 @@ class SaaSApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: SaaSApplicationScimConfigAuthentication + authentication: SaaSApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -802,7 +802,7 @@ class SaaSApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[SaaSApplicationScimConfigMapping] + mappings: Iterable[SaaSApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -917,7 +917,7 @@ class BrowserSSHApplication(TypedDict, total=False): attacks. """ - scim_config: BrowserSSHApplicationScimConfig + scim_config: BrowserSSHApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1026,7 +1026,7 @@ class BrowserSSHApplicationPolicyUnionMember2(TypedDict, total=False): ] -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -1037,7 +1037,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -1047,7 +1047,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -1079,14 +1079,14 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserSSHApplicationScimConfigAuthentication = Union[ - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserSSHApplicationSCIMConfigAuthentication = Union[ + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserSSHApplicationScimConfigMappingOperations(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -1097,7 +1097,7 @@ class BrowserSSHApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserSSHApplicationScimConfigMapping(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -1111,7 +1111,7 @@ class BrowserSSHApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: BrowserSSHApplicationScimConfigMappingOperations + operations: BrowserSSHApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -1121,7 +1121,7 @@ class BrowserSSHApplicationScimConfigMapping(TypedDict, total=False): """ -class BrowserSSHApplicationScimConfig(TypedDict, total=False): +class BrowserSSHApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1131,7 +1131,7 @@ class BrowserSSHApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: BrowserSSHApplicationScimConfigAuthentication + authentication: BrowserSSHApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1147,7 +1147,7 @@ class BrowserSSHApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[BrowserSSHApplicationScimConfigMapping] + mappings: Iterable[BrowserSSHApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1262,7 +1262,7 @@ class BrowserVncApplication(TypedDict, total=False): attacks. """ - scim_config: BrowserVncApplicationScimConfig + scim_config: BrowserVncApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1371,7 +1371,7 @@ class BrowserVncApplicationPolicyUnionMember2(TypedDict, total=False): ] -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -1382,7 +1382,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -1392,7 +1392,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -1424,14 +1424,14 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserVncApplicationScimConfigAuthentication = Union[ - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserVncApplicationSCIMConfigAuthentication = Union[ + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserVncApplicationScimConfigMappingOperations(TypedDict, total=False): +class BrowserVncApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -1442,7 +1442,7 @@ class BrowserVncApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserVncApplicationScimConfigMapping(TypedDict, total=False): +class BrowserVncApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -1456,7 +1456,7 @@ class BrowserVncApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: BrowserVncApplicationScimConfigMappingOperations + operations: BrowserVncApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -1466,7 +1466,7 @@ class BrowserVncApplicationScimConfigMapping(TypedDict, total=False): """ -class BrowserVncApplicationScimConfig(TypedDict, total=False): +class BrowserVncApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1476,7 +1476,7 @@ class BrowserVncApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: BrowserVncApplicationScimConfigAuthentication + authentication: BrowserVncApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1492,7 +1492,7 @@ class BrowserVncApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[BrowserVncApplicationScimConfigMapping] + mappings: Iterable[BrowserVncApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1530,7 +1530,7 @@ class AppLauncherApplication(TypedDict, total=False): exclusive to the application. """ - scim_config: AppLauncherApplicationScimConfig + scim_config: AppLauncherApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1624,7 +1624,7 @@ class AppLauncherApplicationPolicyUnionMember2(TypedDict, total=False): ] -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -1635,7 +1635,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """User name used to authenticate with the remote SCIM service.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -1645,7 +1645,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """The authentication scheme to use when making SCIM requests to this application.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -1677,14 +1677,14 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """ -AppLauncherApplicationScimConfigAuthentication = Union[ - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +AppLauncherApplicationSCIMConfigAuthentication = Union[ + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class AppLauncherApplicationScimConfigMappingOperations(TypedDict, total=False): +class AppLauncherApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -1695,7 +1695,7 @@ class AppLauncherApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class AppLauncherApplicationScimConfigMapping(TypedDict, total=False): +class AppLauncherApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -1709,7 +1709,7 @@ class AppLauncherApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: AppLauncherApplicationScimConfigMappingOperations + operations: AppLauncherApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -1719,7 +1719,7 @@ class AppLauncherApplicationScimConfigMapping(TypedDict, total=False): """ -class AppLauncherApplicationScimConfig(TypedDict, total=False): +class AppLauncherApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1729,7 +1729,7 @@ class AppLauncherApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: AppLauncherApplicationScimConfigAuthentication + authentication: AppLauncherApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1745,7 +1745,7 @@ class AppLauncherApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[AppLauncherApplicationScimConfigMapping] + mappings: Iterable[AppLauncherApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1783,7 +1783,7 @@ class DeviceEnrollmentPermissionsApplication(TypedDict, total=False): exclusive to the application. """ - scim_config: DeviceEnrollmentPermissionsApplicationScimConfig + scim_config: DeviceEnrollmentPermissionsApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1879,7 +1879,7 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2(TypedDict, total= ] -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic( TypedDict, total=False ): password: Required[str] @@ -1892,7 +1892,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -1902,7 +1902,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2( TypedDict, total=False ): authorization_url: Required[str] @@ -1936,14 +1936,14 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(TypedDict, total=False): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -1954,7 +1954,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(TypedDic """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class DeviceEnrollmentPermissionsApplicationScimConfigMapping(TypedDict, total=False): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -1968,7 +1968,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(TypedDict, total=F that matches resources that should be provisioned to this application. """ - operations: DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations + operations: DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -1978,7 +1978,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(TypedDict, total=F """ -class DeviceEnrollmentPermissionsApplicationScimConfig(TypedDict, total=False): +class DeviceEnrollmentPermissionsApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1988,7 +1988,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: DeviceEnrollmentPermissionsApplicationScimConfigAuthentication + authentication: DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2004,7 +2004,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[DeviceEnrollmentPermissionsApplicationScimConfigMapping] + mappings: Iterable[DeviceEnrollmentPermissionsApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2042,7 +2042,7 @@ class BrowserIsolationPermissionsApplication(TypedDict, total=False): exclusive to the application. """ - scim_config: BrowserIsolationPermissionsApplicationScimConfig + scim_config: BrowserIsolationPermissionsApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -2138,7 +2138,7 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2(TypedDict, total= ] -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic( TypedDict, total=False ): password: Required[str] @@ -2151,7 +2151,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( TypedDict, total=False ): token: Required[str] @@ -2161,7 +2161,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2( TypedDict, total=False ): authorization_url: Required[str] @@ -2195,14 +2195,14 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserIsolationPermissionsApplicationSCIMConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -2213,7 +2213,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(TypedDic """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserIsolationPermissionsApplicationScimConfigMapping(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -2227,7 +2227,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(TypedDict, total=F that matches resources that should be provisioned to this application. """ - operations: BrowserIsolationPermissionsApplicationScimConfigMappingOperations + operations: BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -2237,7 +2237,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(TypedDict, total=F """ -class BrowserIsolationPermissionsApplicationScimConfig(TypedDict, total=False): +class BrowserIsolationPermissionsApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2247,7 +2247,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: BrowserIsolationPermissionsApplicationScimConfigAuthentication + authentication: BrowserIsolationPermissionsApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2263,7 +2263,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[BrowserIsolationPermissionsApplicationScimConfigMapping] + mappings: Iterable[BrowserIsolationPermissionsApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2289,7 +2289,7 @@ class BookmarkApplication(TypedDict, total=False): name: str """The name of the application.""" - scim_config: BookmarkApplicationScimConfig + scim_config: BookmarkApplicationSCIMConfig """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -2305,7 +2305,7 @@ class BookmarkApplication(TypedDict, total=False): """The application type.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(TypedDict, total=False): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(TypedDict, total=False): password: Required[str] """Password used to authenticate with the remote SCIM service.""" @@ -2316,7 +2316,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationH """User name used to authenticate with the remote SCIM service.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(TypedDict, total=False): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(TypedDict, total=False): token: Required[str] """Token used to authenticate with the remote SCIM service.""" @@ -2324,7 +2324,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """The authentication scheme to use when making SCIM requests to this application.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(TypedDict, total=False): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(TypedDict, total=False): authorization_url: Required[str] """URL used to generate the auth code used during token generation.""" @@ -2356,14 +2356,14 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """ -BookmarkApplicationScimConfigAuthentication = Union[ - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BookmarkApplicationSCIMConfigAuthentication = Union[ + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BookmarkApplicationScimConfigMappingOperations(TypedDict, total=False): +class BookmarkApplicationSCIMConfigMappingOperations(TypedDict, total=False): create: bool """Whether or not this mapping applies to create (POST) operations.""" @@ -2374,7 +2374,7 @@ class BookmarkApplicationScimConfigMappingOperations(TypedDict, total=False): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BookmarkApplicationScimConfigMapping(TypedDict, total=False): +class BookmarkApplicationSCIMConfigMapping(TypedDict, total=False): schema: Required[str] """Which SCIM resource type this mapping applies to.""" @@ -2388,7 +2388,7 @@ class BookmarkApplicationScimConfigMapping(TypedDict, total=False): that matches resources that should be provisioned to this application. """ - operations: BookmarkApplicationScimConfigMappingOperations + operations: BookmarkApplicationSCIMConfigMappingOperations """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: str @@ -2398,7 +2398,7 @@ class BookmarkApplicationScimConfigMapping(TypedDict, total=False): """ -class BookmarkApplicationScimConfig(TypedDict, total=False): +class BookmarkApplicationSCIMConfig(TypedDict, total=False): idp_uid: Required[str] """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2408,7 +2408,7 @@ class BookmarkApplicationScimConfig(TypedDict, total=False): remote_uri: Required[str] """The base URI for the application's SCIM-compatible API.""" - authentication: BookmarkApplicationScimConfigAuthentication + authentication: BookmarkApplicationSCIMConfigAuthentication """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2424,7 +2424,7 @@ class BookmarkApplicationScimConfig(TypedDict, total=False): enabled: bool """Whether SCIM provisioning is turned on for this application.""" - mappings: Iterable[BookmarkApplicationScimConfigMapping] + mappings: Iterable[BookmarkApplicationSCIMConfigMapping] """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. diff --git a/src/cloudflare/types/zero_trust/access/application_update_response.py b/src/cloudflare/types/zero_trust/access/application_update_response.py index b0a4b129ca1..e7047407794 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_response.py +++ b/src/cloudflare/types/zero_trust/access/application_update_response.py @@ -20,13 +20,13 @@ "ApplicationUpdateResponse", "SelfHostedApplication", "SelfHostedApplicationPolicy", - "SelfHostedApplicationScimConfig", - "SelfHostedApplicationScimConfigAuthentication", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SelfHostedApplicationScimConfigMapping", - "SelfHostedApplicationScimConfigMappingOperations", + "SelfHostedApplicationSCIMConfig", + "SelfHostedApplicationSCIMConfigAuthentication", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SelfHostedApplicationSCIMConfigMapping", + "SelfHostedApplicationSCIMConfigMappingOperations", "SaaSApplication", "SaaSApplicationPolicy", "SaaSApplicationSaaSApp", @@ -35,66 +35,66 @@ "SaaSApplicationSaaSAppAccessOIDCSaaSAppCustomClaimsSource", "SaaSApplicationSaaSAppAccessOIDCSaaSAppHybridAndImplicitOptions", "SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions", - "SaaSApplicationScimConfig", - "SaaSApplicationScimConfigAuthentication", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "SaaSApplicationScimConfigMapping", - "SaaSApplicationScimConfigMappingOperations", + "SaaSApplicationSCIMConfig", + "SaaSApplicationSCIMConfigAuthentication", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "SaaSApplicationSCIMConfigMapping", + "SaaSApplicationSCIMConfigMappingOperations", "BrowserSSHApplication", "BrowserSSHApplicationPolicy", - "BrowserSSHApplicationScimConfig", - "BrowserSSHApplicationScimConfigAuthentication", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserSSHApplicationScimConfigMapping", - "BrowserSSHApplicationScimConfigMappingOperations", + "BrowserSSHApplicationSCIMConfig", + "BrowserSSHApplicationSCIMConfigAuthentication", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserSSHApplicationSCIMConfigMapping", + "BrowserSSHApplicationSCIMConfigMappingOperations", "BrowserVncApplication", "BrowserVncApplicationPolicy", - "BrowserVncApplicationScimConfig", - "BrowserVncApplicationScimConfigAuthentication", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserVncApplicationScimConfigMapping", - "BrowserVncApplicationScimConfigMappingOperations", + "BrowserVncApplicationSCIMConfig", + "BrowserVncApplicationSCIMConfigAuthentication", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserVncApplicationSCIMConfigMapping", + "BrowserVncApplicationSCIMConfigMappingOperations", "AppLauncherApplication", "AppLauncherApplicationPolicy", - "AppLauncherApplicationScimConfig", - "AppLauncherApplicationScimConfigAuthentication", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "AppLauncherApplicationScimConfigMapping", - "AppLauncherApplicationScimConfigMappingOperations", + "AppLauncherApplicationSCIMConfig", + "AppLauncherApplicationSCIMConfigAuthentication", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "AppLauncherApplicationSCIMConfigMapping", + "AppLauncherApplicationSCIMConfigMappingOperations", "DeviceEnrollmentPermissionsApplication", "DeviceEnrollmentPermissionsApplicationPolicy", - "DeviceEnrollmentPermissionsApplicationScimConfig", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthentication", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "DeviceEnrollmentPermissionsApplicationScimConfigMapping", - "DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations", + "DeviceEnrollmentPermissionsApplicationSCIMConfig", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMapping", + "DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations", "BrowserIsolationPermissionsApplication", "BrowserIsolationPermissionsApplicationPolicy", - "BrowserIsolationPermissionsApplicationScimConfig", - "BrowserIsolationPermissionsApplicationScimConfigAuthentication", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BrowserIsolationPermissionsApplicationScimConfigMapping", - "BrowserIsolationPermissionsApplicationScimConfigMappingOperations", + "BrowserIsolationPermissionsApplicationSCIMConfig", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthentication", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BrowserIsolationPermissionsApplicationSCIMConfigMapping", + "BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations", "BookmarkApplication", - "BookmarkApplicationScimConfig", - "BookmarkApplicationScimConfigAuthentication", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken", - "BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2", - "BookmarkApplicationScimConfigMapping", - "BookmarkApplicationScimConfigMappingOperations", + "BookmarkApplicationSCIMConfig", + "BookmarkApplicationSCIMConfigAuthentication", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken", + "BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2", + "BookmarkApplicationSCIMConfigMapping", + "BookmarkApplicationSCIMConfigMappingOperations", ] @@ -160,7 +160,7 @@ class SelfHostedApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -171,7 +171,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -179,7 +179,7 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -211,14 +211,14 @@ class SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -SelfHostedApplicationScimConfigAuthentication = Union[ - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SelfHostedApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SelfHostedApplicationSCIMConfigAuthentication = Union[ + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SelfHostedApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SelfHostedApplicationScimConfigMappingOperations(BaseModel): +class SelfHostedApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -229,7 +229,7 @@ class SelfHostedApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SelfHostedApplicationScimConfigMapping(BaseModel): +class SelfHostedApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -243,7 +243,7 @@ class SelfHostedApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[SelfHostedApplicationScimConfigMappingOperations] = None + operations: Optional[SelfHostedApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -253,7 +253,7 @@ class SelfHostedApplicationScimConfigMapping(BaseModel): """ -class SelfHostedApplicationScimConfig(BaseModel): +class SelfHostedApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -263,7 +263,7 @@ class SelfHostedApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[SelfHostedApplicationScimConfigAuthentication] = None + authentication: Optional[SelfHostedApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -279,7 +279,7 @@ class SelfHostedApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[SelfHostedApplicationScimConfigMapping]] = None + mappings: Optional[List[SelfHostedApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -391,7 +391,7 @@ class SelfHostedApplication(BaseModel): attacks. """ - scim_config: Optional[SelfHostedApplicationScimConfig] = None + scim_config: Optional[SelfHostedApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -580,7 +580,7 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): SaaSApplicationSaaSApp = Union[SAMLSaaSApp, SaaSApplicationSaaSAppAccessOIDCSaaSApp] -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -591,7 +591,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPB """User name used to authenticate with the remote SCIM service.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -599,7 +599,7 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuth """The authentication scheme to use when making SCIM requests to this application.""" -class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -631,14 +631,14 @@ class SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth """ -SaaSApplicationScimConfigAuthentication = Union[ - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - SaaSApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +SaaSApplicationSCIMConfigAuthentication = Union[ + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + SaaSApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class SaaSApplicationScimConfigMappingOperations(BaseModel): +class SaaSApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -649,7 +649,7 @@ class SaaSApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class SaaSApplicationScimConfigMapping(BaseModel): +class SaaSApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -663,7 +663,7 @@ class SaaSApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[SaaSApplicationScimConfigMappingOperations] = None + operations: Optional[SaaSApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -673,7 +673,7 @@ class SaaSApplicationScimConfigMapping(BaseModel): """ -class SaaSApplicationScimConfig(BaseModel): +class SaaSApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -683,7 +683,7 @@ class SaaSApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[SaaSApplicationScimConfigAuthentication] = None + authentication: Optional[SaaSApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -699,7 +699,7 @@ class SaaSApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[SaaSApplicationScimConfigMapping]] = None + mappings: Optional[List[SaaSApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -745,7 +745,7 @@ class SaaSApplication(BaseModel): saas_app: Optional[SaaSApplicationSaaSApp] = None - scim_config: Optional[SaaSApplicationScimConfig] = None + scim_config: Optional[SaaSApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -825,7 +825,7 @@ class BrowserSSHApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -836,7 +836,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -844,7 +844,7 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -876,14 +876,14 @@ class BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserSSHApplicationScimConfigAuthentication = Union[ - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserSSHApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserSSHApplicationSCIMConfigAuthentication = Union[ + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserSSHApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): +class BrowserSSHApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -894,7 +894,7 @@ class BrowserSSHApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserSSHApplicationScimConfigMapping(BaseModel): +class BrowserSSHApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -908,7 +908,7 @@ class BrowserSSHApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserSSHApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserSSHApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -918,7 +918,7 @@ class BrowserSSHApplicationScimConfigMapping(BaseModel): """ -class BrowserSSHApplicationScimConfig(BaseModel): +class BrowserSSHApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -928,7 +928,7 @@ class BrowserSSHApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserSSHApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserSSHApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -944,7 +944,7 @@ class BrowserSSHApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserSSHApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserSSHApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1056,7 +1056,7 @@ class BrowserSSHApplication(BaseModel): attacks. """ - scim_config: Optional[BrowserSSHApplicationScimConfig] = None + scim_config: Optional[BrowserSSHApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1149,7 +1149,7 @@ class BrowserVncApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1160,7 +1160,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """User name used to authenticate with the remote SCIM service.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -1168,7 +1168,7 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1200,14 +1200,14 @@ class BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticatio """ -BrowserVncApplicationScimConfigAuthentication = Union[ - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserVncApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserVncApplicationSCIMConfigAuthentication = Union[ + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserVncApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserVncApplicationScimConfigMappingOperations(BaseModel): +class BrowserVncApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1218,7 +1218,7 @@ class BrowserVncApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserVncApplicationScimConfigMapping(BaseModel): +class BrowserVncApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1232,7 +1232,7 @@ class BrowserVncApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserVncApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserVncApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1242,7 +1242,7 @@ class BrowserVncApplicationScimConfigMapping(BaseModel): """ -class BrowserVncApplicationScimConfig(BaseModel): +class BrowserVncApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1252,7 +1252,7 @@ class BrowserVncApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserVncApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserVncApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1268,7 +1268,7 @@ class BrowserVncApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserVncApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserVncApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1380,7 +1380,7 @@ class BrowserVncApplication(BaseModel): attacks. """ - scim_config: Optional[BrowserVncApplicationScimConfig] = None + scim_config: Optional[BrowserVncApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1473,7 +1473,7 @@ class AppLauncherApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1484,7 +1484,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """User name used to authenticate with the remote SCIM service.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -1492,7 +1492,7 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """The authentication scheme to use when making SCIM requests to this application.""" -class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1524,14 +1524,14 @@ class AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticati """ -AppLauncherApplicationScimConfigAuthentication = Union[ - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - AppLauncherApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +AppLauncherApplicationSCIMConfigAuthentication = Union[ + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + AppLauncherApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class AppLauncherApplicationScimConfigMappingOperations(BaseModel): +class AppLauncherApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1542,7 +1542,7 @@ class AppLauncherApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class AppLauncherApplicationScimConfigMapping(BaseModel): +class AppLauncherApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1556,7 +1556,7 @@ class AppLauncherApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[AppLauncherApplicationScimConfigMappingOperations] = None + operations: Optional[AppLauncherApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1566,7 +1566,7 @@ class AppLauncherApplicationScimConfigMapping(BaseModel): """ -class AppLauncherApplicationScimConfig(BaseModel): +class AppLauncherApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1576,7 +1576,7 @@ class AppLauncherApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[AppLauncherApplicationScimConfigAuthentication] = None + authentication: Optional[AppLauncherApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1592,7 +1592,7 @@ class AppLauncherApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[AppLauncherApplicationScimConfigMapping]] = None + mappings: Optional[List[AppLauncherApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1637,7 +1637,7 @@ class AppLauncherApplication(BaseModel): policies: Optional[List[AppLauncherApplicationPolicy]] = None - scim_config: Optional[AppLauncherApplicationScimConfig] = None + scim_config: Optional[AppLauncherApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1715,7 +1715,7 @@ class DeviceEnrollmentPermissionsApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1726,7 +1726,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( BaseModel ): token: str @@ -1736,7 +1736,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -1768,14 +1768,14 @@ class DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -DeviceEnrollmentPermissionsApplicationScimConfigAuthentication = Union[ - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - DeviceEnrollmentPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication = Union[ + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + DeviceEnrollmentPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -1786,7 +1786,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations(BaseMode """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -1800,7 +1800,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[DeviceEnrollmentPermissionsApplicationScimConfigMappingOperations] = None + operations: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -1810,7 +1810,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfigMapping(BaseModel): """ -class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): +class DeviceEnrollmentPermissionsApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -1820,7 +1820,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[DeviceEnrollmentPermissionsApplicationScimConfigAuthentication] = None + authentication: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -1836,7 +1836,7 @@ class DeviceEnrollmentPermissionsApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[DeviceEnrollmentPermissionsApplicationScimConfigMapping]] = None + mappings: Optional[List[DeviceEnrollmentPermissionsApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -1881,7 +1881,7 @@ class DeviceEnrollmentPermissionsApplication(BaseModel): policies: Optional[List[DeviceEnrollmentPermissionsApplicationPolicy]] = None - scim_config: Optional[DeviceEnrollmentPermissionsApplicationScimConfig] = None + scim_config: Optional[DeviceEnrollmentPermissionsApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -1959,7 +1959,7 @@ class BrowserIsolationPermissionsApplicationPolicy(BaseModel): updated_at: Optional[datetime] = None -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -1970,7 +1970,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """User name used to authenticate with the remote SCIM service.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken( +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken( BaseModel ): token: str @@ -1980,7 +1980,7 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """The authentication scheme to use when making SCIM requests to this application.""" -class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -2012,14 +2012,14 @@ class BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimCo """ -BrowserIsolationPermissionsApplicationScimConfigAuthentication = Union[ - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BrowserIsolationPermissionsApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BrowserIsolationPermissionsApplicationSCIMConfigAuthentication = Union[ + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BrowserIsolationPermissionsApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -2030,7 +2030,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMappingOperations(BaseMode """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -2044,7 +2044,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BrowserIsolationPermissionsApplicationScimConfigMappingOperations] = None + operations: Optional[BrowserIsolationPermissionsApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -2054,7 +2054,7 @@ class BrowserIsolationPermissionsApplicationScimConfigMapping(BaseModel): """ -class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): +class BrowserIsolationPermissionsApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2064,7 +2064,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BrowserIsolationPermissionsApplicationScimConfigAuthentication] = None + authentication: Optional[BrowserIsolationPermissionsApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2080,7 +2080,7 @@ class BrowserIsolationPermissionsApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BrowserIsolationPermissionsApplicationScimConfigMapping]] = None + mappings: Optional[List[BrowserIsolationPermissionsApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2125,7 +2125,7 @@ class BrowserIsolationPermissionsApplication(BaseModel): policies: Optional[List[BrowserIsolationPermissionsApplicationPolicy]] = None - scim_config: Optional[BrowserIsolationPermissionsApplicationScimConfig] = None + scim_config: Optional[BrowserIsolationPermissionsApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. @@ -2141,7 +2141,7 @@ class BrowserIsolationPermissionsApplication(BaseModel): updated_at: Optional[datetime] = None -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic(BaseModel): password: str """Password used to authenticate with the remote SCIM service.""" @@ -2152,7 +2152,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationH """User name used to authenticate with the remote SCIM service.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken(BaseModel): token: str """Token used to authenticate with the remote SCIM service.""" @@ -2160,7 +2160,7 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """The authentication scheme to use when making SCIM requests to this application.""" -class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2(BaseModel): +class BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2(BaseModel): authorization_url: str """URL used to generate the auth code used during token generation.""" @@ -2192,14 +2192,14 @@ class BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationO """ -BookmarkApplicationScimConfigAuthentication = Union[ - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationHTTPBasic, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOAuthBearerToken, - BookmarkApplicationScimConfigAuthenticationAccessScimConfigAuthenticationOauth2, +BookmarkApplicationSCIMConfigAuthentication = Union[ + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationHTTPBasic, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOAuthBearerToken, + BookmarkApplicationSCIMConfigAuthenticationAccessSCIMConfigAuthenticationOauth2, ] -class BookmarkApplicationScimConfigMappingOperations(BaseModel): +class BookmarkApplicationSCIMConfigMappingOperations(BaseModel): create: Optional[bool] = None """Whether or not this mapping applies to create (POST) operations.""" @@ -2210,7 +2210,7 @@ class BookmarkApplicationScimConfigMappingOperations(BaseModel): """Whether or not this mapping applies to update (PATCH/PUT) operations.""" -class BookmarkApplicationScimConfigMapping(BaseModel): +class BookmarkApplicationSCIMConfigMapping(BaseModel): schema_: str = FieldInfo(alias="schema") """Which SCIM resource type this mapping applies to.""" @@ -2224,7 +2224,7 @@ class BookmarkApplicationScimConfigMapping(BaseModel): that matches resources that should be provisioned to this application. """ - operations: Optional[BookmarkApplicationScimConfigMappingOperations] = None + operations: Optional[BookmarkApplicationSCIMConfigMappingOperations] = None """Whether or not this mapping applies to creates, updates, or deletes.""" transform_jsonata: Optional[str] = None @@ -2234,7 +2234,7 @@ class BookmarkApplicationScimConfigMapping(BaseModel): """ -class BookmarkApplicationScimConfig(BaseModel): +class BookmarkApplicationSCIMConfig(BaseModel): idp_uid: str """ The UID of the IdP to use as the source for SCIM resources to provision to this @@ -2244,7 +2244,7 @@ class BookmarkApplicationScimConfig(BaseModel): remote_uri: str """The base URI for the application's SCIM-compatible API.""" - authentication: Optional[BookmarkApplicationScimConfigAuthentication] = None + authentication: Optional[BookmarkApplicationSCIMConfigAuthentication] = None """ Attributes for configuring HTTP Basic authentication scheme for SCIM provisioning to an application. @@ -2260,7 +2260,7 @@ class BookmarkApplicationScimConfig(BaseModel): enabled: Optional[bool] = None """Whether SCIM provisioning is turned on for this application.""" - mappings: Optional[List[BookmarkApplicationScimConfigMapping]] = None + mappings: Optional[List[BookmarkApplicationSCIMConfigMapping]] = None """ A list of mappings to apply to SCIM resources before provisioning them in this application. These can transform or filter the resources to be provisioned. @@ -2288,7 +2288,7 @@ class BookmarkApplication(BaseModel): name: Optional[str] = None """The name of the application.""" - scim_config: Optional[BookmarkApplicationScimConfig] = None + scim_config: Optional[BookmarkApplicationSCIMConfig] = None """Configuration for provisioning to this application via SCIM. This is currently in closed beta. diff --git a/src/cloudflare/types/zero_trust/azure_ad.py b/src/cloudflare/types/zero_trust/azure_ad.py index 2d8690b282a..6b09f2c0581 100644 --- a/src/cloudflare/types/zero_trust/azure_ad.py +++ b/src/cloudflare/types/zero_trust/azure_ad.py @@ -4,7 +4,7 @@ from typing_extensions import Literal from ..._models import BaseModel -from .scim_config import ScimConfig +from .scim_config import SCIMConfig from .identity_provider_type import IdentityProviderType __all__ = ["AzureAD", "Config"] @@ -67,7 +67,7 @@ class AzureAD(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. diff --git a/src/cloudflare/types/zero_trust/identity_provider.py b/src/cloudflare/types/zero_trust/identity_provider.py index 6731d7bc439..6820dd7db58 100644 --- a/src/cloudflare/types/zero_trust/identity_provider.py +++ b/src/cloudflare/types/zero_trust/identity_provider.py @@ -4,7 +4,7 @@ from .azure_ad import AzureAD from ..._models import BaseModel -from .scim_config import ScimConfig +from .scim_config import SCIMConfig from .generic_oauth_config import GenericOAuthConfig from .identity_provider_type import IdentityProviderType @@ -76,7 +76,7 @@ class AccessCentrify(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -104,7 +104,7 @@ class AccessFacebook(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -132,7 +132,7 @@ class AccessGitHub(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -174,7 +174,7 @@ class AccessGoogle(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -219,7 +219,7 @@ class AccessGoogleApps(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -247,7 +247,7 @@ class AccessLinkedin(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -301,7 +301,7 @@ class AccessOIDC(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -349,7 +349,7 @@ class AccessOkta(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -394,7 +394,7 @@ class AccessOnelogin(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -439,7 +439,7 @@ class AccessPingone(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -507,7 +507,7 @@ class AccessSAML(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -535,7 +535,7 @@ class AccessYandex(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -563,7 +563,7 @@ class AccessOnetimepin(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. diff --git a/src/cloudflare/types/zero_trust/identity_provider_create_params.py b/src/cloudflare/types/zero_trust/identity_provider_create_params.py index 907f7124fdb..2e8ddbc3ac4 100644 --- a/src/cloudflare/types/zero_trust/identity_provider_create_params.py +++ b/src/cloudflare/types/zero_trust/identity_provider_create_params.py @@ -5,7 +5,7 @@ from typing import List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -from .scim_config_param import ScimConfigParam +from .scim_config_param import SCIMConfigParam from .identity_provider_type import IdentityProviderType from .generic_oauth_config_param import GenericOAuthConfigParam @@ -62,7 +62,7 @@ class AzureAD(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -129,7 +129,7 @@ class AccessCentrify(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -180,7 +180,7 @@ class AccessFacebook(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -211,7 +211,7 @@ class AccessGitHub(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -242,7 +242,7 @@ class AccessGoogle(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -287,7 +287,7 @@ class AccessGoogleApps(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -335,7 +335,7 @@ class AccessLinkedin(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -366,7 +366,7 @@ class AccessOIDC(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -423,7 +423,7 @@ class AccessOkta(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -474,7 +474,7 @@ class AccessOnelogin(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -522,7 +522,7 @@ class AccessPingone(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -570,7 +570,7 @@ class AccessSAML(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -641,7 +641,7 @@ class AccessYandex(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -672,7 +672,7 @@ class AccessOnetimepin(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. diff --git a/src/cloudflare/types/zero_trust/identity_provider_list_response.py b/src/cloudflare/types/zero_trust/identity_provider_list_response.py index 7fe980dcac8..59761e96afa 100644 --- a/src/cloudflare/types/zero_trust/identity_provider_list_response.py +++ b/src/cloudflare/types/zero_trust/identity_provider_list_response.py @@ -4,7 +4,7 @@ from .azure_ad import AzureAD from ..._models import BaseModel -from .scim_config import ScimConfig +from .scim_config import SCIMConfig from .generic_oauth_config import GenericOAuthConfig from .identity_provider_type import IdentityProviderType @@ -75,7 +75,7 @@ class AccessCentrify(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -103,7 +103,7 @@ class AccessFacebook(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -131,7 +131,7 @@ class AccessGitHub(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -173,7 +173,7 @@ class AccessGoogle(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -218,7 +218,7 @@ class AccessGoogleApps(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -246,7 +246,7 @@ class AccessLinkedin(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -300,7 +300,7 @@ class AccessOIDC(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -348,7 +348,7 @@ class AccessOkta(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -393,7 +393,7 @@ class AccessOnelogin(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -438,7 +438,7 @@ class AccessPingone(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -506,7 +506,7 @@ class AccessSAML(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -534,7 +534,7 @@ class AccessYandex(BaseModel): id: Optional[str] = None """UUID""" - scim_config: Optional[ScimConfig] = None + scim_config: Optional[SCIMConfig] = None """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. diff --git a/src/cloudflare/types/zero_trust/identity_provider_update_params.py b/src/cloudflare/types/zero_trust/identity_provider_update_params.py index 9667f9f04ba..5507de7fdbd 100644 --- a/src/cloudflare/types/zero_trust/identity_provider_update_params.py +++ b/src/cloudflare/types/zero_trust/identity_provider_update_params.py @@ -5,7 +5,7 @@ from typing import List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -from .scim_config_param import ScimConfigParam +from .scim_config_param import SCIMConfigParam from .identity_provider_type import IdentityProviderType from .generic_oauth_config_param import GenericOAuthConfigParam @@ -62,7 +62,7 @@ class AzureAD(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -129,7 +129,7 @@ class AccessCentrify(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -180,7 +180,7 @@ class AccessFacebook(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -211,7 +211,7 @@ class AccessGitHub(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -242,7 +242,7 @@ class AccessGoogle(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -287,7 +287,7 @@ class AccessGoogleApps(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -335,7 +335,7 @@ class AccessLinkedin(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -366,7 +366,7 @@ class AccessOIDC(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -423,7 +423,7 @@ class AccessOkta(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -474,7 +474,7 @@ class AccessOnelogin(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -522,7 +522,7 @@ class AccessPingone(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -570,7 +570,7 @@ class AccessSAML(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -641,7 +641,7 @@ class AccessYandex(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. @@ -672,7 +672,7 @@ class AccessOnetimepin(TypedDict, total=False): zone_id: str """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - scim_config: ScimConfigParam + scim_config: SCIMConfigParam """ The configuration settings for enabling a System for Cross-Domain Identity Management (SCIM) with the identity provider. diff --git a/src/cloudflare/types/zero_trust/scim_config.py b/src/cloudflare/types/zero_trust/scim_config.py index f7f9f993662..625b2f12655 100644 --- a/src/cloudflare/types/zero_trust/scim_config.py +++ b/src/cloudflare/types/zero_trust/scim_config.py @@ -4,10 +4,10 @@ from ..._models import BaseModel -__all__ = ["ScimConfig"] +__all__ = ["SCIMConfig"] -class ScimConfig(BaseModel): +class SCIMConfig(BaseModel): enabled: Optional[bool] = None """A flag to enable or disable SCIM for the identity provider.""" diff --git a/src/cloudflare/types/zero_trust/scim_config_param.py b/src/cloudflare/types/zero_trust/scim_config_param.py index 2ae697d9a43..255b6cebe87 100644 --- a/src/cloudflare/types/zero_trust/scim_config_param.py +++ b/src/cloudflare/types/zero_trust/scim_config_param.py @@ -4,10 +4,10 @@ from typing_extensions import TypedDict -__all__ = ["ScimConfigParam"] +__all__ = ["SCIMConfigParam"] -class ScimConfigParam(TypedDict, total=False): +class SCIMConfigParam(TypedDict, total=False): enabled: bool """A flag to enable or disable SCIM for the identity provider.""" From 9c81cdaaa7a8d3d2b3e9c0d237a5f777ebeb804a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:27:09 +0000 Subject: [PATCH 383/532] feat(api): OpenAPI spec update via Stainless API (#864) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 563ec8b4af0..b68b9a715de 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-efdb1c15faba015f2904e7db0946e71b5bd84a6e4b96256aed210e7e0113cf17.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dd6f560da6eb9ae8d43a6fd37d706e939ef20c6cca15655adc5dc821fa2fd19f.yml From eafefcd3485bc7c932fa4a30c8cb9d3bb09f5517 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:29:26 +0000 Subject: [PATCH 384/532] feat(api): OpenAPI spec update via Stainless API (#865) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b68b9a715de..e43120fc0b0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dd6f560da6eb9ae8d43a6fd37d706e939ef20c6cca15655adc5dc821fa2fd19f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7d5c5ef81ab6fb46d0069fbaee2804fb9260e09c325145e407c67613ba76732f.yml From 4f83a03df2bc9160476e97c98837a6d3cae01f1b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 06:16:12 +0000 Subject: [PATCH 385/532] feat(api): OpenAPI spec update via Stainless API (#866) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e43120fc0b0..b68b9a715de 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7d5c5ef81ab6fb46d0069fbaee2804fb9260e09c325145e407c67613ba76732f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dd6f560da6eb9ae8d43a6fd37d706e939ef20c6cca15655adc5dc821fa2fd19f.yml From 09f9f1f6f4572b35eb043f85cd2d2edca8e2dd47 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 06:18:18 +0000 Subject: [PATCH 386/532] feat(api): OpenAPI spec update via Stainless API (#867) --- .stats.yml | 2 +- src/cloudflare/resources/accounts/members.py | 229 +--- .../types/accounts/member_create_params.py | 49 +- .../types/accounts/member_update_params.py | 51 +- tests/api_resources/accounts/test_members.py | 1006 +---------------- 5 files changed, 35 insertions(+), 1302 deletions(-) diff --git a/.stats.yml b/.stats.yml index b68b9a715de..ddeeffb5d02 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-dd6f560da6eb9ae8d43a6fd37d706e939ef20c6cca15655adc5dc821fa2fd19f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-90de7c383d660ce2dd1c4dfa53b4c75ef8c4c37d485f16f9cc2da269d4852095.yml diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index a36881ed695..642cb60d058 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -2,14 +2,13 @@ from __future__ import annotations -from typing import Any, List, Type, Iterable, Optional, cast, overload +from typing import Any, List, Type, Iterable, Optional, cast from typing_extensions import Literal import httpx from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import ( - required_args, maybe_transform, async_maybe_transform, ) @@ -46,7 +45,6 @@ def with_raw_response(self) -> MembersResourceWithRawResponse: def with_streaming_response(self) -> MembersResourceWithStreamingResponse: return MembersResourceWithStreamingResponse(self) - @overload def create( self, *, @@ -77,57 +75,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - ... - - @overload - def create( - self, - *, - account_id: str, - email: str, - policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], - status: Literal["accepted", "pending"] | 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, - ) -> MemberCreateResponse: - """ - Add a user to the list of members for this account. - - Args: - email: The contact email address of the user. - - policies: Array of policies associated with this member. - - 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 - """ - ... - - @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) - def create( - self, - *, - account_id: str, - email: str, - roles: List[str] | NotGiven = NOT_GIVEN, - status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, - policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | 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, - ) -> MemberCreateResponse: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( @@ -139,7 +86,6 @@ def create( "email": email, "roles": roles, "status": status, - "policies": policies, }, member_create_params.MemberCreateParams, ), @@ -152,13 +98,12 @@ def create( ), ) - @overload def update( self, member_id: str, *, account_id: str, - roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + roles: Iterable[member_update_params.Role] | 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, @@ -182,55 +127,6 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ - ... - - @overload - def update( - self, - member_id: str, - *, - account_id: str, - policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], - # 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, - ) -> MemberUpdateResponse: - """ - Modify an account member. - - Args: - member_id: Membership identifier tag. - - policies: Array of policies associated with this member. - - 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 - """ - ... - - @required_args(["account_id"], ["account_id", "policies"]) - def update( - self, - member_id: str, - *, - account_id: str, - roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, - policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | 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, - ) -> MemberUpdateResponse: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: @@ -239,13 +135,7 @@ def update( MemberUpdateResponse, self._put( f"/accounts/{account_id}/members/{member_id}", - body=maybe_transform( - { - "roles": roles, - "policies": policies, - }, - member_update_params.MemberUpdateParams, - ), + body=maybe_transform({"roles": roles}, member_update_params.MemberUpdateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -410,7 +300,6 @@ def with_raw_response(self) -> AsyncMembersResourceWithRawResponse: def with_streaming_response(self) -> AsyncMembersResourceWithStreamingResponse: return AsyncMembersResourceWithStreamingResponse(self) - @overload async def create( self, *, @@ -441,57 +330,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - ... - - @overload - async def create( - self, - *, - account_id: str, - email: str, - policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], - status: Literal["accepted", "pending"] | 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, - ) -> MemberCreateResponse: - """ - Add a user to the list of members for this account. - - Args: - email: The contact email address of the user. - - policies: Array of policies associated with this member. - - 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 - """ - ... - - @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) - async def create( - self, - *, - account_id: str, - email: str, - roles: List[str] | NotGiven = NOT_GIVEN, - status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, - policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | 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, - ) -> MemberCreateResponse: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return cast( @@ -503,7 +341,6 @@ async def create( "email": email, "roles": roles, "status": status, - "policies": policies, }, member_create_params.MemberCreateParams, ), @@ -516,13 +353,12 @@ async def create( ), ) - @overload async def update( self, member_id: str, *, account_id: str, - roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + roles: Iterable[member_update_params.Role] | 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, @@ -546,55 +382,6 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ - ... - - @overload - async def update( - self, - member_id: str, - *, - account_id: str, - policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], - # 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, - ) -> MemberUpdateResponse: - """ - Modify an account member. - - Args: - member_id: Membership identifier tag. - - policies: Array of policies associated with this member. - - 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 - """ - ... - - @required_args(["account_id"], ["account_id", "policies"]) - async def update( - self, - member_id: str, - *, - account_id: str, - roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, - policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | 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, - ) -> MemberUpdateResponse: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: @@ -603,13 +390,7 @@ async def update( MemberUpdateResponse, await self._put( f"/accounts/{account_id}/members/{member_id}", - body=await async_maybe_transform( - { - "roles": roles, - "policies": policies, - }, - member_update_params.MemberUpdateParams, - ), + body=await async_maybe_transform({"roles": roles}, member_update_params.MemberUpdateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/cloudflare/types/accounts/member_create_params.py b/src/cloudflare/types/accounts/member_create_params.py index 8706522e855..69acda8f5da 100644 --- a/src/cloudflare/types/accounts/member_create_params.py +++ b/src/cloudflare/types/accounts/member_create_params.py @@ -2,20 +2,13 @@ from __future__ import annotations -from typing import List, Union, Iterable +from typing import List from typing_extensions import Literal, Required, TypedDict -__all__ = [ - "MemberCreateParams", - "IamCreateMemberWithRoles", - "IamCreateMemberWithPolicies", - "IamCreateMemberWithPoliciesPolicy", - "IamCreateMemberWithPoliciesPolicyPermissionGroup", - "IamCreateMemberWithPoliciesPolicyResourceGroup", -] +__all__ = ["MemberCreateParams"] -class IamCreateMemberWithRoles(TypedDict, total=False): +class MemberCreateParams(TypedDict, total=False): account_id: Required[str] email: Required[str] @@ -25,39 +18,3 @@ class IamCreateMemberWithRoles(TypedDict, total=False): """Array of roles associated with this member.""" status: Literal["accepted", "pending"] - - -class IamCreateMemberWithPolicies(TypedDict, total=False): - account_id: Required[str] - - email: Required[str] - """The contact email address of the user.""" - - policies: Required[Iterable[IamCreateMemberWithPoliciesPolicy]] - """Array of policies associated with this member.""" - - status: Literal["accepted", "pending"] - - -class IamCreateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): - id: Required[str] - """Identifier of the group.""" - - -class IamCreateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): - id: Required[str] - """Identifier of the group.""" - - -class IamCreateMemberWithPoliciesPolicy(TypedDict, total=False): - access: Required[Literal["allow", "deny"]] - """Allow or deny operations against the resources.""" - - permission_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyPermissionGroup]] - """A set of permission groups that are specified to the policy.""" - - resource_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyResourceGroup]] - """A list of resource groups that the policy applies to.""" - - -MemberCreateParams = Union[IamCreateMemberWithRoles, IamCreateMemberWithPolicies] diff --git a/src/cloudflare/types/accounts/member_update_params.py b/src/cloudflare/types/accounts/member_update_params.py index 851713903c8..66b3ee3cbac 100644 --- a/src/cloudflare/types/accounts/member_update_params.py +++ b/src/cloudflare/types/accounts/member_update_params.py @@ -2,58 +2,19 @@ from __future__ import annotations -from typing import Union, Iterable -from typing_extensions import Literal, Required, TypedDict +from typing import Iterable +from typing_extensions import Required, TypedDict -__all__ = [ - "MemberUpdateParams", - "Member", - "MemberRole", - "IamUpdateMemberWithPolicies", - "IamUpdateMemberWithPoliciesPolicy", - "IamUpdateMemberWithPoliciesPolicyPermissionGroup", - "IamUpdateMemberWithPoliciesPolicyResourceGroup", -] +__all__ = ["MemberUpdateParams", "Role"] -class Member(TypedDict, total=False): +class MemberUpdateParams(TypedDict, total=False): account_id: Required[str] - roles: Iterable[MemberRole] + roles: Iterable[Role] """Roles assigned to this member.""" -class MemberRole(TypedDict, total=False): +class Role(TypedDict, total=False): id: Required[str] """Role identifier tag.""" - - -class IamUpdateMemberWithPolicies(TypedDict, total=False): - account_id: Required[str] - - policies: Required[Iterable[IamUpdateMemberWithPoliciesPolicy]] - """Array of policies associated with this member.""" - - -class IamUpdateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): - id: Required[str] - """Identifier of the group.""" - - -class IamUpdateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): - id: Required[str] - """Identifier of the group.""" - - -class IamUpdateMemberWithPoliciesPolicy(TypedDict, total=False): - access: Required[Literal["allow", "deny"]] - """Allow or deny operations against the resources.""" - - permission_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyPermissionGroup]] - """A set of permission groups that are specified to the policy.""" - - resource_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyResourceGroup]] - """A list of resource groups that the policy applies to.""" - - -MemberUpdateParams = Union[Member, IamUpdateMemberWithPolicies] diff --git a/tests/api_resources/accounts/test_members.py b/tests/api_resources/accounts/test_members.py index 05cb40faa08..c1062178a50 100644 --- a/tests/api_resources/accounts/test_members.py +++ b/tests/api_resources/accounts/test_members.py @@ -25,7 +25,7 @@ class TestMembers: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - def test_method_create_overload_1(self, client: Cloudflare) -> None: + def test_method_create(self, client: Cloudflare) -> None: member = client.accounts.members.create( account_id="string", email="user@example.com", @@ -38,7 +38,7 @@ def test_method_create_overload_1(self, client: Cloudflare) -> None: assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> None: + def test_method_create_with_all_params(self, client: Cloudflare) -> None: member = client.accounts.members.create( account_id="string", email="user@example.com", @@ -52,7 +52,7 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: + def test_raw_response_create(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.create( account_id="string", email="user@example.com", @@ -69,7 +69,7 @@ def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: + def test_streaming_response_create(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.create( account_id="string", email="user@example.com", @@ -88,7 +88,7 @@ def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True @parametrize - def test_path_params_create_overload_1(self, client: Cloudflare) -> None: + 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.accounts.members.with_raw_response.create( account_id="", @@ -100,250 +100,9 @@ def test_path_params_create_overload_1(self, client: Cloudflare) -> None: ], ) - @parametrize - def test_method_create_overload_2(self, client: Cloudflare) -> None: - member = client.accounts.members.create( - account_id="string", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) - - @parametrize - def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> None: - member = client.accounts.members.create( - account_id="string", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - status="accepted", - ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) - - @parametrize - def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: - response = client.accounts.members.with_raw_response.create( - account_id="string", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - member = response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) - - @parametrize - def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: - with client.accounts.members.with_streaming_response.create( - account_id="string", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - member = response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create_overload_2(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.accounts.members.with_raw_response.create( - account_id="", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_update_overload_1(self, client: Cloudflare) -> None: + def test_method_update(self, client: Cloudflare) -> None: member = client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", @@ -352,7 +111,7 @@ def test_method_update_overload_1(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None: + def test_method_update_with_all_params(self, client: Cloudflare) -> None: member = client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", @@ -366,138 +125,10 @@ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> N @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: - response = client.accounts.members.with_raw_response.update( - "4536bcfad5faccb111b47003c79917fa", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - member = response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: - with client.accounts.members.with_streaming_response.update( - "4536bcfad5faccb111b47003c79917fa", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - member = response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update_overload_1(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.accounts.members.with_raw_response.update( - "4536bcfad5faccb111b47003c79917fa", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): - client.accounts.members.with_raw_response.update( - "", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_overload_2(self, client: Cloudflare) -> None: - member = client.accounts.members.update( - "4536bcfad5faccb111b47003c79917fa", - account_id="string", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + def test_raw_response_update(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], ) assert response.is_closed is True @@ -507,48 +138,10 @@ def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + def test_streaming_response_update(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -560,93 +153,17 @@ def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + 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.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): client.accounts.members.with_raw_response.update( "", account_id="string", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], ) @parametrize @@ -800,7 +317,7 @@ class TestAsyncMembers: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_create(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( account_id="string", email="user@example.com", @@ -813,7 +330,7 @@ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( account_id="string", email="user@example.com", @@ -827,7 +344,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.create( account_id="string", email="user@example.com", @@ -844,7 +361,7 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar assert_matches_type(MemberCreateResponse, member, path=["response"]) @parametrize - async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.create( account_id="string", email="user@example.com", @@ -863,7 +380,7 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + 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.accounts.members.with_raw_response.create( account_id="", @@ -875,250 +392,9 @@ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare ], ) - @parametrize - async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: - member = await async_client.accounts.members.create( - account_id="string", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) - - @parametrize - async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: - member = await async_client.accounts.members.create( - account_id="string", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - status="accepted", - ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) - - @parametrize - async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.accounts.members.with_raw_response.create( - account_id="string", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - member = await response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) - - @parametrize - async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.accounts.members.with_streaming_response.create( - account_id="string", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - member = await response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.accounts.members.with_raw_response.create( - account_id="", - email="user@example.com", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) - @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_update(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", @@ -1127,7 +403,7 @@ async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", @@ -1141,138 +417,10 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.accounts.members.with_raw_response.update( - "4536bcfad5faccb111b47003c79917fa", - account_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - member = await response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.accounts.members.with_streaming_response.update( - "4536bcfad5faccb111b47003c79917fa", - account_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - member = await response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.accounts.members.with_raw_response.update( - "4536bcfad5faccb111b47003c79917fa", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): - await async_client.accounts.members.with_raw_response.update( - "", - account_id="string", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: - member = await async_client.accounts.members.update( - "4536bcfad5faccb111b47003c79917fa", - account_id="string", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], - ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], ) assert response.is_closed is True @@ -1282,48 +430,10 @@ async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="string", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1335,93 +445,17 @@ async def test_streaming_response_update_overload_2(self, async_client: AsyncClo @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + 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.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", account_id="", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): await async_client.accounts.members.with_raw_response.update( "", account_id="string", - policies=[ - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - { - "access": "allow", - "permission_groups": [ - {"id": "c8fed203ed3043cba015a93ad1616f1f"}, - {"id": "82e64a83756745bbbb1c9c2701bf816b"}, - ], - "resource_groups": [ - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, - ], - }, - ], ) @parametrize From 50facab4f812941e1242e652b6789fb02dea0bf6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 08:30:49 +0000 Subject: [PATCH 387/532] feat(api): OpenAPI spec update via Stainless API (#868) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ddeeffb5d02..2dc213fb8e8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-90de7c383d660ce2dd1c4dfa53b4c75ef8c4c37d485f16f9cc2da269d4852095.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b9eda15ba6e500908a66e39a9d92ce5ce54da5eb7d0ecce2ccb51eaa74afaeee.yml From db8224984433842bb3d267be303cb2e4f75731ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 09:17:40 +0000 Subject: [PATCH 388/532] feat(api): OpenAPI spec update via Stainless API (#869) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2dc213fb8e8..ddeeffb5d02 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b9eda15ba6e500908a66e39a9d92ce5ce54da5eb7d0ecce2ccb51eaa74afaeee.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-90de7c383d660ce2dd1c4dfa53b4c75ef8c4c37d485f16f9cc2da269d4852095.yml From 57e73e5f475d547bc6c383759d84eef590570265 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 09:48:43 +0000 Subject: [PATCH 389/532] feat(api): OpenAPI spec update via Stainless API (#870) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ddeeffb5d02..8b57cbbfca4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-90de7c383d660ce2dd1c4dfa53b4c75ef8c4c37d485f16f9cc2da269d4852095.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-97347d998788b4bfb492f2a2aeadd31063f79a70cd39952c18b880117a06a8b5.yml From 0d5f2a92b0355c0dbfc5e4998936c63034e26fa1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:04:02 +0000 Subject: [PATCH 390/532] feat(api): OpenAPI spec update via Stainless API (#871) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8b57cbbfca4..2dc213fb8e8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-97347d998788b4bfb492f2a2aeadd31063f79a70cd39952c18b880117a06a8b5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b9eda15ba6e500908a66e39a9d92ce5ce54da5eb7d0ecce2ccb51eaa74afaeee.yml From 7a883a3af3ae930a5d54192d3659c984b87b0c45 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:06:18 +0000 Subject: [PATCH 391/532] feat(api): OpenAPI spec update via Stainless API (#872) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2dc213fb8e8..8b57cbbfca4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b9eda15ba6e500908a66e39a9d92ce5ce54da5eb7d0ecce2ccb51eaa74afaeee.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-97347d998788b4bfb492f2a2aeadd31063f79a70cd39952c18b880117a06a8b5.yml From fd420dab47712333a017cb157d5d9b02fec4feba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:08:44 +0000 Subject: [PATCH 392/532] feat(api): OpenAPI spec update via Stainless API (#873) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8b57cbbfca4..97ea24156e2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-97347d998788b4bfb492f2a2aeadd31063f79a70cd39952c18b880117a06a8b5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-10c6435539a9266e87ab838ee156aea2c5e8412dfdf9009512910abc3be46a29.yml From d05b083904538968e1d3f40e88b819ea16f1d259 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:17:13 +0000 Subject: [PATCH 393/532] feat(api): OpenAPI spec update via Stainless API (#874) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 97ea24156e2..8b57cbbfca4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-10c6435539a9266e87ab838ee156aea2c5e8412dfdf9009512910abc3be46a29.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-97347d998788b4bfb492f2a2aeadd31063f79a70cd39952c18b880117a06a8b5.yml From 4944d404c55c05d059a7b8dbb4ccf90fe4d7c714 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 14:51:37 +0000 Subject: [PATCH 394/532] feat(api): OpenAPI spec update via Stainless API (#875) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8b57cbbfca4..2dc213fb8e8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-97347d998788b4bfb492f2a2aeadd31063f79a70cd39952c18b880117a06a8b5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b9eda15ba6e500908a66e39a9d92ce5ce54da5eb7d0ecce2ccb51eaa74afaeee.yml From 8f28f6cafbaf9cea72e6f2345d4ec861b08b5700 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:01:05 +0000 Subject: [PATCH 395/532] feat(api): OpenAPI spec update via Stainless API (#876) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2dc213fb8e8..8b57cbbfca4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b9eda15ba6e500908a66e39a9d92ce5ce54da5eb7d0ecce2ccb51eaa74afaeee.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-97347d998788b4bfb492f2a2aeadd31063f79a70cd39952c18b880117a06a8b5.yml From b0a46c09fe8c80c22b02434b01193a1536321c9f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:13:32 +0000 Subject: [PATCH 396/532] feat(api): OpenAPI spec update via Stainless API (#877) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8b57cbbfca4..2dc213fb8e8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-97347d998788b4bfb492f2a2aeadd31063f79a70cd39952c18b880117a06a8b5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b9eda15ba6e500908a66e39a9d92ce5ce54da5eb7d0ecce2ccb51eaa74afaeee.yml From 306f8a4fa860428042d6e144e9f633325836c490 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:18:09 +0000 Subject: [PATCH 397/532] feat(api): OpenAPI spec update via Stainless API (#878) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2dc213fb8e8..0d963443d9f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b9eda15ba6e500908a66e39a9d92ce5ce54da5eb7d0ecce2ccb51eaa74afaeee.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-01bcee9f0bcbf82223f65ca440689c33643a11097face82ec05050592f2389ad.yml From 017c740e7c372cd79590edb64b5434fb2df8aa61 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:10:50 +0000 Subject: [PATCH 398/532] feat(api): OpenAPI spec update via Stainless API (#879) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0d963443d9f..330be9e14a4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-01bcee9f0bcbf82223f65ca440689c33643a11097face82ec05050592f2389ad.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0053e474edb7f838f2b1d38334a7ccb983db09216cca0173a3c3d5401cadcf82.yml From fdbc41b6f8ed81836e45def67becb4dc17910fc6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:38:04 +0000 Subject: [PATCH 399/532] feat(api): OpenAPI spec update via Stainless API (#880) --- .stats.yml | 2 +- api.md | 8 +- .../addressing/address_maps/address_maps.py | 16 ++- .../addressing/loa_documents/downloads.py | 34 ++++-- .../addressing/address_map_create_params.py | 22 +++- .../addressing/address_map_create_response.py | 2 +- .../addressing/address_map_get_response.py | 2 +- .../loa_documents/test_downloads.py | 105 ++++++++++++------ .../addressing/test_address_maps.py | 30 +++++ 9 files changed, 165 insertions(+), 56 deletions(-) diff --git a/.stats.yml b/.stats.yml index 330be9e14a4..0440ff0afac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0053e474edb7f838f2b1d38334a7ccb983db09216cca0173a3c3d5401cadcf82.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml diff --git a/api.md b/api.md index 5295390d972..5d3170fce1e 100644 --- a/api.md +++ b/api.md @@ -3498,15 +3498,9 @@ Methods: ### Downloads -Types: - -```python -from cloudflare.types.addressing.loa_documents import DownloadGetResponse -``` - Methods: -- client.addressing.loa_documents.downloads.get(loa_document_id, \*, account_id) -> object +- client.addressing.loa_documents.downloads.get(loa_document_id, \*, account_id) -> BinaryAPIResponse ## Prefixes diff --git a/src/cloudflare/resources/addressing/address_maps/address_maps.py b/src/cloudflare/resources/addressing/address_maps/address_maps.py index bb2faee96ef..c92ddd937a3 100644 --- a/src/cloudflare/resources/addressing/address_maps/address_maps.py +++ b/src/cloudflare/resources/addressing/address_maps/address_maps.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import List, Type, Iterable, Optional, cast import httpx @@ -85,6 +85,8 @@ def create( account_id: str, description: Optional[str] | NotGiven = NOT_GIVEN, enabled: Optional[bool] | NotGiven = NOT_GIVEN, + ips: List[str] | NotGiven = NOT_GIVEN, + memberships: Iterable[address_map_create_params.Membership] | 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, @@ -104,6 +106,9 @@ def create( enabled: Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. + memberships: Zones and Accounts which will be assigned IPs on this Address Map. A zone + membership will take priority over an account membership. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -120,6 +125,8 @@ def create( { "description": description, "enabled": enabled, + "ips": ips, + "memberships": memberships, }, address_map_create_params.AddressMapCreateParams, ), @@ -354,6 +361,8 @@ async def create( account_id: str, description: Optional[str] | NotGiven = NOT_GIVEN, enabled: Optional[bool] | NotGiven = NOT_GIVEN, + ips: List[str] | NotGiven = NOT_GIVEN, + memberships: Iterable[address_map_create_params.Membership] | 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, @@ -373,6 +382,9 @@ async def create( enabled: Whether the Address Map is enabled or not. Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. + memberships: Zones and Accounts which will be assigned IPs on this Address Map. A zone + membership will take priority over an account membership. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -389,6 +401,8 @@ async def create( { "description": description, "enabled": enabled, + "ips": ips, + "memberships": memberships, }, address_map_create_params.AddressMapCreateParams, ), diff --git a/src/cloudflare/resources/addressing/loa_documents/downloads.py b/src/cloudflare/resources/addressing/loa_documents/downloads.py index b29d0888acd..e333bc3e986 100644 --- a/src/cloudflare/resources/addressing/loa_documents/downloads.py +++ b/src/cloudflare/resources/addressing/loa_documents/downloads.py @@ -10,10 +10,14 @@ 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, + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, + to_custom_raw_response_wrapper, + to_custom_streamed_response_wrapper, + async_to_custom_raw_response_wrapper, + async_to_custom_streamed_response_wrapper, ) from ...._base_client import ( make_request_options, @@ -42,7 +46,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> BinaryAPIResponse: """ Download specified LOA document under the account. @@ -63,12 +67,13 @@ def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not loa_document_id: raise ValueError(f"Expected a non-empty value for `loa_document_id` but received {loa_document_id!r}") + extra_headers = {"Accept": "application/pdf", **(extra_headers or {})} return self._get( f"/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=object, + cast_to=BinaryAPIResponse, ) @@ -92,7 +97,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> AsyncBinaryAPIResponse: """ Download specified LOA document under the account. @@ -113,12 +118,13 @@ async def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not loa_document_id: raise ValueError(f"Expected a non-empty value for `loa_document_id` but received {loa_document_id!r}") + extra_headers = {"Accept": "application/pdf", **(extra_headers or {})} return await self._get( f"/accounts/{account_id}/addressing/loa_documents/{loa_document_id}/download", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=object, + cast_to=AsyncBinaryAPIResponse, ) @@ -126,8 +132,9 @@ class DownloadsResourceWithRawResponse: def __init__(self, downloads: DownloadsResource) -> None: self._downloads = downloads - self.get = to_raw_response_wrapper( + self.get = to_custom_raw_response_wrapper( downloads.get, + BinaryAPIResponse, ) @@ -135,8 +142,9 @@ class AsyncDownloadsResourceWithRawResponse: def __init__(self, downloads: AsyncDownloadsResource) -> None: self._downloads = downloads - self.get = async_to_raw_response_wrapper( + self.get = async_to_custom_raw_response_wrapper( downloads.get, + AsyncBinaryAPIResponse, ) @@ -144,8 +152,9 @@ class DownloadsResourceWithStreamingResponse: def __init__(self, downloads: DownloadsResource) -> None: self._downloads = downloads - self.get = to_streamed_response_wrapper( + self.get = to_custom_streamed_response_wrapper( downloads.get, + StreamedBinaryAPIResponse, ) @@ -153,6 +162,7 @@ class AsyncDownloadsResourceWithStreamingResponse: def __init__(self, downloads: AsyncDownloadsResource) -> None: self._downloads = downloads - self.get = async_to_streamed_response_wrapper( + self.get = async_to_custom_streamed_response_wrapper( downloads.get, + AsyncStreamedBinaryAPIResponse, ) diff --git a/src/cloudflare/types/addressing/address_map_create_params.py b/src/cloudflare/types/addressing/address_map_create_params.py index 5ecc49b6e6e..ac313102d61 100644 --- a/src/cloudflare/types/addressing/address_map_create_params.py +++ b/src/cloudflare/types/addressing/address_map_create_params.py @@ -2,10 +2,12 @@ from __future__ import annotations -from typing import Optional +from typing import List, Iterable, Optional from typing_extensions import Required, TypedDict -__all__ = ["AddressMapCreateParams"] +from .kind import Kind + +__all__ = ["AddressMapCreateParams", "Membership"] class AddressMapCreateParams(TypedDict, total=False): @@ -24,3 +26,19 @@ class AddressMapCreateParams(TypedDict, total=False): Cloudflare's DNS will not respond with IP addresses on an Address Map until the map is enabled. """ + + ips: List[str] + + memberships: Iterable[Membership] + """Zones and Accounts which will be assigned IPs on this Address Map. + + A zone membership will take priority over an account membership. + """ + + +class Membership(TypedDict, total=False): + identifier: str + """The identifier for the membership (eg. a zone or account tag).""" + + kind: Kind + """The type of the membership.""" diff --git a/src/cloudflare/types/addressing/address_map_create_response.py b/src/cloudflare/types/addressing/address_map_create_response.py index d4eb788e2df..032e1166d18 100644 --- a/src/cloudflare/types/addressing/address_map_create_response.py +++ b/src/cloudflare/types/addressing/address_map_create_response.py @@ -23,7 +23,7 @@ class Membership(BaseModel): created_at: Optional[datetime] = None identifier: Optional[str] = None - """Identifier""" + """The identifier for the membership (eg. a zone or account tag).""" kind: Optional[Kind] = None """The type of the membership.""" diff --git a/src/cloudflare/types/addressing/address_map_get_response.py b/src/cloudflare/types/addressing/address_map_get_response.py index 06bdfc92ed8..0eb306ccdbd 100644 --- a/src/cloudflare/types/addressing/address_map_get_response.py +++ b/src/cloudflare/types/addressing/address_map_get_response.py @@ -23,7 +23,7 @@ class Membership(BaseModel): created_at: Optional[datetime] = None identifier: Optional[str] = None - """Identifier""" + """The identifier for the membership (eg. a zone or account tag).""" kind: Optional[Kind] = None """The type of the membership.""" diff --git a/tests/api_resources/addressing/loa_documents/test_downloads.py b/tests/api_resources/addressing/loa_documents/test_downloads.py index db82ee230fa..bd37633f548 100644 --- a/tests/api_resources/addressing/loa_documents/test_downloads.py +++ b/tests/api_resources/addressing/loa_documents/test_downloads.py @@ -5,10 +5,17 @@ import os from typing import Any, cast +import httpx import pytest +from respx import MockRouter from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type +from cloudflare._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -17,40 +24,58 @@ class TestDownloads: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - def test_method_get(self, client: Cloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/addressing/loa_documents/d933b1530bc56c9953cf8ce166da8004/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) download = client.addressing.loa_documents.downloads.get( "d933b1530bc56c9953cf8ce166da8004", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(object, download, path=["response"]) + assert download.is_closed + assert download.json() == {"foo": "bar"} + assert cast(Any, download.is_closed) is True + assert isinstance(download, BinaryAPIResponse) @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.addressing.loa_documents.downloads.with_raw_response.get( + @pytest.mark.respx(base_url=base_url) + def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/addressing/loa_documents/d933b1530bc56c9953cf8ce166da8004/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + + download = client.addressing.loa_documents.downloads.with_raw_response.get( "d933b1530bc56c9953cf8ce166da8004", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - download = response.parse() - assert_matches_type(object, download, path=["response"]) + assert download.is_closed is True + assert download.http_request.headers.get("X-Stainless-Lang") == "python" + assert download.json() == {"foo": "bar"} + assert isinstance(download, BinaryAPIResponse) @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/addressing/loa_documents/d933b1530bc56c9953cf8ce166da8004/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) with client.addressing.loa_documents.downloads.with_streaming_response.get( "d933b1530bc56c9953cf8ce166da8004", account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ) as download: + assert not download.is_closed + assert download.http_request.headers.get("X-Stainless-Lang") == "python" - download = response.parse() - assert_matches_type(object, download, path=["response"]) + assert download.json() == {"foo": "bar"} + assert cast(Any, download.is_closed) is True + assert isinstance(download, StreamedBinaryAPIResponse) - assert cast(Any, response.is_closed) is True + assert cast(Any, download.is_closed) is True @parametrize + @pytest.mark.respx(base_url=base_url) 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.addressing.loa_documents.downloads.with_raw_response.get( @@ -69,40 +94,58 @@ class TestAsyncDownloads: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/addressing/loa_documents/d933b1530bc56c9953cf8ce166da8004/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) download = await async_client.addressing.loa_documents.downloads.get( "d933b1530bc56c9953cf8ce166da8004", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(object, download, path=["response"]) + assert download.is_closed + assert await download.json() == {"foo": "bar"} + assert cast(Any, download.is_closed) is True + assert isinstance(download, AsyncBinaryAPIResponse) @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.addressing.loa_documents.downloads.with_raw_response.get( + @pytest.mark.respx(base_url=base_url) + async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/addressing/loa_documents/d933b1530bc56c9953cf8ce166da8004/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + + download = await async_client.addressing.loa_documents.downloads.with_raw_response.get( "d933b1530bc56c9953cf8ce166da8004", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - download = await response.parse() - assert_matches_type(object, download, path=["response"]) + assert download.is_closed is True + assert download.http_request.headers.get("X-Stainless-Lang") == "python" + assert await download.json() == {"foo": "bar"} + assert isinstance(download, AsyncBinaryAPIResponse) @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/addressing/loa_documents/d933b1530bc56c9953cf8ce166da8004/download" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) async with async_client.addressing.loa_documents.downloads.with_streaming_response.get( "d933b1530bc56c9953cf8ce166da8004", account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ) as download: + assert not download.is_closed + assert download.http_request.headers.get("X-Stainless-Lang") == "python" - download = await response.parse() - assert_matches_type(object, download, path=["response"]) + assert await download.json() == {"foo": "bar"} + assert cast(Any, download.is_closed) is True + assert isinstance(download, AsyncStreamedBinaryAPIResponse) - assert cast(Any, response.is_closed) is True + assert cast(Any, download.is_closed) is True @parametrize + @pytest.mark.respx(base_url=base_url) 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.addressing.loa_documents.downloads.with_raw_response.get( diff --git a/tests/api_resources/addressing/test_address_maps.py b/tests/api_resources/addressing/test_address_maps.py index 1a4e0b0a57c..a883e9dfd4b 100644 --- a/tests/api_resources/addressing/test_address_maps.py +++ b/tests/api_resources/addressing/test_address_maps.py @@ -36,6 +36,21 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", description="My Ecommerce zones", enabled=True, + ips=["192.0.2.1", "192.0.2.1", "192.0.2.1"], + memberships=[ + { + "identifier": "023e105f4ecef8ad9ca31a8372d0c353", + "kind": "zone", + }, + { + "identifier": "023e105f4ecef8ad9ca31a8372d0c353", + "kind": "zone", + }, + { + "identifier": "023e105f4ecef8ad9ca31a8372d0c353", + "kind": "zone", + }, + ], ) assert_matches_type(Optional[AddressMapCreateResponse], address_map, path=["response"]) @@ -280,6 +295,21 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_id="023e105f4ecef8ad9ca31a8372d0c353", description="My Ecommerce zones", enabled=True, + ips=["192.0.2.1", "192.0.2.1", "192.0.2.1"], + memberships=[ + { + "identifier": "023e105f4ecef8ad9ca31a8372d0c353", + "kind": "zone", + }, + { + "identifier": "023e105f4ecef8ad9ca31a8372d0c353", + "kind": "zone", + }, + { + "identifier": "023e105f4ecef8ad9ca31a8372d0c353", + "kind": "zone", + }, + ], ) assert_matches_type(Optional[AddressMapCreateResponse], address_map, path=["response"]) From a54ba22cbd417bc28ff96635c9a6e673de2f02b6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:46:27 +0000 Subject: [PATCH 400/532] feat(api): OpenAPI spec update via Stainless API (#881) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0440ff0afac..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From be7f95b936c4664abf46db13afc5ca13e94baa26 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:48:41 +0000 Subject: [PATCH 401/532] feat(api): OpenAPI spec update via Stainless API (#882) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..0440ff0afac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml From 2f8cee56e4505a5d9d4b258551fd14e559751062 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:58:15 +0000 Subject: [PATCH 402/532] feat(api): OpenAPI spec update via Stainless API (#883) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0440ff0afac..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From 0a5bff5ef8bb33e91847dc06e27cd64c25a3d366 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:00:26 +0000 Subject: [PATCH 403/532] feat(api): OpenAPI spec update via Stainless API (#884) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..4210ccee048 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml From 142d257f4487a91f424c34b9c06c45efe1dfbcd9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:02:42 +0000 Subject: [PATCH 404/532] feat(api): OpenAPI spec update via Stainless API (#885) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4210ccee048..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From 78c7e25e85316d7529d76bed2c75a47476337ebb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 18:07:50 +0000 Subject: [PATCH 405/532] feat(api): OpenAPI spec update via Stainless API (#886) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..0440ff0afac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml From 561f2c0b649394d493363915c97714e39fc2a011 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 18:10:02 +0000 Subject: [PATCH 406/532] feat(api): OpenAPI spec update via Stainless API (#887) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0440ff0afac..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From 21b7830e1b36b653ba670f7584da0c57dd515704 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 19:18:28 +0000 Subject: [PATCH 407/532] feat(api): OpenAPI spec update via Stainless API (#888) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..4210ccee048 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml From 77175b0d230954b2f3cd31d12af45b5f022e3c3f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 19:59:32 +0000 Subject: [PATCH 408/532] feat(api): OpenAPI spec update via Stainless API (#889) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4210ccee048..0440ff0afac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml From 11581943445a1858adc8cb003764bdf52b1d8319 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:20:18 +0000 Subject: [PATCH 409/532] feat(api): OpenAPI spec update via Stainless API (#890) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0440ff0afac..92b81159a83 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml From 6e2115adddba8d6764013bc377e4264e74553c96 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:08:24 +0000 Subject: [PATCH 410/532] feat(api): OpenAPI spec update via Stainless API (#891) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92b81159a83..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From 0330dce9a9dc3ebf88c74e7b1f73dab4cd927550 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:10:45 +0000 Subject: [PATCH 411/532] feat(api): OpenAPI spec update via Stainless API (#892) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..92b81159a83 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml From b22ba085dffb57dc8540e88e250655e23a0e6c4e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:44:41 +0000 Subject: [PATCH 412/532] feat(api): OpenAPI spec update via Stainless API (#893) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92b81159a83..4210ccee048 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml From 814073556826dcf850c9066b40dbb6a186a55b29 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:47:04 +0000 Subject: [PATCH 413/532] feat(api): OpenAPI spec update via Stainless API (#894) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4210ccee048..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From 547a922d645ba30f18fda20308cec11a00605295 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:57:16 +0000 Subject: [PATCH 414/532] feat(api): OpenAPI spec update via Stainless API (#895) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..4210ccee048 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml From 706751326205e3272f1d3e5e2ae60c6555c18b72 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:59:28 +0000 Subject: [PATCH 415/532] feat(api): OpenAPI spec update via Stainless API (#896) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4210ccee048..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From ec1cce1022b73726a50bcd19f518c47a2f7f90d1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 12:09:47 +0000 Subject: [PATCH 416/532] feat(api): OpenAPI spec update via Stainless API (#897) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..4210ccee048 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml From ee63e1eabd0ded4e2b0d66f7be3b4d3fdc73454a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 12:12:12 +0000 Subject: [PATCH 417/532] feat(api): OpenAPI spec update via Stainless API (#898) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4210ccee048..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From f7761ebf84cf5a60e6c2b1443e34104e3c65b06b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 12:56:58 +0000 Subject: [PATCH 418/532] feat(api): OpenAPI spec update via Stainless API (#899) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..92b81159a83 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml From d61c9a1401a1d200fdaa850a1e4393dd60159bdc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:28:59 +0000 Subject: [PATCH 419/532] feat(api): OpenAPI spec update via Stainless API (#900) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92b81159a83..4210ccee048 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml From 0c827900578fa4ca1f790b7dddd1e93090ceaa6a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:40:42 +0000 Subject: [PATCH 420/532] feat(api): OpenAPI spec update via Stainless API (#901) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4210ccee048..92b81159a83 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-88251a14cc4e73591bebcd234af63228b058d53dc2fb2ab00e0386e984b4db80.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml From 36f10acb46a80d69906018baaad28c5c07299da0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:00:14 +0000 Subject: [PATCH 421/532] feat(api): OpenAPI spec update via Stainless API (#902) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92b81159a83..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From a1c451e77848fc90c5bcb0cbb7e681d6df8611a6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:02:23 +0000 Subject: [PATCH 422/532] feat(api): OpenAPI spec update via Stainless API (#903) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..0440ff0afac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml From 73c1c103a90c77f85d548d93478a39412f0e7647 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:04:35 +0000 Subject: [PATCH 423/532] feat(api): OpenAPI spec update via Stainless API (#904) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0440ff0afac..a09b92e43db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml From fe3c0e9aaf50b1376da4159da12f03134b1b1d4d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:52:32 +0000 Subject: [PATCH 424/532] feat(api): OpenAPI spec update via Stainless API (#905) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a09b92e43db..92b81159a83 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f64174a3fe500d2081cdd36a3263ffda8c5713543ddf8aa7fef8c8cdcda7d22f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml From 637480d143b5f2f77226b84d88a3b283733367bf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:55:08 +0000 Subject: [PATCH 425/532] feat(api): OpenAPI spec update via Stainless API (#906) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92b81159a83..0440ff0afac 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml From 1716bafadaba2a6fc8511f0cafb000ee33d661ba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:09:03 +0000 Subject: [PATCH 426/532] feat(api): OpenAPI spec update via Stainless API (#907) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0440ff0afac..92b81159a83 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d780b9eb98465e97c30112eb2c9e586883852508d23a6684bd28e5a9cb7da7a1.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml From 392e54fb43bf148da0f1686cb8e777135c96d106 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:11:24 +0000 Subject: [PATCH 427/532] feat(api): OpenAPI spec update via Stainless API (#908) --- .stats.yml | 2 +- .../access/application_create_params.py | 7 ++++ .../access/application_create_response.py | 7 ++++ .../access/application_get_response.py | 7 ++++ .../access/application_list_response.py | 7 ++++ .../access/application_update_params.py | 7 ++++ .../access/application_update_response.py | 7 ++++ src/cloudflare/types/zero_trust/seat.py | 2 +- .../types/zero_trust/seat_edit_params.py | 3 ++ tests/api_resources/zero_trust/test_seats.py | 36 +++++++++++++++---- 10 files changed, 77 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 92b81159a83..5a6baba3ca7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bdfe21693106fc05b48376c8081959ea29b7484eb76fb778b3a87cfdd4849dd2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f33a7e8050bdba5caa80d678c9b3de6fe87b6af4bf29184f3f1b07b2793c817b.yml diff --git a/src/cloudflare/types/zero_trust/access/application_create_params.py b/src/cloudflare/types/zero_trust/access/application_create_params.py index 6456faaed7c..f09b5e2993c 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_params.py +++ b/src/cloudflare/types/zero_trust/access/application_create_params.py @@ -629,6 +629,13 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(TypedDict, tota class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): + access_token_lifetime: str + """The lifetime of the OIDC Access Token after creation. + + Valid units are m,h. Must be greater than or equal to 1m and less than or equal + to 24h. + """ + allow_pkce_without_client_secret: bool """ If client secret should be required on the token endpoint when diff --git a/src/cloudflare/types/zero_trust/access/application_create_response.py b/src/cloudflare/types/zero_trust/access/application_create_response.py index f6c58d8012b..af4a28bfba5 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_response.py +++ b/src/cloudflare/types/zero_trust/access/application_create_response.py @@ -522,6 +522,13 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): + access_token_lifetime: Optional[str] = None + """The lifetime of the OIDC Access Token after creation. + + Valid units are m,h. Must be greater than or equal to 1m and less than or equal + to 24h. + """ + allow_pkce_without_client_secret: Optional[bool] = None """ If client secret should be required on the token endpoint when diff --git a/src/cloudflare/types/zero_trust/access/application_get_response.py b/src/cloudflare/types/zero_trust/access/application_get_response.py index e4990e3e2b2..a633b9174c1 100644 --- a/src/cloudflare/types/zero_trust/access/application_get_response.py +++ b/src/cloudflare/types/zero_trust/access/application_get_response.py @@ -522,6 +522,13 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): + access_token_lifetime: Optional[str] = None + """The lifetime of the OIDC Access Token after creation. + + Valid units are m,h. Must be greater than or equal to 1m and less than or equal + to 24h. + """ + allow_pkce_without_client_secret: Optional[bool] = None """ If client secret should be required on the token endpoint when diff --git a/src/cloudflare/types/zero_trust/access/application_list_response.py b/src/cloudflare/types/zero_trust/access/application_list_response.py index f2b23a70eae..2b7457c8e75 100644 --- a/src/cloudflare/types/zero_trust/access/application_list_response.py +++ b/src/cloudflare/types/zero_trust/access/application_list_response.py @@ -522,6 +522,13 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): + access_token_lifetime: Optional[str] = None + """The lifetime of the OIDC Access Token after creation. + + Valid units are m,h. Must be greater than or equal to 1m and less than or equal + to 24h. + """ + allow_pkce_without_client_secret: Optional[bool] = None """ If client secret should be required on the token endpoint when diff --git a/src/cloudflare/types/zero_trust/access/application_update_params.py b/src/cloudflare/types/zero_trust/access/application_update_params.py index 2dc5938e715..c0da9486d6a 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_params.py +++ b/src/cloudflare/types/zero_trust/access/application_update_params.py @@ -629,6 +629,13 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(TypedDict, tota class SaaSApplicationSaaSAppAccessOIDCSaaSApp(TypedDict, total=False): + access_token_lifetime: str + """The lifetime of the OIDC Access Token after creation. + + Valid units are m,h. Must be greater than or equal to 1m and less than or equal + to 24h. + """ + allow_pkce_without_client_secret: bool """ If client secret should be required on the token endpoint when diff --git a/src/cloudflare/types/zero_trust/access/application_update_response.py b/src/cloudflare/types/zero_trust/access/application_update_response.py index e7047407794..9c96a2d760d 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_response.py +++ b/src/cloudflare/types/zero_trust/access/application_update_response.py @@ -522,6 +522,13 @@ class SaaSApplicationSaaSAppAccessOIDCSaaSAppRefreshTokenOptions(BaseModel): class SaaSApplicationSaaSAppAccessOIDCSaaSApp(BaseModel): + access_token_lifetime: Optional[str] = None + """The lifetime of the OIDC Access Token after creation. + + Valid units are m,h. Must be greater than or equal to 1m and less than or equal + to 24h. + """ + allow_pkce_without_client_secret: Optional[bool] = None """ If client secret should be required on the token endpoint when diff --git a/src/cloudflare/types/zero_trust/seat.py b/src/cloudflare/types/zero_trust/seat.py index bf56403a543..5d59613de0d 100644 --- a/src/cloudflare/types/zero_trust/seat.py +++ b/src/cloudflare/types/zero_trust/seat.py @@ -18,6 +18,6 @@ class Seat(BaseModel): """True if the seat is part of Gateway.""" seat_uid: Optional[str] = None - """Identifier""" + """The unique API identifier for the Zero Trust seat.""" updated_at: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/seat_edit_params.py b/src/cloudflare/types/zero_trust/seat_edit_params.py index 5e6696944c1..ace9d68ecfb 100644 --- a/src/cloudflare/types/zero_trust/seat_edit_params.py +++ b/src/cloudflare/types/zero_trust/seat_edit_params.py @@ -21,3 +21,6 @@ class Body(TypedDict, total=False): gateway_seat: Required[bool] """True if the seat is part of Gateway.""" + + seat_uid: Required[str] + """The unique API identifier for the Zero Trust seat.""" diff --git a/tests/api_resources/zero_trust/test_seats.py b/tests/api_resources/zero_trust/test_seats.py index 76a871664a8..639cbee067f 100644 --- a/tests/api_resources/zero_trust/test_seats.py +++ b/tests/api_resources/zero_trust/test_seats.py @@ -21,19 +21,22 @@ class TestSeats: @parametrize def test_method_edit(self, client: Cloudflare) -> None: seat = client.zero_trust.seats.edit( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="699d98642c564d2e855e9661899b7252", body=[ { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, ], ) @@ -43,19 +46,22 @@ def test_method_edit(self, client: Cloudflare) -> None: @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: response = client.zero_trust.seats.with_raw_response.edit( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="699d98642c564d2e855e9661899b7252", body=[ { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, ], ) @@ -69,19 +75,22 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: with client.zero_trust.seats.with_streaming_response.edit( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="699d98642c564d2e855e9661899b7252", body=[ { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, ], ) as response: @@ -103,14 +112,17 @@ def test_path_params_edit(self, client: Cloudflare) -> None: { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, ], ) @@ -123,19 +135,22 @@ class TestAsyncSeats: @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: seat = await async_client.zero_trust.seats.edit( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="699d98642c564d2e855e9661899b7252", body=[ { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, ], ) @@ -145,19 +160,22 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.seats.with_raw_response.edit( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="699d98642c564d2e855e9661899b7252", body=[ { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, ], ) @@ -171,19 +189,22 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.seats.with_streaming_response.edit( - account_id="023e105f4ecef8ad9ca31a8372d0c353", + account_id="699d98642c564d2e855e9661899b7252", body=[ { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, ], ) as response: @@ -205,14 +226,17 @@ async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, { "access_seat": False, "gateway_seat": False, + "seat_uid": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", }, ], ) From f9ea911f67fe67ecdc9dd7cbb9611db3a777cd95 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:36:55 +0000 Subject: [PATCH 428/532] feat(api): OpenAPI spec update via Stainless API (#909) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5a6baba3ca7..254000e633d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f33a7e8050bdba5caa80d678c9b3de6fe87b6af4bf29184f3f1b07b2793c817b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6545c93a16062d2763cd304367d8babf5aaef09046036361dbb077b75536e858.yml From cef0cea6c48a6b3af2c3da8ece583cf5cef347c8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:46:05 +0000 Subject: [PATCH 429/532] feat(api): OpenAPI spec update via Stainless API (#910) --- .stats.yml | 2 +- .../zero_trust/dlp/datasets/upload.py | 4 ++-- .../dlp/datasets/upload_edit_params.py | 2 +- .../zero_trust/dlp/datasets/test_upload.py | 20 +++++++++---------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.stats.yml b/.stats.yml index 254000e633d..f6163818d60 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6545c93a16062d2763cd304367d8babf5aaef09046036361dbb077b75536e858.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f1ab7e5d073ef27b0e08bd9fd83e406c15c1c69017c29b17dadceec459febd7b.yml diff --git a/src/cloudflare/resources/zero_trust/dlp/datasets/upload.py b/src/cloudflare/resources/zero_trust/dlp/datasets/upload.py index 8ae70bace70..ffbd13882e4 100644 --- a/src/cloudflare/resources/zero_trust/dlp/datasets/upload.py +++ b/src/cloudflare/resources/zero_trust/dlp/datasets/upload.py @@ -85,7 +85,7 @@ def edit( *, account_id: str, dataset_id: str, - body: object, + body: 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, @@ -178,7 +178,7 @@ async def edit( *, account_id: str, dataset_id: str, - body: object, + body: 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, diff --git a/src/cloudflare/types/zero_trust/dlp/datasets/upload_edit_params.py b/src/cloudflare/types/zero_trust/dlp/datasets/upload_edit_params.py index 3427ac066d8..1a0500f09a4 100644 --- a/src/cloudflare/types/zero_trust/dlp/datasets/upload_edit_params.py +++ b/src/cloudflare/types/zero_trust/dlp/datasets/upload_edit_params.py @@ -12,4 +12,4 @@ class UploadEditParams(TypedDict, total=False): dataset_id: Required[str] - body: Required[object] + body: Required[str] diff --git a/tests/api_resources/zero_trust/dlp/datasets/test_upload.py b/tests/api_resources/zero_trust/dlp/datasets/test_upload.py index df7a9832ab3..625c13ce809 100644 --- a/tests/api_resources/zero_trust/dlp/datasets/test_upload.py +++ b/tests/api_resources/zero_trust/dlp/datasets/test_upload.py @@ -73,7 +73,7 @@ def test_method_edit(self, client: Cloudflare) -> None: 0, account_id="string", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body={}, + body="string", ) assert_matches_type(Optional[Dataset], upload, path=["response"]) @@ -84,7 +84,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: 0, account_id="string", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body={}, + body="string", ) assert response.is_closed is True @@ -99,7 +99,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: 0, account_id="string", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body={}, + body="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -117,7 +117,7 @@ def test_path_params_edit(self, client: Cloudflare) -> None: 0, account_id="", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body={}, + body="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): @@ -125,7 +125,7 @@ def test_path_params_edit(self, client: Cloudflare) -> None: 0, account_id="string", dataset_id="", - body={}, + body="string", ) @@ -187,7 +187,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: 0, account_id="string", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body={}, + body="string", ) assert_matches_type(Optional[Dataset], upload, path=["response"]) @@ -198,7 +198,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: 0, account_id="string", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body={}, + body="string", ) assert response.is_closed is True @@ -213,7 +213,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N 0, account_id="string", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body={}, + body="string", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -231,7 +231,7 @@ async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: 0, account_id="", dataset_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - body={}, + body="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataset_id` but received ''"): @@ -239,5 +239,5 @@ async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: 0, account_id="string", dataset_id="", - body={}, + body="string", ) From 92b2ce3b9b1800491f3e82e109d0daa3ef8624c1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:47:32 +0000 Subject: [PATCH 430/532] feat(api): OpenAPI spec update via Stainless API (#911) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f6163818d60..9a470d133fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f1ab7e5d073ef27b0e08bd9fd83e406c15c1c69017c29b17dadceec459febd7b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0af4828f19ecf78eaed609758780c7c837f008f7bd0bab1e47a902a791cf3eba.yml From 03507c5c9172bb669b25ba6ba81737b8c5f8da17 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 01:31:58 +0000 Subject: [PATCH 431/532] feat(api): update via SDK Studio (#912) --- .../loa_documents/test_downloads.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/api_resources/addressing/loa_documents/test_downloads.py b/tests/api_resources/addressing/loa_documents/test_downloads.py index bd37633f548..5c401decdfe 100644 --- a/tests/api_resources/addressing/loa_documents/test_downloads.py +++ b/tests/api_resources/addressing/loa_documents/test_downloads.py @@ -23,6 +23,9 @@ class TestDownloads: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="TODO: address broken spotlight error - https://github.com/cloudflare/cloudflare-typescript/actions/runs/9456639475/job/26048931174?pr=498#step:5:489" + ) @parametrize @pytest.mark.respx(base_url=base_url) def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: @@ -38,6 +41,9 @@ def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: assert cast(Any, download.is_closed) is True assert isinstance(download, BinaryAPIResponse) + @pytest.mark.skip( + reason="TODO: address broken spotlight error - https://github.com/cloudflare/cloudflare-typescript/actions/runs/9456639475/job/26048931174?pr=498#step:5:489" + ) @parametrize @pytest.mark.respx(base_url=base_url) def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: @@ -55,6 +61,9 @@ def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> N assert download.json() == {"foo": "bar"} assert isinstance(download, BinaryAPIResponse) + @pytest.mark.skip( + reason="TODO: address broken spotlight error - https://github.com/cloudflare/cloudflare-typescript/actions/runs/9456639475/job/26048931174?pr=498#step:5:489" + ) @parametrize @pytest.mark.respx(base_url=base_url) def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: @@ -74,6 +83,9 @@ def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter assert cast(Any, download.is_closed) is True + @pytest.mark.skip( + reason="TODO: address broken spotlight error - https://github.com/cloudflare/cloudflare-typescript/actions/runs/9456639475/job/26048931174?pr=498#step:5:489" + ) @parametrize @pytest.mark.respx(base_url=base_url) def test_path_params_get(self, client: Cloudflare) -> None: @@ -93,6 +105,9 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncDownloads: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip( + reason="TODO: address broken spotlight error - https://github.com/cloudflare/cloudflare-typescript/actions/runs/9456639475/job/26048931174?pr=498#step:5:489" + ) @parametrize @pytest.mark.respx(base_url=base_url) async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: @@ -108,6 +123,9 @@ async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockR assert cast(Any, download.is_closed) is True assert isinstance(download, AsyncBinaryAPIResponse) + @pytest.mark.skip( + reason="TODO: address broken spotlight error - https://github.com/cloudflare/cloudflare-typescript/actions/runs/9456639475/job/26048931174?pr=498#step:5:489" + ) @parametrize @pytest.mark.respx(base_url=base_url) async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: @@ -125,6 +143,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: assert await download.json() == {"foo": "bar"} assert isinstance(download, AsyncBinaryAPIResponse) + @pytest.mark.skip( + reason="TODO: address broken spotlight error - https://github.com/cloudflare/cloudflare-typescript/actions/runs/9456639475/job/26048931174?pr=498#step:5:489" + ) @parametrize @pytest.mark.respx(base_url=base_url) async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: @@ -144,6 +165,9 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx assert cast(Any, download.is_closed) is True + @pytest.mark.skip( + reason="TODO: address broken spotlight error - https://github.com/cloudflare/cloudflare-typescript/actions/runs/9456639475/job/26048931174?pr=498#step:5:489" + ) @parametrize @pytest.mark.respx(base_url=base_url) async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: From 7600ef4404439ad88e907cfbc906df3f295f92b4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 08:56:28 +0000 Subject: [PATCH 432/532] feat(api): OpenAPI spec update via Stainless API (#913) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9a470d133fc..63ee54ee2bb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0af4828f19ecf78eaed609758780c7c837f008f7bd0bab1e47a902a791cf3eba.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1621fb6b04eebbe830d6278109c795ad58da5fabdde174fea2fa2d5cc0a2a6e7.yml From 64e3e727948bb198791c83e0eab875729a213ca8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:04:08 +0000 Subject: [PATCH 433/532] feat(api): OpenAPI spec update via Stainless API (#914) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 63ee54ee2bb..a5cd29944cd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1621fb6b04eebbe830d6278109c795ad58da5fabdde174fea2fa2d5cc0a2a6e7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-808f6ad1ec4946bfa2de623df9e6b47369a325e530eb5944671f18f11024b2e4.yml From e94d9f7e8a238b5706f65db4bb7e83cc0db7aedb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:02:33 +0000 Subject: [PATCH 434/532] feat(api): OpenAPI spec update via Stainless API (#915) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a5cd29944cd..a3ab103b789 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-808f6ad1ec4946bfa2de623df9e6b47369a325e530eb5944671f18f11024b2e4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-21b47a69bc32776f3294f3c636cad301b509524877079e2477fd4f306b9c123b.yml From 6dc52de9b04efdf2f0a09731f7d9fd262a87cdd7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:49:31 +0000 Subject: [PATCH 435/532] feat(api): OpenAPI spec update via Stainless API (#916) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a3ab103b789..6df0dd1533b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-21b47a69bc32776f3294f3c636cad301b509524877079e2477fd4f306b9c123b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3dbd1eb87fca83bbc2f9437df898269e03c56e67cd37ee62ccb3f7e1232eb606.yml From 5d522b4a3b7a5b8c1dcc48b7e19bcc86570ad0c1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:35:57 +0000 Subject: [PATCH 436/532] feat(api): OpenAPI spec update via Stainless API (#917) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6df0dd1533b..71726454a92 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3dbd1eb87fca83bbc2f9437df898269e03c56e67cd37ee62ccb3f7e1232eb606.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4220c0316b6a5dada3587bc54e55df7d6f77bc9509a1e4ecff7273928d079843.yml From 598f17dc09f2bc1eba21732d658aff91092ad38f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 20:33:08 +0000 Subject: [PATCH 437/532] feat(api): OpenAPI spec update via Stainless API (#918) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 71726454a92..c31bc4bb3d4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4220c0316b6a5dada3587bc54e55df7d6f77bc9509a1e4ecff7273928d079843.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-edcf9ad6aa034e166b4e50019579df2a77135741fecdb5c836cf6352ff4a1e1a.yml From 8c02be4d02578daa36bb64a06f3ecc5e6d1e93a6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 20:43:24 +0000 Subject: [PATCH 438/532] feat(api): OpenAPI spec update via Stainless API (#919) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c31bc4bb3d4..655f5af9cfb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-edcf9ad6aa034e166b4e50019579df2a77135741fecdb5c836cf6352ff4a1e1a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3ea4936546f621c7849b96e75c935cb8242eef6497615bf83ae09dff102a1827.yml From 3f3c410cc465de67bf4a353cfe18b3d29fc8524a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:09:08 +0000 Subject: [PATCH 439/532] feat(api): OpenAPI spec update via Stainless API (#920) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 655f5af9cfb..d92ca395299 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3ea4936546f621c7849b96e75c935cb8242eef6497615bf83ae09dff102a1827.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b57c143aface6815ba3fea56b8918bf3585a783920aab504c0f5290ddaa6c223.yml From 9c787974347ea014457389007bc6f9f6397306e3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:16:24 +0000 Subject: [PATCH 440/532] feat(api): OpenAPI spec update via Stainless API (#921) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d92ca395299..c93e9183438 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b57c143aface6815ba3fea56b8918bf3585a783920aab504c0f5290ddaa6c223.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c6936210883e7f0b45c6934943092702ee1e70750421fb07777b53fbe0829b97.yml From 4f81e3a49b56512c4258c33a5aa9872b8362842b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:10:45 +0000 Subject: [PATCH 441/532] feat(api): OpenAPI spec update via Stainless API (#922) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c93e9183438..e5899477aec 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c6936210883e7f0b45c6934943092702ee1e70750421fb07777b53fbe0829b97.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-869da9197e7a5cc155e776b632c1bc39c4e80b33faa17c0ba4ec02002573c018.yml From 980ac6dd9ed7bc345c36fd112f2be169870680ec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 05:56:12 +0000 Subject: [PATCH 442/532] feat(api): update via SDK Studio (#923) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e5899477aec..9a470d133fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-869da9197e7a5cc155e776b632c1bc39c4e80b33faa17c0ba4ec02002573c018.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0af4828f19ecf78eaed609758780c7c837f008f7bd0bab1e47a902a791cf3eba.yml From a19a00632f6f635bad9789a9021dc5f006c3d580 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:29:27 +0000 Subject: [PATCH 443/532] feat(api): OpenAPI spec update via Stainless API (#924) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9a470d133fc..d92ca395299 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0af4828f19ecf78eaed609758780c7c837f008f7bd0bab1e47a902a791cf3eba.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b57c143aface6815ba3fea56b8918bf3585a783920aab504c0f5290ddaa6c223.yml From ff97dd5b0cd64672a0a63102396a2fbfc04a3cb8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:31:47 +0000 Subject: [PATCH 444/532] feat(api): OpenAPI spec update via Stainless API (#925) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d92ca395299..e5899477aec 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b57c143aface6815ba3fea56b8918bf3585a783920aab504c0f5290ddaa6c223.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-869da9197e7a5cc155e776b632c1bc39c4e80b33faa17c0ba4ec02002573c018.yml From 02aeaabae3c68c8f46570d9dbff8f5c72b271093 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:02:55 +0000 Subject: [PATCH 445/532] feat(api): OpenAPI spec update via Stainless API (#926) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e5899477aec..d92ca395299 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-869da9197e7a5cc155e776b632c1bc39c4e80b33faa17c0ba4ec02002573c018.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b57c143aface6815ba3fea56b8918bf3585a783920aab504c0f5290ddaa6c223.yml From 74f90177e7343e27868c0b6cfef297254cdaa41f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:05:14 +0000 Subject: [PATCH 446/532] feat(api): OpenAPI spec update via Stainless API (#927) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d92ca395299..c93e9183438 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b57c143aface6815ba3fea56b8918bf3585a783920aab504c0f5290ddaa6c223.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c6936210883e7f0b45c6934943092702ee1e70750421fb07777b53fbe0829b97.yml From 113cb5b2690caf2ec4dc37986ebc1a5849e365d2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:15:57 +0000 Subject: [PATCH 447/532] feat(api): OpenAPI spec update via Stainless API (#928) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c93e9183438..c1d464865fd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c6936210883e7f0b45c6934943092702ee1e70750421fb07777b53fbe0829b97.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-799a9bbf5649fd0d0530e2b7cd45106c66c52539d1ff188e812b00570931aef0.yml From 4198b88ddc5f68bf8a433bc57f70bf4d55e6631e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:57:53 +0000 Subject: [PATCH 448/532] feat(api): OpenAPI spec update via Stainless API (#929) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c1d464865fd..10556b9b008 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-799a9bbf5649fd0d0530e2b7cd45106c66c52539d1ff188e812b00570931aef0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6e72e9fb06c3ae4b5c549e441f8f6fb151d8e3c7c58e4e8d6b93a375b23100d0.yml From 53842105e14b0bbed52311da07a5c7396fe09e03 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:09:24 +0000 Subject: [PATCH 449/532] feat(api): OpenAPI spec update via Stainless API (#930) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 10556b9b008..c1d464865fd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6e72e9fb06c3ae4b5c549e441f8f6fb151d8e3c7c58e4e8d6b93a375b23100d0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-799a9bbf5649fd0d0530e2b7cd45106c66c52539d1ff188e812b00570931aef0.yml From 912276c1fd9a39bd0bba3e79f809af55122488ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:14:06 +0000 Subject: [PATCH 450/532] feat(api): OpenAPI spec update via Stainless API (#931) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c1d464865fd..10556b9b008 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-799a9bbf5649fd0d0530e2b7cd45106c66c52539d1ff188e812b00570931aef0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6e72e9fb06c3ae4b5c549e441f8f6fb151d8e3c7c58e4e8d6b93a375b23100d0.yml From a1758adc9d2920cc77be660f8d2ae15be0a91b68 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:16:20 +0000 Subject: [PATCH 451/532] feat(api): OpenAPI spec update via Stainless API (#932) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 10556b9b008..c1d464865fd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6e72e9fb06c3ae4b5c549e441f8f6fb151d8e3c7c58e4e8d6b93a375b23100d0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-799a9bbf5649fd0d0530e2b7cd45106c66c52539d1ff188e812b00570931aef0.yml From 02fe287f003629a048370f66b452b4875f1f593f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:18:33 +0000 Subject: [PATCH 452/532] feat(api): OpenAPI spec update via Stainless API (#933) --- .stats.yml | 2 +- src/cloudflare/types/ai_gateway/log_get_response.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c1d464865fd..fb231383dbe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-799a9bbf5649fd0d0530e2b7cd45106c66c52539d1ff188e812b00570931aef0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-251166f81d34bc492cd6c4fdd7ac8e6861c3541b3f6daee95299402290925165.yml diff --git a/src/cloudflare/types/ai_gateway/log_get_response.py b/src/cloudflare/types/ai_gateway/log_get_response.py index fd96ae02af1..c78976e56d4 100644 --- a/src/cloudflare/types/ai_gateway/log_get_response.py +++ b/src/cloudflare/types/ai_gateway/log_get_response.py @@ -35,8 +35,12 @@ class LogGetResponseItem(BaseModel): metadata: Optional[str] = None + request_content_type: Optional[str] = None + request_type: Optional[str] = None + response_content_type: Optional[str] = None + status_code: Optional[int] = None step: Optional[int] = None From a1af91e7e01b6e610d12f64346c5c1335c6e76c5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:20:40 +0000 Subject: [PATCH 453/532] feat(api): OpenAPI spec update via Stainless API (#934) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fb231383dbe..695ddd7d27e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-251166f81d34bc492cd6c4fdd7ac8e6861c3541b3f6daee95299402290925165.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-48e28a02de2c33ece25ad1d8b607437a22080c5dedf1fdc6a3a6376191511969.yml From 3a93f412ba0bd69443b91c2e2c4609eb0c1ad82f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:54:11 +0000 Subject: [PATCH 454/532] feat(api): OpenAPI spec update via Stainless API (#935) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 695ddd7d27e..42f2e9dfae1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-48e28a02de2c33ece25ad1d8b607437a22080c5dedf1fdc6a3a6376191511969.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7189cd1704f80d8969496b778da756eb0513a1ff672a7b92832621a442392df.yml From b852f702de447c36d347fac54b08ee052b4803f5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:20:23 +0000 Subject: [PATCH 455/532] feat(api): OpenAPI spec update via Stainless API (#936) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 42f2e9dfae1..1ec79c56fc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7189cd1704f80d8969496b778da756eb0513a1ff672a7b92832621a442392df.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b0b298b696064472a3286b206fea41a653304187a69a9d0f0c30d58ff6b94d93.yml From e1195acc48a21dec20c5e59da1a3ea5263ca9f47 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:22:34 +0000 Subject: [PATCH 456/532] feat(api): OpenAPI spec update via Stainless API (#937) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1ec79c56fc9..42f2e9dfae1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b0b298b696064472a3286b206fea41a653304187a69a9d0f0c30d58ff6b94d93.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7189cd1704f80d8969496b778da756eb0513a1ff672a7b92832621a442392df.yml From bd703b43af9642113eb06b19934055dc8c00a251 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:28:38 +0000 Subject: [PATCH 457/532] feat(api): OpenAPI spec update via Stainless API (#938) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 42f2e9dfae1..179d467f7b3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f7189cd1704f80d8969496b778da756eb0513a1ff672a7b92832621a442392df.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-461929b1b5afaf566588db157668b281c06fc476c889e6de6d2dc85684dd3b0b.yml From ef6191f69de92028baaa4229db1bc7f6b001f3e5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:59:21 +0000 Subject: [PATCH 458/532] feat(api): OpenAPI spec update via Stainless API (#939) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 179d467f7b3..1a485b2e26e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-461929b1b5afaf566588db157668b281c06fc476c889e6de6d2dc85684dd3b0b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c75e08772b144c7d39368408731ab6653af70f38c28776c04deeed19e186ad22.yml From 14b0f6621fde28becf1e808db62fbff4dd5b0d3c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 16:47:21 +0000 Subject: [PATCH 459/532] feat(api): OpenAPI spec update via Stainless API (#940) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1a485b2e26e..e9195a53d77 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c75e08772b144c7d39368408731ab6653af70f38c28776c04deeed19e186ad22.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b8f040caccf466c729ad97c89d1d67efa0db92032827dbb89bdb534d512776a.yml From 9da9ede896cbed33dab7b6c94be84c8c9669508a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:30:28 +0000 Subject: [PATCH 460/532] feat(api): OpenAPI spec update via Stainless API (#941) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e9195a53d77..1ec79c56fc9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3b8f040caccf466c729ad97c89d1d67efa0db92032827dbb89bdb534d512776a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b0b298b696064472a3286b206fea41a653304187a69a9d0f0c30d58ff6b94d93.yml From cb1414919426a182bdd69c42bf739c2b8ae31295 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:32:48 +0000 Subject: [PATCH 461/532] feat(api): OpenAPI spec update via Stainless API (#942) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1ec79c56fc9..1a485b2e26e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b0b298b696064472a3286b206fea41a653304187a69a9d0f0c30d58ff6b94d93.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c75e08772b144c7d39368408731ab6653af70f38c28776c04deeed19e186ad22.yml From 72884ce88dbb895fe462582ea9d949f079569e7e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:35:08 +0000 Subject: [PATCH 462/532] feat(api): OpenAPI spec update via Stainless API (#943) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1a485b2e26e..179d467f7b3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c75e08772b144c7d39368408731ab6653af70f38c28776c04deeed19e186ad22.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-461929b1b5afaf566588db157668b281c06fc476c889e6de6d2dc85684dd3b0b.yml From d62120038551a25bb438529ea4106aa8b9c9e1ac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:10:52 +0000 Subject: [PATCH 463/532] feat(api): OpenAPI spec update via Stainless API (#944) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 179d467f7b3..e95c24fcea9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-461929b1b5afaf566588db157668b281c06fc476c889e6de6d2dc85684dd3b0b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-10a753356d5981b9dc2ea375f82d6d7394b33a3479852fabb987883dff9d30d9.yml From 5ba6aa2fdcdafdef77a6bde34245383093d85e38 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:25:45 +0000 Subject: [PATCH 464/532] feat(api): OpenAPI spec update via Stainless API (#945) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e95c24fcea9..87bd020b671 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-10a753356d5981b9dc2ea375f82d6d7394b33a3479852fabb987883dff9d30d9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-809dc71ed8eb89889ef334ca5c906e9007132a6823ca2e457eaa104c171f48aa.yml From ba3959a51ffcb40e2e1a5d34ee96ec1875bea4cd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 20:59:33 +0000 Subject: [PATCH 465/532] feat(api): OpenAPI spec update via Stainless API (#946) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 87bd020b671..16df9bdbb7d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-809dc71ed8eb89889ef334ca5c906e9007132a6823ca2e457eaa104c171f48aa.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a8b418c4ee750ec86822d47288511679fac8f8c4f67ce699f726925fd0eba16.yml From efcc9ebccaf23f036ffa5e569aa74042c709fd64 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:08:30 +0000 Subject: [PATCH 466/532] feat(api): OpenAPI spec update via Stainless API (#947) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 16df9bdbb7d..246b4871863 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a8b418c4ee750ec86822d47288511679fac8f8c4f67ce699f726925fd0eba16.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96b5069e416336d61323d8bcf354e7c821962a2d5c727d93a42d8a71dd66f345.yml From c90d052713e311b792f2e8d6c1081aef615e92e8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:10:49 +0000 Subject: [PATCH 467/532] feat(api): OpenAPI spec update via Stainless API (#948) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 246b4871863..16df9bdbb7d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96b5069e416336d61323d8bcf354e7c821962a2d5c727d93a42d8a71dd66f345.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a8b418c4ee750ec86822d47288511679fac8f8c4f67ce699f726925fd0eba16.yml From 78265361b34ab207c70f5c9a6a43d9801a8b96c5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:13:33 +0000 Subject: [PATCH 468/532] feat(api): OpenAPI spec update via Stainless API (#949) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 16df9bdbb7d..246b4871863 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6a8b418c4ee750ec86822d47288511679fac8f8c4f67ce699f726925fd0eba16.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96b5069e416336d61323d8bcf354e7c821962a2d5c727d93a42d8a71dd66f345.yml From 00bf60078f7158b263e7be34f56c1dff60fe518c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:15:47 +0000 Subject: [PATCH 469/532] feat(api): OpenAPI spec update via Stainless API (#950) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 246b4871863..afacac1c249 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-96b5069e416336d61323d8bcf354e7c821962a2d5c727d93a42d8a71dd66f345.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e9286bfc3a8928017faeb1e13647ed442f40920306240a58bef108882279838a.yml From 39e0aa0787ac55a1e7da6616724cbf4fde261bbe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 21:35:56 +0000 Subject: [PATCH 470/532] feat(api): OpenAPI spec update via Stainless API (#951) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index afacac1c249..71fd807cc37 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e9286bfc3a8928017faeb1e13647ed442f40920306240a58bef108882279838a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8dcef9f58449044ae01861fe3fab751073a39aa953b36da3bb3f413ea2cafbc2.yml From 7db30f1a64bf0564027e0577cf992bef4c752b75 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 22:31:20 +0000 Subject: [PATCH 471/532] feat(api): OpenAPI spec update via Stainless API (#952) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 71fd807cc37..c4ad890aa36 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8dcef9f58449044ae01861fe3fab751073a39aa953b36da3bb3f413ea2cafbc2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-006fe70343aa3ef4a560a2cd1a8d68653d4f838c85aeab7106e1fbb79999d3d4.yml From 1b6e7fb5063b1c13cc11c3f33d34baf62e77a782 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 22:33:54 +0000 Subject: [PATCH 472/532] feat(api): OpenAPI spec update via Stainless API (#953) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c4ad890aa36..71fd807cc37 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-006fe70343aa3ef4a560a2cd1a8d68653d4f838c85aeab7106e1fbb79999d3d4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8dcef9f58449044ae01861fe3fab751073a39aa953b36da3bb3f413ea2cafbc2.yml From 1a54c89f03b210722717e09169d4ffd07f6ef461 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 01:29:33 +0000 Subject: [PATCH 473/532] feat(api): OpenAPI spec update via Stainless API (#954) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 71fd807cc37..e527984a914 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8dcef9f58449044ae01861fe3fab751073a39aa953b36da3bb3f413ea2cafbc2.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d74ff52531eba014ef7094d273b7c762dabc31c730dc5dfadb9eaaef49e34f91.yml From 3062da94071e16c97847144b5cbec16b481a0b50 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:08:41 +0000 Subject: [PATCH 474/532] feat(api): OpenAPI spec update via Stainless API (#955) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e527984a914..6c39e78a8e7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d74ff52531eba014ef7094d273b7c762dabc31c730dc5dfadb9eaaef49e34f91.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-41c018ac6326b548545294d1e9b667f10cb5e0337351b34407d6e1eaf0ef29a6.yml From 1755024b6ff5d16c49b801f6b82addecc140ec36 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:26:40 +0000 Subject: [PATCH 475/532] feat(api): OpenAPI spec update via Stainless API (#956) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6c39e78a8e7..e527984a914 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-41c018ac6326b548545294d1e9b667f10cb5e0337351b34407d6e1eaf0ef29a6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d74ff52531eba014ef7094d273b7c762dabc31c730dc5dfadb9eaaef49e34f91.yml From da5790328894a566ced0878f3b2e6d70ac27cfcd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:27:38 +0000 Subject: [PATCH 476/532] feat(api): OpenAPI spec update via Stainless API (#957) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e527984a914..c4ad890aa36 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d74ff52531eba014ef7094d273b7c762dabc31c730dc5dfadb9eaaef49e34f91.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-006fe70343aa3ef4a560a2cd1a8d68653d4f838c85aeab7106e1fbb79999d3d4.yml From 578652c4ac86d756a965431bbfac7d9485983a65 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 12:51:43 +0000 Subject: [PATCH 477/532] feat(api): OpenAPI spec update via Stainless API (#958) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c4ad890aa36..6c39e78a8e7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-006fe70343aa3ef4a560a2cd1a8d68653d4f838c85aeab7106e1fbb79999d3d4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-41c018ac6326b548545294d1e9b667f10cb5e0337351b34407d6e1eaf0ef29a6.yml From 9911e8a5ae9c075129174b9a87f057c39ca2dfca Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:09:41 +0000 Subject: [PATCH 478/532] feat(api): OpenAPI spec update via Stainless API (#959) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6c39e78a8e7..e527984a914 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-41c018ac6326b548545294d1e9b667f10cb5e0337351b34407d6e1eaf0ef29a6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d74ff52531eba014ef7094d273b7c762dabc31c730dc5dfadb9eaaef49e34f91.yml From f3cd3a0e495e843468505ccdb9716a9cc330b785 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 14:13:06 +0000 Subject: [PATCH 479/532] feat(api): OpenAPI spec update via Stainless API (#960) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e527984a914..021924421a3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d74ff52531eba014ef7094d273b7c762dabc31c730dc5dfadb9eaaef49e34f91.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3d58351dc0fdbc99a810dbf8010a0b78ee693ef3be9b656377bf1eeed0e0c8b6.yml From 390080678ba70c628de15912eed8b4609436796e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:19:05 +0000 Subject: [PATCH 480/532] feat(api): OpenAPI spec update via Stainless API (#961) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 021924421a3..6c39e78a8e7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3d58351dc0fdbc99a810dbf8010a0b78ee693ef3be9b656377bf1eeed0e0c8b6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-41c018ac6326b548545294d1e9b667f10cb5e0337351b34407d6e1eaf0ef29a6.yml From e272f2d2f3f59d61619ccf848085503ccaebfb06 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:27:25 +0000 Subject: [PATCH 481/532] feat(api): OpenAPI spec update via Stainless API (#962) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6c39e78a8e7..c4ad890aa36 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-41c018ac6326b548545294d1e9b667f10cb5e0337351b34407d6e1eaf0ef29a6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-006fe70343aa3ef4a560a2cd1a8d68653d4f838c85aeab7106e1fbb79999d3d4.yml From e51ae76cb5230e3c28f24e47ab3fa7139dc6f23c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 04:30:33 +0000 Subject: [PATCH 482/532] feat(api): update via SDK Studio (#963) --- .stats.yml | 2 +- api.md | 45 +- src/cloudflare/resources/accounts/members.py | 425 ++++-- src/cloudflare/resources/accounts/roles.py | 8 + .../resources/kv/namespaces/bulk.py | 106 +- .../resources/kv/namespaces/metadata.py | 15 +- .../resources/kv/namespaces/namespaces.py | 130 +- .../resources/kv/namespaces/values.py | 160 ++- src/cloudflare/resources/memberships.py | 90 +- src/cloudflare/resources/storage/analytics.py | 26 +- .../user/tokens/permission_groups.py | 4 +- .../resources/workers/scripts/versions.py | 56 +- src/cloudflare/types/accounts/__init__.py | 1 + .../types/accounts/member_create_params.py | 51 +- .../types/accounts/member_create_response.py | 109 +- .../types/accounts/member_get_response.py | 109 +- .../types/accounts/member_list_params.py | 1 + .../types/accounts/member_list_response.py | 112 ++ .../types/accounts/member_update_params.py | 53 +- .../types/accounts/member_update_response.py | 109 +- .../addressing/address_map_create_params.py | 8 +- .../types/kv/namespace_delete_response.py | 8 +- .../types/kv/namespace_update_response.py | 8 +- .../types/kv/namespaces/__init__.py | 2 +- .../kv/namespaces/bulk_delete_response.py | 8 +- .../types/kv/namespaces/bulk_update_params.py | 4 +- .../kv/namespaces/bulk_update_response.py | 8 +- src/cloudflare/types/kv/namespaces/key.py | 4 +- .../kv/namespaces/metadata_get_response.py | 7 + .../kv/namespaces/value_delete_response.py | 8 +- .../types/kv/namespaces/value_get_response.py | 6 - .../kv/namespaces/value_update_response.py | 8 +- .../memberships/membership_get_response.py | 125 +- .../memberships/membership_update_response.py | 125 +- .../types/user/token_create_params.py | 3 +- .../types/user/token_update_params.py | 3 +- .../types/workers/scripts/__init__.py | 1 + .../workers/scripts/version_list_params.py | 21 + .../workers/scripts/version_list_response.py | 10 +- tests/api_resources/accounts/test_members.py | 1152 +++++++++++++++-- tests/api_resources/accounts/test_roles.py | 24 +- .../addressing/test_address_maps.py | 7 + .../api_resources/kv/namespaces/test_bulk.py | 26 +- .../kv/namespaces/test_metadata.py | 15 +- .../kv/namespaces/test_values.py | 133 +- tests/api_resources/kv/test_namespaces.py | 50 +- tests/api_resources/storage/test_analytics.py | 34 +- tests/api_resources/test_memberships.py | 24 +- tests/api_resources/user/test_tokens.py | 180 ++- .../workers/scripts/test_versions.py | 35 +- 50 files changed, 2928 insertions(+), 731 deletions(-) create mode 100644 src/cloudflare/types/accounts/member_list_response.py create mode 100644 src/cloudflare/types/kv/namespaces/metadata_get_response.py delete mode 100644 src/cloudflare/types/kv/namespaces/value_get_response.py create mode 100644 src/cloudflare/types/workers/scripts/version_list_params.py diff --git a/.stats.yml b/.stats.yml index c4ad890aa36..cf68beefb0d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-006fe70343aa3ef4a560a2cd1a8d68653d4f838c85aeab7106e1fbb79999d3d4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-af1ecaabf305033e1f88b63fa9ff708149d2e8f79c0050c0e046d010c668038c.yml diff --git a/api.md b/api.md index 5d3170fce1e..8caf9c9dae6 100644 --- a/api.md +++ b/api.md @@ -50,6 +50,7 @@ from cloudflare.types.accounts import ( UserWithInviteCode, MemberCreateResponse, MemberUpdateResponse, + MemberListResponse, MemberDeleteResponse, MemberGetResponse, ) @@ -57,11 +58,11 @@ from cloudflare.types.accounts import ( Methods: -- client.accounts.members.create(\*, account_id, \*\*params) -> MemberCreateResponse -- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> MemberUpdateResponse -- client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Member] +- client.accounts.members.create(\*, account_id, \*\*params) -> Optional +- client.accounts.members.update(member_id, \*, account_id, \*\*params) -> Optional +- client.accounts.members.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[MemberListResponse] - client.accounts.members.delete(member_id, \*, account_id) -> Optional -- client.accounts.members.get(member_id, \*, account_id) -> MemberGetResponse +- client.accounts.members.get(member_id, \*, account_id) -> Optional ## Roles @@ -123,10 +124,10 @@ from cloudflare.types.memberships import ( Methods: -- client.memberships.update(membership_id, \*\*params) -> MembershipUpdateResponse +- client.memberships.update(membership_id, \*\*params) -> Optional - client.memberships.list(\*\*params) -> SyncV4PagePaginationArray[Membership] - client.memberships.delete(membership_id) -> Optional -- client.memberships.get(membership_id) -> MembershipGetResponse +- client.memberships.get(membership_id) -> Optional # User @@ -2765,7 +2766,7 @@ from cloudflare.types.workers.scripts import ( Methods: - client.workers.scripts.versions.create(script_name, \*, account_id, \*\*params) -> Optional -- client.workers.scripts.versions.list(script_name, \*, account_id) -> Optional +- client.workers.scripts.versions.list(script_name, \*, account_id, \*\*params) -> SyncV4PagePagination[VersionListResponse] - client.workers.scripts.versions.get(version_id, \*, account_id, script_name) -> Optional ## AccountSettings @@ -2821,11 +2822,11 @@ from cloudflare.types.kv import Namespace, NamespaceUpdateResponse, NamespaceDel Methods: -- client.kv.namespaces.create(\*, account_id, \*\*params) -> Namespace -- client.kv.namespaces.update(namespace_id, \*, account_id, \*\*params) -> NamespaceUpdateResponse +- client.kv.namespaces.create(\*, account_id, \*\*params) -> Optional +- client.kv.namespaces.update(namespace_id, \*, account_id, \*\*params) -> Optional - client.kv.namespaces.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Namespace] -- client.kv.namespaces.delete(namespace_id, \*, account_id) -> NamespaceDeleteResponse -- client.kv.namespaces.get(namespace_id, \*, account_id) -> Namespace +- client.kv.namespaces.delete(namespace_id, \*, account_id) -> Optional +- client.kv.namespaces.get(namespace_id, \*, account_id) -> Optional ### Bulk @@ -2837,8 +2838,8 @@ from cloudflare.types.kv.namespaces import BulkUpdateResponse, BulkDeleteRespons Methods: -- client.kv.namespaces.bulk.update(namespace_id, \*, account_id, \*\*params) -> BulkUpdateResponse -- client.kv.namespaces.bulk.delete(namespace_id, \*, account_id) -> BulkDeleteResponse +- client.kv.namespaces.bulk.update(namespace_id, \*, account_id, \*\*params) -> Optional +- client.kv.namespaces.bulk.delete(namespace_id, \*, account_id) -> Optional ### Keys @@ -2862,25 +2863,21 @@ from cloudflare.types.kv.namespaces import MetadataGetResponse Methods: -- client.kv.namespaces.metadata.get(key_name, \*, account_id, namespace_id) -> object +- client.kv.namespaces.metadata.get(key_name, \*, account_id, namespace_id) -> Optional ### Values Types: ```python -from cloudflare.types.kv.namespaces import ( - ValueUpdateResponse, - ValueDeleteResponse, - ValueGetResponse, -) +from cloudflare.types.kv.namespaces import ValueUpdateResponse, ValueDeleteResponse ``` Methods: -- client.kv.namespaces.values.update(key_name, \*, account_id, namespace_id, \*\*params) -> ValueUpdateResponse -- client.kv.namespaces.values.delete(key_name, \*, account_id, namespace_id) -> ValueDeleteResponse -- client.kv.namespaces.values.get(key_name, \*, account_id, namespace_id) -> str +- client.kv.namespaces.values.update(key_name, \*, account_id, namespace_id, \*\*params) -> Optional +- client.kv.namespaces.values.delete(key_name, \*, account_id, namespace_id) -> Optional +- client.kv.namespaces.values.get(key_name, \*, account_id, namespace_id) -> BinaryAPIResponse # DurableObjects @@ -4474,8 +4471,8 @@ from cloudflare.types.storage import Components, Schema Methods: -- client.storage.analytics.list(\*, account_id, \*\*params) -> Schema -- client.storage.analytics.stored(\*, account_id, \*\*params) -> Components +- client.storage.analytics.list(\*, account_id, \*\*params) -> Optional +- client.storage.analytics.stored(\*, account_id, \*\*params) -> Optional # Stream diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 642cb60d058..36ae1a8926f 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -2,13 +2,14 @@ from __future__ import annotations -from typing import Any, List, Type, Iterable, Optional, cast +from typing import List, Type, Iterable, Optional, cast, overload from typing_extensions import Literal import httpx from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import ( + required_args, maybe_transform, async_maybe_transform, ) @@ -27,8 +28,8 @@ make_request_options, ) from ...types.accounts import member_list_params, member_create_params, member_update_params -from ...types.shared.member import Member from ...types.accounts.member_get_response import MemberGetResponse +from ...types.accounts.member_list_response import MemberListResponse from ...types.accounts.member_create_response import MemberCreateResponse from ...types.accounts.member_delete_response import MemberDeleteResponse from ...types.accounts.member_update_response import MemberUpdateResponse @@ -45,6 +46,7 @@ def with_raw_response(self) -> MembersResourceWithRawResponse: def with_streaming_response(self) -> MembersResourceWithStreamingResponse: return MembersResourceWithStreamingResponse(self) + @overload def create( self, *, @@ -58,11 +60,13 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MemberCreateResponse: + ) -> Optional[MemberCreateResponse]: """ Add a user to the list of members for this account. Args: + account_id: Account identifier tag. + email: The contact email address of the user. roles: Array of roles associated with this member. @@ -75,46 +79,102 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + def create( + self, + *, + account_id: str, + email: str, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], + status: Literal["accepted", "pending"] | 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[MemberCreateResponse]: + """ + Add a user to the list of members for this account. + + Args: + account_id: Account identifier tag. + + email: The contact email address of the user. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) + def create( + self, + *, + account_id: str, + email: str, + roles: List[str] | NotGiven = NOT_GIVEN, + status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | 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[MemberCreateResponse]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - MemberCreateResponse, - self._post( - f"/accounts/{account_id}/members", - body=maybe_transform( - { - "email": email, - "roles": roles, - "status": status, - }, - member_create_params.MemberCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MemberCreateResponse - ), # Union types cannot be passed in as arguments in the type system + return self._post( + f"/accounts/{account_id}/members", + body=maybe_transform( + { + "email": email, + "roles": roles, + "status": status, + "policies": policies, + }, + member_create_params.MemberCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberCreateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberCreateResponse]], ResultWrapper[MemberCreateResponse]), ) + @overload def update( self, member_id: str, *, account_id: str, - roles: Iterable[member_update_params.Role] | NotGiven = NOT_GIVEN, + roles: Iterable[member_update_params.MemberRole] | 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, - ) -> MemberUpdateResponse: + ) -> Optional[MemberUpdateResponse]: """ Modify an account member. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. roles: Roles assigned to this member. @@ -127,22 +187,78 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + def update( + self, + member_id: str, + *, + account_id: str, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], + # 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[MemberUpdateResponse]: + """ + Modify an account member. + + Args: + account_id: Account identifier tag. + + member_id: Membership identifier tag. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id"], ["account_id", "policies"]) + def update( + self, + member_id: str, + *, + account_id: str, + roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | 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[MemberUpdateResponse]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return cast( - MemberUpdateResponse, - self._put( - f"/accounts/{account_id}/members/{member_id}", - body=maybe_transform({"roles": roles}, member_update_params.MemberUpdateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MemberUpdateResponse - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}/members/{member_id}", + body=maybe_transform( + { + "roles": roles, + "policies": policies, + }, + member_update_params.MemberUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberUpdateResponse]], ResultWrapper[MemberUpdateResponse]), ) def list( @@ -160,11 +276,13 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[Member]: + ) -> SyncV4PagePaginationArray[MemberListResponse]: """ List all members of an account. Args: + account_id: Account identifier tag. + direction: Direction to order results. order: Field to order results by. @@ -187,7 +305,7 @@ def list( 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}/members", - page=SyncV4PagePaginationArray[Member], + page=SyncV4PagePaginationArray[MemberListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -204,7 +322,7 @@ def list( member_list_params.MemberListParams, ), ), - model=Member, + model=MemberListResponse, ) def delete( @@ -223,6 +341,8 @@ def delete( Remove a member from an account. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. extra_headers: Send extra headers @@ -260,11 +380,13 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MemberGetResponse: + ) -> Optional[MemberGetResponse]: """ Get information about a specific member of an account. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. extra_headers: Send extra headers @@ -279,15 +401,16 @@ def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return cast( - MemberGetResponse, - self._get( - f"/accounts/{account_id}/members/{member_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast(Any, MemberGetResponse), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/accounts/{account_id}/members/{member_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberGetResponse]], ResultWrapper[MemberGetResponse]), ) @@ -300,6 +423,7 @@ def with_raw_response(self) -> AsyncMembersResourceWithRawResponse: def with_streaming_response(self) -> AsyncMembersResourceWithStreamingResponse: return AsyncMembersResourceWithStreamingResponse(self) + @overload async def create( self, *, @@ -313,11 +437,13 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MemberCreateResponse: + ) -> Optional[MemberCreateResponse]: """ Add a user to the list of members for this account. Args: + account_id: Account identifier tag. + email: The contact email address of the user. roles: Array of roles associated with this member. @@ -330,46 +456,102 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + async def create( + self, + *, + account_id: str, + email: str, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], + status: Literal["accepted", "pending"] | 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[MemberCreateResponse]: + """ + Add a user to the list of members for this account. + + Args: + account_id: Account identifier tag. + + email: The contact email address of the user. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id", "email", "roles"], ["account_id", "email", "policies"]) + async def create( + self, + *, + account_id: str, + email: str, + roles: List[str] | NotGiven = NOT_GIVEN, + status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, + policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | 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[MemberCreateResponse]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - MemberCreateResponse, - await self._post( - f"/accounts/{account_id}/members", - body=await async_maybe_transform( - { - "email": email, - "roles": roles, - "status": status, - }, - member_create_params.MemberCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MemberCreateResponse - ), # Union types cannot be passed in as arguments in the type system + return await self._post( + f"/accounts/{account_id}/members", + body=await async_maybe_transform( + { + "email": email, + "roles": roles, + "status": status, + "policies": policies, + }, + member_create_params.MemberCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberCreateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberCreateResponse]], ResultWrapper[MemberCreateResponse]), ) + @overload async def update( self, member_id: str, *, account_id: str, - roles: Iterable[member_update_params.Role] | NotGiven = NOT_GIVEN, + roles: Iterable[member_update_params.MemberRole] | 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, - ) -> MemberUpdateResponse: + ) -> Optional[MemberUpdateResponse]: """ Modify an account member. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. roles: Roles assigned to this member. @@ -382,22 +564,78 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @overload + async def update( + self, + member_id: str, + *, + account_id: str, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], + # 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[MemberUpdateResponse]: + """ + Modify an account member. + + Args: + account_id: Account identifier tag. + + member_id: Membership identifier tag. + + policies: Array of policies associated with this member. + + 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 + """ + ... + + @required_args(["account_id"], ["account_id", "policies"]) + async def update( + self, + member_id: str, + *, + account_id: str, + roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, + policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | 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[MemberUpdateResponse]: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return cast( - MemberUpdateResponse, - await self._put( - f"/accounts/{account_id}/members/{member_id}", - body=await async_maybe_transform({"roles": roles}, member_update_params.MemberUpdateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MemberUpdateResponse - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}/members/{member_id}", + body=await async_maybe_transform( + { + "roles": roles, + "policies": policies, + }, + member_update_params.MemberUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberUpdateResponse]], ResultWrapper[MemberUpdateResponse]), ) def list( @@ -415,11 +653,13 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Member, AsyncV4PagePaginationArray[Member]]: + ) -> AsyncPaginator[MemberListResponse, AsyncV4PagePaginationArray[MemberListResponse]]: """ List all members of an account. Args: + account_id: Account identifier tag. + direction: Direction to order results. order: Field to order results by. @@ -442,7 +682,7 @@ def list( 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}/members", - page=AsyncV4PagePaginationArray[Member], + page=AsyncV4PagePaginationArray[MemberListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -459,7 +699,7 @@ def list( member_list_params.MemberListParams, ), ), - model=Member, + model=MemberListResponse, ) async def delete( @@ -478,6 +718,8 @@ async def delete( Remove a member from an account. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. extra_headers: Send extra headers @@ -515,11 +757,13 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MemberGetResponse: + ) -> Optional[MemberGetResponse]: """ Get information about a specific member of an account. Args: + account_id: Account identifier tag. + member_id: Membership identifier tag. extra_headers: Send extra headers @@ -534,15 +778,16 @@ async def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not member_id: raise ValueError(f"Expected a non-empty value for `member_id` but received {member_id!r}") - return cast( - MemberGetResponse, - await self._get( - f"/accounts/{account_id}/members/{member_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast(Any, MemberGetResponse), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/accounts/{account_id}/members/{member_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MemberGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MemberGetResponse]], ResultWrapper[MemberGetResponse]), ) diff --git a/src/cloudflare/resources/accounts/roles.py b/src/cloudflare/resources/accounts/roles.py index 2cb8405d641..16c89ca10dd 100644 --- a/src/cloudflare/resources/accounts/roles.py +++ b/src/cloudflare/resources/accounts/roles.py @@ -50,6 +50,8 @@ def list( Get all available roles for an account. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -85,6 +87,8 @@ def get( Get information about a specific role for an account. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -132,6 +136,8 @@ def list( Get all available roles for an account. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -167,6 +173,8 @@ async def get( Get information about a specific role for an account. Args: + account_id: Account identifier tag. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request diff --git a/src/cloudflare/resources/kv/namespaces/bulk.py b/src/cloudflare/resources/kv/namespaces/bulk.py index 9c9ee270e5c..7bc398ecfd9 100644 --- a/src/cloudflare/resources/kv/namespaces/bulk.py +++ b/src/cloudflare/resources/kv/namespaces/bulk.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Iterable, cast +from typing import Type, Iterable, Optional, cast import httpx @@ -51,7 +51,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BulkUpdateResponse: + ) -> Optional[BulkUpdateResponse]: """Write multiple keys and values at once. Body should be an array of up to 10,000 @@ -78,22 +78,17 @@ def update( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - BulkUpdateResponse, - self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", - body=maybe_transform(body, bulk_update_params.BulkUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[BulkUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[BulkUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + body=maybe_transform(body, bulk_update_params.BulkUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BulkUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[BulkUpdateResponse]], ResultWrapper[BulkUpdateResponse]), ) def delete( @@ -107,7 +102,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BulkDeleteResponse: + ) -> Optional[BulkDeleteResponse]: """Remove multiple KV pairs from the namespace. Body should be an array of up to @@ -130,21 +125,16 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - BulkDeleteResponse, - self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[BulkDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[BulkDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BulkDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[BulkDeleteResponse]], ResultWrapper[BulkDeleteResponse]), ) @@ -169,7 +159,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BulkUpdateResponse: + ) -> Optional[BulkUpdateResponse]: """Write multiple keys and values at once. Body should be an array of up to 10,000 @@ -196,22 +186,17 @@ async def update( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - BulkUpdateResponse, - await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", - body=await async_maybe_transform(body, bulk_update_params.BulkUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[BulkUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[BulkUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + body=await async_maybe_transform(body, bulk_update_params.BulkUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BulkUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[BulkUpdateResponse]], ResultWrapper[BulkUpdateResponse]), ) async def delete( @@ -225,7 +210,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> BulkDeleteResponse: + ) -> Optional[BulkDeleteResponse]: """Remove multiple KV pairs from the namespace. Body should be an array of up to @@ -248,21 +233,16 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - BulkDeleteResponse, - await self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[BulkDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[BulkDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[BulkDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[BulkDeleteResponse]], ResultWrapper[BulkDeleteResponse]), ) diff --git a/src/cloudflare/resources/kv/namespaces/metadata.py b/src/cloudflare/resources/kv/namespaces/metadata.py index b9a442c88b0..9112053105f 100644 --- a/src/cloudflare/resources/kv/namespaces/metadata.py +++ b/src/cloudflare/resources/kv/namespaces/metadata.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -19,6 +19,7 @@ from ...._base_client import ( make_request_options, ) +from ....types.kv.namespaces.metadata_get_response import MetadataGetResponse __all__ = ["MetadataResource", "AsyncMetadataResource"] @@ -44,7 +45,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> Optional[MetadataGetResponse]: """Returns the metadata associated with the given key in the given namespace. Use @@ -80,9 +81,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[object]._unwrapper, + post_parser=ResultWrapper[Optional[MetadataGetResponse]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[MetadataGetResponse]], ResultWrapper[MetadataGetResponse]), ) @@ -107,7 +108,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> Optional[MetadataGetResponse]: """Returns the metadata associated with the given key in the given namespace. Use @@ -143,9 +144,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[object]._unwrapper, + post_parser=ResultWrapper[Optional[MetadataGetResponse]]._unwrapper, ), - cast_to=cast(Type[object], ResultWrapper[object]), + cast_to=cast(Type[Optional[MetadataGetResponse]], ResultWrapper[MetadataGetResponse]), ) diff --git a/src/cloudflare/resources/kv/namespaces/namespaces.py b/src/cloudflare/resources/kv/namespaces/namespaces.py index 5f25f6cfbf3..be73605e215 100644 --- a/src/cloudflare/resources/kv/namespaces/namespaces.py +++ b/src/cloudflare/resources/kv/namespaces/namespaces.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -102,7 +102,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Namespace: + ) -> Optional[Namespace]: """Creates a namespace under the given title. A `400` is returned if the account @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Namespace]._unwrapper, + post_parser=ResultWrapper[Optional[Namespace]]._unwrapper, ), - cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + cast_to=cast(Type[Optional[Namespace]], ResultWrapper[Namespace]), ) def update( @@ -149,7 +149,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> NamespaceUpdateResponse: + ) -> Optional[NamespaceUpdateResponse]: """ Modifies a namespace's title. @@ -172,22 +172,17 @@ def update( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - NamespaceUpdateResponse, - self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", - body=maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[NamespaceUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[NamespaceUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + body=maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[NamespaceUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[NamespaceUpdateResponse]], ResultWrapper[NamespaceUpdateResponse]), ) def list( @@ -261,7 +256,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> NamespaceDeleteResponse: + ) -> Optional[NamespaceDeleteResponse]: """ Deletes the namespace corresponding to the given ID. @@ -282,21 +277,16 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - NamespaceDeleteResponse, - self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[NamespaceDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[NamespaceDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[NamespaceDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[NamespaceDeleteResponse]], ResultWrapper[NamespaceDeleteResponse]), ) def get( @@ -310,7 +300,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Namespace: + ) -> Optional[Namespace]: """ Get the namespace corresponding to the given ID. @@ -338,9 +328,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Namespace]._unwrapper, + post_parser=ResultWrapper[Optional[Namespace]]._unwrapper, ), - cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + cast_to=cast(Type[Optional[Namespace]], ResultWrapper[Namespace]), ) @@ -380,7 +370,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Namespace: + ) -> Optional[Namespace]: """Creates a namespace under the given title. A `400` is returned if the account @@ -410,9 +400,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Namespace]._unwrapper, + post_parser=ResultWrapper[Optional[Namespace]]._unwrapper, ), - cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + cast_to=cast(Type[Optional[Namespace]], ResultWrapper[Namespace]), ) async def update( @@ -427,7 +417,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> NamespaceUpdateResponse: + ) -> Optional[NamespaceUpdateResponse]: """ Modifies a namespace's title. @@ -450,22 +440,17 @@ async def update( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - NamespaceUpdateResponse, - await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", - body=await async_maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[NamespaceUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[NamespaceUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + body=await async_maybe_transform({"title": title}, namespace_update_params.NamespaceUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[NamespaceUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[NamespaceUpdateResponse]], ResultWrapper[NamespaceUpdateResponse]), ) def list( @@ -539,7 +524,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> NamespaceDeleteResponse: + ) -> Optional[NamespaceDeleteResponse]: """ Deletes the namespace corresponding to the given ID. @@ -560,21 +545,16 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not namespace_id: raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") - return cast( - NamespaceDeleteResponse, - await self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[NamespaceDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[NamespaceDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[NamespaceDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[NamespaceDeleteResponse]], ResultWrapper[NamespaceDeleteResponse]), ) async def get( @@ -588,7 +568,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Namespace: + ) -> Optional[Namespace]: """ Get the namespace corresponding to the given ID. @@ -616,9 +596,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Namespace]._unwrapper, + post_parser=ResultWrapper[Optional[Namespace]]._unwrapper, ), - cast_to=cast(Type[Namespace], ResultWrapper[Namespace]), + cast_to=cast(Type[Optional[Namespace]], ResultWrapper[Namespace]), ) diff --git a/src/cloudflare/resources/kv/namespaces/values.py b/src/cloudflare/resources/kv/namespaces/values.py index 011fb16adde..b80c2b635bb 100644 --- a/src/cloudflare/resources/kv/namespaces/values.py +++ b/src/cloudflare/resources/kv/namespaces/values.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, cast +from typing import Type, Optional, cast import httpx @@ -14,10 +14,18 @@ from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, + to_custom_raw_response_wrapper, async_to_streamed_response_wrapper, + to_custom_streamed_response_wrapper, + async_to_custom_raw_response_wrapper, + async_to_custom_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper from ...._base_client import ( @@ -53,7 +61,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ValueUpdateResponse: + ) -> Optional[ValueUpdateResponse]: """Write a value identified by a key. Use URL-encoding to use special characters @@ -89,28 +97,23 @@ def update( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") - return cast( - ValueUpdateResponse, - self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", - body=maybe_transform( - { - "metadata": metadata, - "value": value, - }, - value_update_params.ValueUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ValueUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ValueUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + body=maybe_transform( + { + "metadata": metadata, + "value": value, + }, + value_update_params.ValueUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ValueUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[ValueUpdateResponse]], ResultWrapper[ValueUpdateResponse]), ) def delete( @@ -125,7 +128,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ValueDeleteResponse: + ) -> Optional[ValueDeleteResponse]: """Remove a KV pair from the namespace. Use URL-encoding to use special characters @@ -153,21 +156,16 @@ def delete( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") - return cast( - ValueDeleteResponse, - self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ValueDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ValueDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ValueDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[ValueDeleteResponse]], ResultWrapper[ValueDeleteResponse]), ) def get( @@ -182,7 +180,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> str: + ) -> BinaryAPIResponse: """Returns the value associated with the given key in the given namespace. Use @@ -213,12 +211,13 @@ def get( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") + extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return self._get( f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=str, + cast_to=BinaryAPIResponse, ) @@ -245,7 +244,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ValueUpdateResponse: + ) -> Optional[ValueUpdateResponse]: """Write a value identified by a key. Use URL-encoding to use special characters @@ -281,28 +280,23 @@ async def update( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") - return cast( - ValueUpdateResponse, - await self._put( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", - body=await async_maybe_transform( - { - "metadata": metadata, - "value": value, - }, - value_update_params.ValueUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ValueUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ValueUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + body=await async_maybe_transform( + { + "metadata": metadata, + "value": value, + }, + value_update_params.ValueUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ValueUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[ValueUpdateResponse]], ResultWrapper[ValueUpdateResponse]), ) async def delete( @@ -317,7 +311,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ValueDeleteResponse: + ) -> Optional[ValueDeleteResponse]: """Remove a KV pair from the namespace. Use URL-encoding to use special characters @@ -345,21 +339,16 @@ async def delete( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") - return cast( - ValueDeleteResponse, - await self._delete( - f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ValueDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ValueDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ValueDeleteResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[ValueDeleteResponse]], ResultWrapper[ValueDeleteResponse]), ) async def get( @@ -374,7 +363,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> str: + ) -> AsyncBinaryAPIResponse: """Returns the value associated with the given key in the given namespace. Use @@ -405,12 +394,13 @@ async def get( raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}") if not key_name: raise ValueError(f"Expected a non-empty value for `key_name` but received {key_name!r}") + extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return await self._get( f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=str, + cast_to=AsyncBinaryAPIResponse, ) @@ -424,8 +414,9 @@ def __init__(self, values: ValuesResource) -> None: self.delete = to_raw_response_wrapper( values.delete, ) - self.get = to_raw_response_wrapper( + self.get = to_custom_raw_response_wrapper( values.get, + BinaryAPIResponse, ) @@ -439,8 +430,9 @@ def __init__(self, values: AsyncValuesResource) -> None: self.delete = async_to_raw_response_wrapper( values.delete, ) - self.get = async_to_raw_response_wrapper( + self.get = async_to_custom_raw_response_wrapper( values.get, + AsyncBinaryAPIResponse, ) @@ -454,8 +446,9 @@ def __init__(self, values: ValuesResource) -> None: self.delete = to_streamed_response_wrapper( values.delete, ) - self.get = to_streamed_response_wrapper( + self.get = to_custom_streamed_response_wrapper( values.get, + StreamedBinaryAPIResponse, ) @@ -469,6 +462,7 @@ def __init__(self, values: AsyncValuesResource) -> None: self.delete = async_to_streamed_response_wrapper( values.delete, ) - self.get = async_to_streamed_response_wrapper( + self.get = async_to_custom_streamed_response_wrapper( values.get, + AsyncStreamedBinaryAPIResponse, ) diff --git a/src/cloudflare/resources/memberships.py b/src/cloudflare/resources/memberships.py index 0884e4c7e8b..b4c963fbea7 100644 --- a/src/cloudflare/resources/memberships.py +++ b/src/cloudflare/resources/memberships.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Optional, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -55,7 +55,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipUpdateResponse: + ) -> Optional[MembershipUpdateResponse]: """ Accept or reject this account invitation. @@ -74,18 +74,17 @@ def update( """ if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") - return cast( - MembershipUpdateResponse, - self._put( - f"/memberships/{membership_id}", - body=maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MembershipUpdateResponse - ), # Union types cannot be passed in as arguments in the type system + return self._put( + f"/memberships/{membership_id}", + body=maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MembershipUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MembershipUpdateResponse]], ResultWrapper[MembershipUpdateResponse]), ) def list( @@ -202,7 +201,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipGetResponse: + ) -> Optional[MembershipGetResponse]: """ Get a specific membership. @@ -219,17 +218,16 @@ def get( """ if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") - return cast( - MembershipGetResponse, - self._get( - f"/memberships/{membership_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MembershipGetResponse - ), # Union types cannot be passed in as arguments in the type system + return self._get( + f"/memberships/{membership_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MembershipGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MembershipGetResponse]], ResultWrapper[MembershipGetResponse]), ) @@ -253,7 +251,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipUpdateResponse: + ) -> Optional[MembershipUpdateResponse]: """ Accept or reject this account invitation. @@ -272,18 +270,17 @@ async def update( """ if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") - return cast( - MembershipUpdateResponse, - await self._put( - f"/memberships/{membership_id}", - body=await async_maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MembershipUpdateResponse - ), # Union types cannot be passed in as arguments in the type system + return await self._put( + f"/memberships/{membership_id}", + body=await async_maybe_transform({"status": status}, membership_update_params.MembershipUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MembershipUpdateResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MembershipUpdateResponse]], ResultWrapper[MembershipUpdateResponse]), ) def list( @@ -400,7 +397,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MembershipGetResponse: + ) -> Optional[MembershipGetResponse]: """ Get a specific membership. @@ -417,17 +414,16 @@ async def get( """ if not membership_id: raise ValueError(f"Expected a non-empty value for `membership_id` but received {membership_id!r}") - return cast( - MembershipGetResponse, - await self._get( - f"/memberships/{membership_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, MembershipGetResponse - ), # Union types cannot be passed in as arguments in the type system + return await self._get( + f"/memberships/{membership_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[MembershipGetResponse]]._unwrapper, ), + cast_to=cast(Type[Optional[MembershipGetResponse]], ResultWrapper[MembershipGetResponse]), ) diff --git a/src/cloudflare/resources/storage/analytics.py b/src/cloudflare/resources/storage/analytics.py index 9a0621a4f2c..dfef4b35536 100644 --- a/src/cloudflare/resources/storage/analytics.py +++ b/src/cloudflare/resources/storage/analytics.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -50,7 +50,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Schema: + ) -> Optional[Schema]: """ Retrieves Workers KV request metrics for the given account. @@ -77,9 +77,9 @@ def list( extra_body=extra_body, timeout=timeout, query=maybe_transform({"query": query}, analytics_list_params.AnalyticsListParams), - post_parser=ResultWrapper[Schema]._unwrapper, + post_parser=ResultWrapper[Optional[Schema]]._unwrapper, ), - cast_to=cast(Type[Schema], ResultWrapper[Schema]), + cast_to=cast(Type[Optional[Schema]], ResultWrapper[Schema]), ) def stored( @@ -93,7 +93,7 @@ def stored( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Components: + ) -> Optional[Components]: """ Retrieves Workers KV stored data metrics for the given account. @@ -120,9 +120,9 @@ def stored( extra_body=extra_body, timeout=timeout, query=maybe_transform({"query": query}, analytics_stored_params.AnalyticsStoredParams), - post_parser=ResultWrapper[Components]._unwrapper, + post_parser=ResultWrapper[Optional[Components]]._unwrapper, ), - cast_to=cast(Type[Components], ResultWrapper[Components]), + cast_to=cast(Type[Optional[Components]], ResultWrapper[Components]), ) @@ -146,7 +146,7 @@ async def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Schema: + ) -> Optional[Schema]: """ Retrieves Workers KV request metrics for the given account. @@ -173,9 +173,9 @@ async def list( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"query": query}, analytics_list_params.AnalyticsListParams), - post_parser=ResultWrapper[Schema]._unwrapper, + post_parser=ResultWrapper[Optional[Schema]]._unwrapper, ), - cast_to=cast(Type[Schema], ResultWrapper[Schema]), + cast_to=cast(Type[Optional[Schema]], ResultWrapper[Schema]), ) async def stored( @@ -189,7 +189,7 @@ async def stored( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Components: + ) -> Optional[Components]: """ Retrieves Workers KV stored data metrics for the given account. @@ -216,9 +216,9 @@ async def stored( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"query": query}, analytics_stored_params.AnalyticsStoredParams), - post_parser=ResultWrapper[Components]._unwrapper, + post_parser=ResultWrapper[Optional[Components]]._unwrapper, ), - cast_to=cast(Type[Components], ResultWrapper[Components]), + cast_to=cast(Type[Optional[Components]], ResultWrapper[Components]), ) diff --git a/src/cloudflare/resources/user/tokens/permission_groups.py b/src/cloudflare/resources/user/tokens/permission_groups.py index 427b3944862..28efd8ca0e4 100644 --- a/src/cloudflare/resources/user/tokens/permission_groups.py +++ b/src/cloudflare/resources/user/tokens/permission_groups.py @@ -41,7 +41,7 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> SyncSinglePage[object]: - """Find all available permission groups.""" + """Find all available permission groups for API Tokens""" return self._get_api_list( "/user/tokens/permission_groups", page=SyncSinglePage[object], @@ -71,7 +71,7 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AsyncPaginator[object, AsyncSinglePage[object]]: - """Find all available permission groups.""" + """Find all available permission groups for API Tokens""" return self._get_api_list( "/user/tokens/permission_groups", page=AsyncSinglePage[object], diff --git a/src/cloudflare/resources/workers/scripts/versions.py b/src/cloudflare/resources/workers/scripts/versions.py index 493ece2bd84..a13d69c5e8d 100644 --- a/src/cloudflare/resources/workers/scripts/versions.py +++ b/src/cloudflare/resources/workers/scripts/versions.py @@ -22,10 +22,12 @@ async_to_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper +from ....pagination import SyncV4PagePagination, AsyncV4PagePagination from ...._base_client import ( + AsyncPaginator, make_request_options, ) -from ....types.workers.scripts import version_create_params +from ....types.workers.scripts import version_list_params, version_create_params from ....types.workers.scripts.version_get_response import VersionGetResponse from ....types.workers.scripts.version_list_response import VersionListResponse from ....types.workers.scripts.version_create_response import VersionCreateResponse @@ -113,13 +115,16 @@ def list( script_name: str, *, account_id: str, + deployable: bool | NotGiven = NOT_GIVEN, + page: int | NotGiven = NOT_GIVEN, + per_page: int | 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[VersionListResponse]: + ) -> SyncV4PagePagination[VersionListResponse]: """List of Worker Versions. The first version in the list is the latest version. @@ -129,6 +134,12 @@ def list( script_name: Name of the script. + deployable: Only return versions that can be used in a deployment. Ignores pagination. + + page: Current page. + + per_page: Items per-page. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -141,16 +152,24 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") - return self._get( + return self._get_api_list( f"/accounts/{account_id}/workers/scripts/{script_name}/versions", + page=SyncV4PagePagination[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[VersionListResponse]]._unwrapper, + query=maybe_transform( + { + "deployable": deployable, + "page": page, + "per_page": per_page, + }, + version_list_params.VersionListParams, + ), ), - cast_to=cast(Type[Optional[VersionListResponse]], ResultWrapper[VersionListResponse]), + model=VersionListResponse, ) def get( @@ -276,18 +295,21 @@ async def create( cast_to=cast(Type[Optional[VersionCreateResponse]], ResultWrapper[VersionCreateResponse]), ) - async def list( + def list( self, script_name: str, *, account_id: str, + deployable: bool | NotGiven = NOT_GIVEN, + page: int | NotGiven = NOT_GIVEN, + per_page: int | 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[VersionListResponse]: + ) -> AsyncPaginator[VersionListResponse, AsyncV4PagePagination[VersionListResponse]]: """List of Worker Versions. The first version in the list is the latest version. @@ -297,6 +319,12 @@ async def list( script_name: Name of the script. + deployable: Only return versions that can be used in a deployment. Ignores pagination. + + page: Current page. + + per_page: Items per-page. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -309,16 +337,24 @@ async def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not script_name: raise ValueError(f"Expected a non-empty value for `script_name` but received {script_name!r}") - return await self._get( + return self._get_api_list( f"/accounts/{account_id}/workers/scripts/{script_name}/versions", + page=AsyncV4PagePagination[VersionListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[VersionListResponse]]._unwrapper, + query=maybe_transform( + { + "deployable": deployable, + "page": page, + "per_page": per_page, + }, + version_list_params.VersionListParams, + ), ), - cast_to=cast(Type[Optional[VersionListResponse]], ResultWrapper[VersionListResponse]), + model=VersionListResponse, ) async def get( diff --git a/src/cloudflare/types/accounts/__init__.py b/src/cloudflare/types/accounts/__init__.py index 5b4a4199ba4..4379841c49a 100644 --- a/src/cloudflare/types/accounts/__init__.py +++ b/src/cloudflare/types/accounts/__init__.py @@ -8,6 +8,7 @@ from .account_list_params import AccountListParams as AccountListParams from .member_get_response import MemberGetResponse as MemberGetResponse from .member_create_params import MemberCreateParams as MemberCreateParams +from .member_list_response import MemberListResponse as MemberListResponse from .member_update_params import MemberUpdateParams as MemberUpdateParams from .account_update_params import AccountUpdateParams as AccountUpdateParams from .member_create_response import MemberCreateResponse as MemberCreateResponse diff --git a/src/cloudflare/types/accounts/member_create_params.py b/src/cloudflare/types/accounts/member_create_params.py index 69acda8f5da..1531d624747 100644 --- a/src/cloudflare/types/accounts/member_create_params.py +++ b/src/cloudflare/types/accounts/member_create_params.py @@ -2,14 +2,22 @@ from __future__ import annotations -from typing import List +from typing import List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -__all__ = ["MemberCreateParams"] +__all__ = [ + "MemberCreateParams", + "IamCreateMemberWithRoles", + "IamCreateMemberWithPolicies", + "IamCreateMemberWithPoliciesPolicy", + "IamCreateMemberWithPoliciesPolicyPermissionGroup", + "IamCreateMemberWithPoliciesPolicyResourceGroup", +] -class MemberCreateParams(TypedDict, total=False): +class IamCreateMemberWithRoles(TypedDict, total=False): account_id: Required[str] + """Account identifier tag.""" email: Required[str] """The contact email address of the user.""" @@ -18,3 +26,40 @@ class MemberCreateParams(TypedDict, total=False): """Array of roles associated with this member.""" status: Literal["accepted", "pending"] + + +class IamCreateMemberWithPolicies(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + email: Required[str] + """The contact email address of the user.""" + + policies: Required[Iterable[IamCreateMemberWithPoliciesPolicy]] + """Array of policies associated with this member.""" + + status: Literal["accepted", "pending"] + + +class IamCreateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamCreateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamCreateMemberWithPoliciesPolicy(TypedDict, total=False): + access: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyPermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resource_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyResourceGroup]] + """A list of resource groups that the policy applies to.""" + + +MemberCreateParams = Union[IamCreateMemberWithRoles, IamCreateMemberWithPolicies] diff --git a/src/cloudflare/types/accounts/member_create_response.py b/src/cloudflare/types/accounts/member_create_response.py index 02ed65d99c8..dd71bbe04ce 100644 --- a/src/cloudflare/types/accounts/member_create_response.py +++ b/src/cloudflare/types/accounts/member_create_response.py @@ -1,15 +1,112 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from ..shared.member import Member +from ..shared.role import Role -__all__ = ["MemberCreateResponse", "IamAPIResponseCommon"] +__all__ = [ + "MemberCreateResponse", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", + "User", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Member] = None +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + meta: Optional[object] = None + """Attributes associated to the permission group.""" -MemberCreateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class User(BaseModel): + email: str + """The contact email address of the user.""" + + id: Optional[str] = None + """Identifier""" + + first_name: Optional[str] = None + """User's first name""" + + last_name: Optional[str] = None + """User's last name""" + + two_factor_authentication_enabled: Optional[bool] = None + """Indicates whether two-factor authentication is enabled for the user account. + + Does not apply to API authentication. + """ + + +class MemberCreateResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[Role]] = None + """Roles assigned to this Member.""" + + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" + + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/accounts/member_get_response.py b/src/cloudflare/types/accounts/member_get_response.py index b4ff99e9597..61da641cd72 100644 --- a/src/cloudflare/types/accounts/member_get_response.py +++ b/src/cloudflare/types/accounts/member_get_response.py @@ -1,15 +1,112 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from ..shared.member import Member +from ..shared.role import Role -__all__ = ["MemberGetResponse", "IamAPIResponseCommon"] +__all__ = [ + "MemberGetResponse", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", + "User", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Member] = None +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + meta: Optional[object] = None + """Attributes associated to the permission group.""" -MemberGetResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class User(BaseModel): + email: str + """The contact email address of the user.""" + + id: Optional[str] = None + """Identifier""" + + first_name: Optional[str] = None + """User's first name""" + + last_name: Optional[str] = None + """User's last name""" + + two_factor_authentication_enabled: Optional[bool] = None + """Indicates whether two-factor authentication is enabled for the user account. + + Does not apply to API authentication. + """ + + +class MemberGetResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[Role]] = None + """Roles assigned to this Member.""" + + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" + + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/accounts/member_list_params.py b/src/cloudflare/types/accounts/member_list_params.py index 1b594104750..cda9328b103 100644 --- a/src/cloudflare/types/accounts/member_list_params.py +++ b/src/cloudflare/types/accounts/member_list_params.py @@ -9,6 +9,7 @@ class MemberListParams(TypedDict, total=False): account_id: Required[str] + """Account identifier tag.""" direction: Literal["asc", "desc"] """Direction to order results.""" diff --git a/src/cloudflare/types/accounts/member_list_response.py b/src/cloudflare/types/accounts/member_list_response.py new file mode 100644 index 00000000000..5a8a4f49c10 --- /dev/null +++ b/src/cloudflare/types/accounts/member_list_response.py @@ -0,0 +1,112 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.role import Role + +__all__ = [ + "MemberListResponse", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", + "User", +] + + +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + + meta: Optional[object] = None + """Attributes associated to the permission group.""" + + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class User(BaseModel): + email: str + """The contact email address of the user.""" + + id: Optional[str] = None + """Identifier""" + + first_name: Optional[str] = None + """User's first name""" + + last_name: Optional[str] = None + """User's last name""" + + two_factor_authentication_enabled: Optional[bool] = None + """Indicates whether two-factor authentication is enabled for the user account. + + Does not apply to API authentication. + """ + + +class MemberListResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[Role]] = None + """Roles assigned to this Member.""" + + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" + + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/accounts/member_update_params.py b/src/cloudflare/types/accounts/member_update_params.py index 66b3ee3cbac..559895f2ca0 100644 --- a/src/cloudflare/types/accounts/member_update_params.py +++ b/src/cloudflare/types/accounts/member_update_params.py @@ -2,19 +2,60 @@ from __future__ import annotations -from typing import Iterable -from typing_extensions import Required, TypedDict +from typing import Union, Iterable +from typing_extensions import Literal, Required, TypedDict -__all__ = ["MemberUpdateParams", "Role"] +__all__ = [ + "MemberUpdateParams", + "Member", + "MemberRole", + "IamUpdateMemberWithPolicies", + "IamUpdateMemberWithPoliciesPolicy", + "IamUpdateMemberWithPoliciesPolicyPermissionGroup", + "IamUpdateMemberWithPoliciesPolicyResourceGroup", +] -class MemberUpdateParams(TypedDict, total=False): +class Member(TypedDict, total=False): account_id: Required[str] + """Account identifier tag.""" - roles: Iterable[Role] + roles: Iterable[MemberRole] """Roles assigned to this member.""" -class Role(TypedDict, total=False): +class MemberRole(TypedDict, total=False): id: Required[str] """Role identifier tag.""" + + +class IamUpdateMemberWithPolicies(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + policies: Required[Iterable[IamUpdateMemberWithPoliciesPolicy]] + """Array of policies associated with this member.""" + + +class IamUpdateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamUpdateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): + id: Required[str] + """Identifier of the group.""" + + +class IamUpdateMemberWithPoliciesPolicy(TypedDict, total=False): + access: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyPermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resource_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyResourceGroup]] + """A list of resource groups that the policy applies to.""" + + +MemberUpdateParams = Union[Member, IamUpdateMemberWithPolicies] diff --git a/src/cloudflare/types/accounts/member_update_response.py b/src/cloudflare/types/accounts/member_update_response.py index 47de5ca79fe..0c92f9b20fb 100644 --- a/src/cloudflare/types/accounts/member_update_response.py +++ b/src/cloudflare/types/accounts/member_update_response.py @@ -1,15 +1,112 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from ..shared.member import Member +from ..shared.role import Role -__all__ = ["MemberUpdateResponse", "IamAPIResponseCommon"] +__all__ = [ + "MemberUpdateResponse", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", + "User", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Member] = None +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + meta: Optional[object] = None + """Attributes associated to the permission group.""" -MemberUpdateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class User(BaseModel): + email: str + """The contact email address of the user.""" + + id: Optional[str] = None + """Identifier""" + + first_name: Optional[str] = None + """User's first name""" + + last_name: Optional[str] = None + """User's last name""" + + two_factor_authentication_enabled: Optional[bool] = None + """Indicates whether two-factor authentication is enabled for the user account. + + Does not apply to API authentication. + """ + + +class MemberUpdateResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[Role]] = None + """Roles assigned to this Member.""" + + status: Optional[Literal["accepted", "pending"]] = None + """A member's status in the account.""" + + user: Optional[User] = None + """Details of the user associated to the membership.""" diff --git a/src/cloudflare/types/addressing/address_map_create_params.py b/src/cloudflare/types/addressing/address_map_create_params.py index ac313102d61..b0eae43afc8 100644 --- a/src/cloudflare/types/addressing/address_map_create_params.py +++ b/src/cloudflare/types/addressing/address_map_create_params.py @@ -2,10 +2,12 @@ from __future__ import annotations -from typing import List, Iterable, Optional -from typing_extensions import Required, TypedDict +from typing import List, Union, Iterable, Optional +from datetime import datetime +from typing_extensions import Required, Annotated, TypedDict from .kind import Kind +from ..._utils import PropertyInfo __all__ = ["AddressMapCreateParams", "Membership"] @@ -37,6 +39,8 @@ class AddressMapCreateParams(TypedDict, total=False): class Membership(TypedDict, total=False): + created_at: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + identifier: str """The identifier for the membership (eg. a zone or account tag).""" diff --git a/src/cloudflare/types/kv/namespace_delete_response.py b/src/cloudflare/types/kv/namespace_delete_response.py index 9e59782ae79..eb6f28e4253 100644 --- a/src/cloudflare/types/kv/namespace_delete_response.py +++ b/src/cloudflare/types/kv/namespace_delete_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ..._models import BaseModel __all__ = ["NamespaceDeleteResponse"] -NamespaceDeleteResponse = Union[str, object] + +class NamespaceDeleteResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespace_update_response.py b/src/cloudflare/types/kv/namespace_update_response.py index fbd61fb15c8..b8f763fc2e9 100644 --- a/src/cloudflare/types/kv/namespace_update_response.py +++ b/src/cloudflare/types/kv/namespace_update_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ..._models import BaseModel __all__ = ["NamespaceUpdateResponse"] -NamespaceUpdateResponse = Union[str, object] + +class NamespaceUpdateResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespaces/__init__.py b/src/cloudflare/types/kv/namespaces/__init__.py index e7c21904155..69632f0965e 100644 --- a/src/cloudflare/types/kv/namespaces/__init__.py +++ b/src/cloudflare/types/kv/namespaces/__init__.py @@ -5,9 +5,9 @@ from .key import Key as Key from .key_list_params import KeyListParams as KeyListParams from .bulk_update_params import BulkUpdateParams as BulkUpdateParams -from .value_get_response import ValueGetResponse as ValueGetResponse from .value_update_params import ValueUpdateParams as ValueUpdateParams from .bulk_delete_response import BulkDeleteResponse as BulkDeleteResponse from .bulk_update_response import BulkUpdateResponse as BulkUpdateResponse +from .metadata_get_response import MetadataGetResponse as MetadataGetResponse from .value_delete_response import ValueDeleteResponse as ValueDeleteResponse from .value_update_response import ValueUpdateResponse as ValueUpdateResponse diff --git a/src/cloudflare/types/kv/namespaces/bulk_delete_response.py b/src/cloudflare/types/kv/namespaces/bulk_delete_response.py index 56c602c8530..4ae88607764 100644 --- a/src/cloudflare/types/kv/namespaces/bulk_delete_response.py +++ b/src/cloudflare/types/kv/namespaces/bulk_delete_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ...._models import BaseModel __all__ = ["BulkDeleteResponse"] -BulkDeleteResponse = Union[str, object] + +class BulkDeleteResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespaces/bulk_update_params.py b/src/cloudflare/types/kv/namespaces/bulk_update_params.py index c78d5da68ad..6cb8d8702c8 100644 --- a/src/cloudflare/types/kv/namespaces/bulk_update_params.py +++ b/src/cloudflare/types/kv/namespaces/bulk_update_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Iterable +from typing import Dict, Iterable from typing_extensions import Required, TypedDict __all__ = ["BulkUpdateParams", "Body"] @@ -42,7 +42,7 @@ class Body(TypedDict, total=False): valid. """ - metadata: object + metadata: Dict[str, object] """Arbitrary JSON that is associated with a key.""" value: str diff --git a/src/cloudflare/types/kv/namespaces/bulk_update_response.py b/src/cloudflare/types/kv/namespaces/bulk_update_response.py index 7a1f035d954..55544c65e54 100644 --- a/src/cloudflare/types/kv/namespaces/bulk_update_response.py +++ b/src/cloudflare/types/kv/namespaces/bulk_update_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ...._models import BaseModel __all__ = ["BulkUpdateResponse"] -BulkUpdateResponse = Union[str, object] + +class BulkUpdateResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespaces/key.py b/src/cloudflare/types/kv/namespaces/key.py index 604b5d06192..5b48057e954 100644 --- a/src/cloudflare/types/kv/namespaces/key.py +++ b/src/cloudflare/types/kv/namespaces/key.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import Dict, Optional from ...._models import BaseModel @@ -21,5 +21,5 @@ class Key(BaseModel): will expire. This property is omitted for keys that will not expire. """ - metadata: Optional[object] = None + metadata: Optional[Dict[str, object]] = None """Arbitrary JSON that is associated with a key.""" diff --git a/src/cloudflare/types/kv/namespaces/metadata_get_response.py b/src/cloudflare/types/kv/namespaces/metadata_get_response.py new file mode 100644 index 00000000000..6b0475335e2 --- /dev/null +++ b/src/cloudflare/types/kv/namespaces/metadata_get_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict + +__all__ = ["MetadataGetResponse"] + +MetadataGetResponse = Dict[str, object] diff --git a/src/cloudflare/types/kv/namespaces/value_delete_response.py b/src/cloudflare/types/kv/namespaces/value_delete_response.py index 7c3d2c3fb80..224a80852b0 100644 --- a/src/cloudflare/types/kv/namespaces/value_delete_response.py +++ b/src/cloudflare/types/kv/namespaces/value_delete_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ...._models import BaseModel __all__ = ["ValueDeleteResponse"] -ValueDeleteResponse = Union[str, object] + +class ValueDeleteResponse(BaseModel): + pass diff --git a/src/cloudflare/types/kv/namespaces/value_get_response.py b/src/cloudflare/types/kv/namespaces/value_get_response.py deleted file mode 100644 index 81657f0d82b..00000000000 --- a/src/cloudflare/types/kv/namespaces/value_get_response.py +++ /dev/null @@ -1,6 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - - -__all__ = ["ValueGetResponse"] - -ValueGetResponse = str diff --git a/src/cloudflare/types/kv/namespaces/value_update_response.py b/src/cloudflare/types/kv/namespaces/value_update_response.py index 30f088b4fd9..40ffa943af8 100644 --- a/src/cloudflare/types/kv/namespaces/value_update_response.py +++ b/src/cloudflare/types/kv/namespaces/value_update_response.py @@ -1,7 +1,11 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union + + +from ...._models import BaseModel __all__ = ["ValueUpdateResponse"] -ValueUpdateResponse = Union[str, object] + +class ValueUpdateResponse(BaseModel): + pass diff --git a/src/cloudflare/types/memberships/membership_get_response.py b/src/cloudflare/types/memberships/membership_get_response.py index e586b51180f..d828d038709 100644 --- a/src/cloudflare/types/memberships/membership_get_response.py +++ b/src/cloudflare/types/memberships/membership_get_response.py @@ -1,15 +1,128 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from .membership import Membership +from ..accounts.account import Account +from ..shared.permission_grant import PermissionGrant -__all__ = ["MembershipGetResponse", "IamAPIResponseCommon"] +__all__ = [ + "MembershipGetResponse", + "Permissions", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Membership] = None +class Permissions(BaseModel): + analytics: Optional[PermissionGrant] = None + billing: Optional[PermissionGrant] = None -MembershipGetResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + cache_purge: Optional[PermissionGrant] = None + + dns: Optional[PermissionGrant] = None + + dns_records: Optional[PermissionGrant] = None + + lb: Optional[PermissionGrant] = None + + logs: Optional[PermissionGrant] = None + + organization: Optional[PermissionGrant] = None + + ssl: Optional[PermissionGrant] = None + + waf: Optional[PermissionGrant] = None + + zone_settings: Optional[PermissionGrant] = None + + zones: Optional[PermissionGrant] = None + + +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + + meta: Optional[object] = None + """Attributes associated to the permission group.""" + + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class MembershipGetResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + account: Optional[Account] = None + + api_access_enabled: Optional[bool] = None + """Enterprise only. + + Indicates whether or not API access is enabled specifically for this user on a + given account. + """ + + permissions: Optional[Permissions] = None + """All access permissions for the user at the account.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[str]] = None + """List of role names for the user at the account.""" + + status: Optional[Literal["accepted", "pending", "rejected"]] = None + """Status of this membership.""" diff --git a/src/cloudflare/types/memberships/membership_update_response.py b/src/cloudflare/types/memberships/membership_update_response.py index 6aa89e9311b..ee118776d7c 100644 --- a/src/cloudflare/types/memberships/membership_update_response.py +++ b/src/cloudflare/types/memberships/membership_update_response.py @@ -1,15 +1,128 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel -from .membership import Membership +from ..accounts.account import Account +from ..shared.permission_grant import PermissionGrant -__all__ = ["MembershipUpdateResponse", "IamAPIResponseCommon"] +__all__ = [ + "MembershipUpdateResponse", + "Permissions", + "Policy", + "PolicyPermissionGroup", + "PolicyResourceGroup", + "PolicyResourceGroupScope", + "PolicyResourceGroupScopeObject", +] -class IamAPIResponseCommon(BaseModel): - result: Optional[Membership] = None +class Permissions(BaseModel): + analytics: Optional[PermissionGrant] = None + billing: Optional[PermissionGrant] = None -MembershipUpdateResponse = Union[IamAPIResponseCommon, IamAPIResponseCommon] + cache_purge: Optional[PermissionGrant] = None + + dns: Optional[PermissionGrant] = None + + dns_records: Optional[PermissionGrant] = None + + lb: Optional[PermissionGrant] = None + + logs: Optional[PermissionGrant] = None + + organization: Optional[PermissionGrant] = None + + ssl: Optional[PermissionGrant] = None + + waf: Optional[PermissionGrant] = None + + zone_settings: Optional[PermissionGrant] = None + + zones: Optional[PermissionGrant] = None + + +class PolicyPermissionGroup(BaseModel): + id: str + """Identifier of the group.""" + + meta: Optional[object] = None + """Attributes associated to the permission group.""" + + name: Optional[str] = None + """Name of the group.""" + + +class PolicyResourceGroupScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class PolicyResourceGroupScope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[PolicyResourceGroupScopeObject] + """A list of scope objects for additional context.""" + + +class PolicyResourceGroup(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[PolicyResourceGroupScope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" + + +class Policy(BaseModel): + id: Optional[str] = None + """Policy identifier.""" + + access: Optional[Literal["allow", "deny"]] = None + """Allow or deny operations against the resources.""" + + permission_groups: Optional[List[PolicyPermissionGroup]] = None + """A set of permission groups that are specified to the policy.""" + + resource_groups: Optional[List[PolicyResourceGroup]] = None + """A list of resource groups that the policy applies to.""" + + +class MembershipUpdateResponse(BaseModel): + id: Optional[str] = None + """Membership identifier tag.""" + + account: Optional[Account] = None + + api_access_enabled: Optional[bool] = None + """Enterprise only. + + Indicates whether or not API access is enabled specifically for this user on a + given account. + """ + + permissions: Optional[Permissions] = None + """All access permissions for the user at the account.""" + + policies: Optional[List[Policy]] = None + """Access policy for the membership""" + + roles: Optional[List[str]] = None + """List of role names for the user at the account.""" + + status: Optional[Literal["accepted", "pending", "rejected"]] = None + """Status of this membership.""" diff --git a/src/cloudflare/types/user/token_create_params.py b/src/cloudflare/types/user/token_create_params.py index 842eed61529..b10b10f24ca 100644 --- a/src/cloudflare/types/user/token_create_params.py +++ b/src/cloudflare/types/user/token_create_params.py @@ -32,7 +32,8 @@ class TokenCreateParams(TypedDict, total=False): class PolicyPermissionGroup(TypedDict, total=False): - pass + meta: object + """Attributes associated to the permission group.""" class Policy(TypedDict, total=False): diff --git a/src/cloudflare/types/user/token_update_params.py b/src/cloudflare/types/user/token_update_params.py index 9299975073e..7cd89a8938a 100644 --- a/src/cloudflare/types/user/token_update_params.py +++ b/src/cloudflare/types/user/token_update_params.py @@ -35,7 +35,8 @@ class TokenUpdateParams(TypedDict, total=False): class PolicyPermissionGroup(TypedDict, total=False): - pass + meta: object + """Attributes associated to the permission group.""" class Policy(TypedDict, total=False): diff --git a/src/cloudflare/types/workers/scripts/__init__.py b/src/cloudflare/types/workers/scripts/__init__.py index 233a054aa7a..64f34786b7c 100644 --- a/src/cloudflare/types/workers/scripts/__init__.py +++ b/src/cloudflare/types/workers/scripts/__init__.py @@ -9,6 +9,7 @@ from .tail_get_response import TailGetResponse as TailGetResponse from .tail_create_params import TailCreateParams as TailCreateParams from .setting_edit_params import SettingEditParams as SettingEditParams +from .version_list_params import VersionListParams as VersionListParams from .tail_create_response import TailCreateResponse as TailCreateResponse from .tail_delete_response import TailDeleteResponse as TailDeleteResponse from .version_get_response import VersionGetResponse as VersionGetResponse diff --git a/src/cloudflare/types/workers/scripts/version_list_params.py b/src/cloudflare/types/workers/scripts/version_list_params.py new file mode 100644 index 00000000000..b5c0dd9481e --- /dev/null +++ b/src/cloudflare/types/workers/scripts/version_list_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["VersionListParams"] + + +class VersionListParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + deployable: bool + """Only return versions that can be used in a deployment. Ignores pagination.""" + + page: int + """Current page.""" + + per_page: int + """Items per-page.""" diff --git a/src/cloudflare/types/workers/scripts/version_list_response.py b/src/cloudflare/types/workers/scripts/version_list_response.py index fd3de314931..b992e3fab59 100644 --- a/src/cloudflare/types/workers/scripts/version_list_response.py +++ b/src/cloudflare/types/workers/scripts/version_list_response.py @@ -1,19 +1,15 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Optional from ...._models import BaseModel -__all__ = ["VersionListResponse", "Item"] +__all__ = ["VersionListResponse"] -class Item(BaseModel): +class VersionListResponse(BaseModel): id: Optional[str] = None metadata: Optional[object] = None number: Optional[float] = None - - -class VersionListResponse(BaseModel): - items: Optional[List[Item]] = None diff --git a/tests/api_resources/accounts/test_members.py b/tests/api_resources/accounts/test_members.py index c1062178a50..b739eead76a 100644 --- a/tests/api_resources/accounts/test_members.py +++ b/tests/api_resources/accounts/test_members.py @@ -10,9 +10,9 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.shared import Member from cloudflare.types.accounts import ( MemberGetResponse, + MemberListResponse, MemberCreateResponse, MemberDeleteResponse, MemberUpdateResponse, @@ -25,9 +25,9 @@ class TestMembers: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - def test_method_create(self, client: Cloudflare) -> None: + def test_method_create_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -35,12 +35,12 @@ def test_method_create(self, client: Cloudflare) -> None: "3536bcfad5faccb999b47003c79917fb", ], ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: + def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -49,12 +49,12 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ], status="accepted", ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -66,12 +66,12 @@ 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" member = response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -83,12 +83,12 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: + def test_path_params_create_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.accounts.members.with_raw_response.create( account_id="", @@ -100,60 +100,301 @@ def test_path_params_create(self, client: Cloudflare) -> None: ], ) + @parametrize + def test_method_create_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + status="accepted", + ) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.accounts.members.with_raw_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = response.parse() + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.accounts.members.with_streaming_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = response.parse() + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.accounts.members.with_raw_response.create( + account_id="", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_update(self, client: Cloudflare) -> None: + def test_method_update_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: + def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", roles=[ {"id": "3536bcfad5faccb999b47003c79917fb"}, {"id": "3536bcfad5faccb999b47003c79917fb"}, {"id": "3536bcfad5faccb999b47003c79917fb"}, ], ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", @@ -163,49 +404,291 @@ def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): client.accounts.members.with_raw_response.update( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + member = client.accounts.members.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = response.parse() + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.accounts.members.with_streaming_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = response.parse() + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): + client.accounts.members.with_raw_response.update( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], ) @parametrize def test_method_list(self, client: Cloudflare) -> None: member = client.accounts.members.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: member = client.accounts.members.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", direction="desc", order="status", page=1, per_page=5, status="accepted", ) - assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(SyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -220,7 +703,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: def test_method_delete(self, client: Cloudflare) -> None: member = client.accounts.members.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(Optional[MemberDeleteResponse], member, path=["response"]) @@ -228,7 +711,7 @@ def test_method_delete(self, client: Cloudflare) -> None: def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -240,7 +723,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -261,40 +744,40 @@ def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): client.accounts.members.with_raw_response.delete( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) @parametrize def test_method_get(self, client: Cloudflare) -> None: member = client.accounts.members.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = response.parse() - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -309,7 +792,7 @@ def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): client.accounts.members.with_raw_response.get( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) @@ -317,9 +800,9 @@ class TestAsyncMembers: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -327,12 +810,12 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "3536bcfad5faccb999b47003c79917fb", ], ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -341,12 +824,12 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ], status="accepted", ) - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -358,12 +841,12 @@ 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" member = await response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.create( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", email="user@example.com", roles=[ "3536bcfad5faccb999b47003c79917fb", @@ -375,12 +858,12 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberCreateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.accounts.members.with_raw_response.create( account_id="", @@ -392,60 +875,301 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: ], ) + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + status="accepted", + ) + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.accounts.members.with_raw_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = await response.parse() + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.accounts.members.with_streaming_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = await response.parse() + assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.accounts.members.with_raw_response.create( + account_id="", + email="user@example.com", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", roles=[ {"id": "3536bcfad5faccb999b47003c79917fb"}, {"id": "3536bcfad5faccb999b47003c79917fb"}, {"id": "3536bcfad5faccb999b47003c79917fb"}, ], ) - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.update( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberUpdateResponse, member, path=["response"]) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.accounts.members.with_raw_response.update( "4536bcfad5faccb111b47003c79917fa", @@ -455,49 +1179,291 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): await async_client.accounts.members.with_raw_response.update( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + member = await async_client.accounts.members.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + member = await response.parse() + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.accounts.members.with_streaming_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + member = await response.parse() + assert_matches_type(Optional[MemberUpdateResponse], member, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.accounts.members.with_raw_response.update( + "4536bcfad5faccb111b47003c79917fa", + account_id="", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): + await async_client.accounts.members.with_raw_response.update( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + policies=[ + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + { + "access": "allow", + "permission_groups": [ + {"id": "c8fed203ed3043cba015a93ad1616f1f"}, + {"id": "82e64a83756745bbbb1c9c2701bf816b"}, + ], + "resource_groups": [ + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + {"id": "6d7f2f5f5b1d4a0e9081fdc98d432fd1"}, + ], + }, + ], ) @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", direction="desc", order="status", page=1, per_page=5, status="accepted", ) - assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[Member], member, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[MemberListResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -512,7 +1478,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: async def test_method_delete(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(Optional[MemberDeleteResponse], member, path=["response"]) @@ -520,7 +1486,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -532,7 +1498,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.delete( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -553,40 +1519,40 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): await async_client.accounts.members.with_raw_response.delete( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.get( "4536bcfad5faccb111b47003c79917fa", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" member = await response.parse() - assert_matches_type(MemberGetResponse, member, path=["response"]) + assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) assert cast(Any, response.is_closed) is True @@ -601,5 +1567,5 @@ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `member_id` but received ''"): await async_client.accounts.members.with_raw_response.get( "", - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) diff --git a/tests/api_resources/accounts/test_roles.py b/tests/api_resources/accounts/test_roles.py index 768327bb0a6..4236c1b2b13 100644 --- a/tests/api_resources/accounts/test_roles.py +++ b/tests/api_resources/accounts/test_roles.py @@ -21,14 +21,14 @@ class TestRoles: @parametrize def test_method_list(self, client: Cloudflare) -> None: role = client.accounts.roles.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(SyncSinglePage[Role], role, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.accounts.roles.with_raw_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -39,7 +39,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.accounts.roles.with_streaming_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -60,7 +60,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: def test_method_get(self, client: Cloudflare) -> None: role = client.accounts.roles.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(object, role, path=["response"]) @@ -68,7 +68,7 @@ def test_method_get(self, client: Cloudflare) -> None: def test_raw_response_get(self, client: Cloudflare) -> None: response = client.accounts.roles.with_raw_response.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -80,7 +80,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: def test_streaming_response_get(self, client: Cloudflare) -> None: with client.accounts.roles.with_streaming_response.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -105,14 +105,14 @@ class TestAsyncRoles: @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: role = await async_client.accounts.roles.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(AsyncSinglePage[Role], role, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.roles.with_raw_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -123,7 +123,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.roles.with_streaming_response.list( - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -144,7 +144,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: async def test_method_get(self, async_client: AsyncCloudflare) -> None: role = await async_client.accounts.roles.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert_matches_type(object, role, path=["response"]) @@ -152,7 +152,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.roles.with_raw_response.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) assert response.is_closed is True @@ -164,7 +164,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.roles.with_streaming_response.get( {}, - account_id="string", + account_id="eb78d65290b24279ba6f44721b3ea3c4", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/addressing/test_address_maps.py b/tests/api_resources/addressing/test_address_maps.py index a883e9dfd4b..f8e982e4260 100644 --- a/tests/api_resources/addressing/test_address_maps.py +++ b/tests/api_resources/addressing/test_address_maps.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.addressing import ( AddressMap, @@ -39,14 +40,17 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ips=["192.0.2.1", "192.0.2.1", "192.0.2.1"], memberships=[ { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, @@ -298,14 +302,17 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ips=["192.0.2.1", "192.0.2.1", "192.0.2.1"], memberships=[ { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), "identifier": "023e105f4ecef8ad9ca31a8372d0c353", "kind": "zone", }, diff --git a/tests/api_resources/kv/namespaces/test_bulk.py b/tests/api_resources/kv/namespaces/test_bulk.py index c941e118037..6a37a64f90e 100644 --- a/tests/api_resources/kv/namespaces/test_bulk.py +++ b/tests/api_resources/kv/namespaces/test_bulk.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -24,7 +24,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", body=[{}, {}, {}], ) - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ 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" bulk = response.parse() - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -50,7 +50,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = response.parse() - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) assert cast(Any, response.is_closed) is True @@ -76,7 +76,7 @@ def test_method_delete(self, client: Cloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -88,7 +88,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = response.parse() - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = response.parse() - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) assert cast(Any, response.is_closed) is True @@ -129,7 +129,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", body=[{}, {}, {}], ) - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -142,7 +142,7 @@ 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" bulk = await response.parse() - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -155,7 +155,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = await response.parse() - assert_matches_type(BulkUpdateResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkUpdateResponse], bulk, path=["response"]) assert cast(Any, response.is_closed) is True @@ -181,7 +181,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -193,7 +193,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = await response.parse() - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -205,7 +205,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" bulk = await response.parse() - assert_matches_type(BulkDeleteResponse, bulk, path=["response"]) + assert_matches_type(Optional[BulkDeleteResponse], bulk, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/kv/namespaces/test_metadata.py b/tests/api_resources/kv/namespaces/test_metadata.py index e7f40bbb7bd..7c8a4325a43 100644 --- a/tests/api_resources/kv/namespaces/test_metadata.py +++ b/tests/api_resources/kv/namespaces/test_metadata.py @@ -3,12 +3,13 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare.types.kv.namespaces import MetadataGetResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -23,7 +24,7 @@ def test_method_get(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -36,7 +37,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" metadata = response.parse() - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -49,7 +50,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" metadata = response.parse() - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) assert cast(Any, response.is_closed) is True @@ -87,7 +88,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -100,7 +101,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" metadata = await response.parse() - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -113,7 +114,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" metadata = await response.parse() - assert_matches_type(object, metadata, path=["response"]) + assert_matches_type(Optional[MetadataGetResponse], metadata, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/kv/namespaces/test_values.py b/tests/api_resources/kv/namespaces/test_values.py index af7e9da5b3b..d090fd1683d 100644 --- a/tests/api_resources/kv/namespaces/test_values.py +++ b/tests/api_resources/kv/namespaces/test_values.py @@ -3,16 +3,21 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast +import httpx import pytest +from respx import MockRouter from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.kv.namespaces import ( - ValueDeleteResponse, - ValueUpdateResponse, +from cloudflare._response import ( + BinaryAPIResponse, + AsyncBinaryAPIResponse, + StreamedBinaryAPIResponse, + AsyncStreamedBinaryAPIResponse, ) +from cloudflare.types.kv.namespaces import ValueDeleteResponse, ValueUpdateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -30,7 +35,7 @@ def test_method_update(self, client: Cloudflare) -> None: metadata='{"someMetadataKey": "someMetadataValue"}', value="Some Value", ) - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -46,7 +51,7 @@ 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" value = response.parse() - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -62,7 +67,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = response.parse() - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) assert cast(Any, response.is_closed) is True @@ -103,7 +108,7 @@ def test_method_delete(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -116,7 +121,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = response.parse() - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -129,7 +134,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = response.parse() - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) assert cast(Any, response.is_closed) is True @@ -157,43 +162,61 @@ def test_path_params_delete(self, client: Cloudflare) -> None: ) @parametrize - def test_method_get(self, client: Cloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) value = client.kv.namespaces.values.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(str, value, path=["response"]) + assert value.is_closed + assert value.json() == {"foo": "bar"} + assert cast(Any, value.is_closed) is True + assert isinstance(value, BinaryAPIResponse) @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.kv.namespaces.values.with_raw_response.get( + @pytest.mark.respx(base_url=base_url) + def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + + value = client.kv.namespaces.values.with_raw_response.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - value = response.parse() - assert_matches_type(str, value, path=["response"]) + assert value.is_closed is True + assert value.http_request.headers.get("X-Stainless-Lang") == "python" + assert value.json() == {"foo": "bar"} + assert isinstance(value, BinaryAPIResponse) @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) with client.kv.namespaces.values.with_streaming_response.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ) as value: + assert not value.is_closed + assert value.http_request.headers.get("X-Stainless-Lang") == "python" - value = response.parse() - assert_matches_type(str, value, path=["response"]) + assert value.json() == {"foo": "bar"} + assert cast(Any, value.is_closed) is True + assert isinstance(value, StreamedBinaryAPIResponse) - assert cast(Any, response.is_closed) is True + assert cast(Any, value.is_closed) is True @parametrize + @pytest.mark.respx(base_url=base_url) 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.kv.namespaces.values.with_raw_response.get( @@ -230,7 +253,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: metadata='{"someMetadataKey": "someMetadataValue"}', value="Some Value", ) - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -246,7 +269,7 @@ 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" value = await response.parse() - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -262,7 +285,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = await response.parse() - assert_matches_type(ValueUpdateResponse, value, path=["response"]) + assert_matches_type(Optional[ValueUpdateResponse], value, path=["response"]) assert cast(Any, response.is_closed) is True @@ -303,7 +326,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -316,7 +339,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = await response.parse() - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -329,7 +352,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" value = await response.parse() - assert_matches_type(ValueDeleteResponse, value, path=["response"]) + assert_matches_type(Optional[ValueDeleteResponse], value, path=["response"]) assert cast(Any, response.is_closed) is True @@ -357,43 +380,61 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: ) @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) value = await async_client.kv.namespaces.values.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert_matches_type(str, value, path=["response"]) + assert value.is_closed + assert await value.json() == {"foo": "bar"} + assert cast(Any, value.is_closed) is True + assert isinstance(value, AsyncBinaryAPIResponse) @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.kv.namespaces.values.with_raw_response.get( + @pytest.mark.respx(base_url=base_url) + async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) + + value = await async_client.kv.namespaces.values.with_raw_response.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", ) - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - value = await response.parse() - assert_matches_type(str, value, path=["response"]) + assert value.is_closed is True + assert value.http_request.headers.get("X-Stainless-Lang") == "python" + assert await value.json() == {"foo": "bar"} + assert isinstance(value, AsyncBinaryAPIResponse) @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + @pytest.mark.respx(base_url=base_url) + async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: + respx_mock.get( + "/accounts/023e105f4ecef8ad9ca31a8372d0c353/storage/kv/namespaces/0f2ac74b498b48028cb68387c421e279/values/My-Key" + ).mock(return_value=httpx.Response(200, json={"foo": "bar"})) async with async_client.kv.namespaces.values.with_streaming_response.get( "My-Key", account_id="023e105f4ecef8ad9ca31a8372d0c353", namespace_id="0f2ac74b498b48028cb68387c421e279", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ) as value: + assert not value.is_closed + assert value.http_request.headers.get("X-Stainless-Lang") == "python" - value = await response.parse() - assert_matches_type(str, value, path=["response"]) + assert await value.json() == {"foo": "bar"} + assert cast(Any, value.is_closed) is True + assert isinstance(value, AsyncStreamedBinaryAPIResponse) - assert cast(Any, response.is_closed) is True + assert cast(Any, value.is_closed) is True @parametrize + @pytest.mark.respx(base_url=base_url) 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.kv.namespaces.values.with_raw_response.get( diff --git a/tests/api_resources/kv/test_namespaces.py b/tests/api_resources/kv/test_namespaces.py index d263f63eae8..c8be55ff1e2 100644 --- a/tests/api_resources/kv/test_namespaces.py +++ b/tests/api_resources/kv/test_namespaces.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", title="My Own Namespace", ) - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -40,7 +40,7 @@ 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" namespace = response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -71,7 +71,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", title="My Own Namespace", ) - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -84,7 +84,7 @@ 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" namespace = response.parse() - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -97,7 +97,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -172,7 +172,7 @@ def test_method_delete(self, client: Cloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: @@ -184,7 +184,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: @@ -196,7 +196,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -220,7 +220,7 @@ def test_method_get(self, client: Cloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -232,7 +232,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -244,7 +244,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -272,7 +272,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", title="My Own Namespace", ) - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -284,7 +284,7 @@ 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" namespace = await response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -296,7 +296,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -315,7 +315,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", title="My Own Namespace", ) - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -328,7 +328,7 @@ 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" namespace = await response.parse() - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -341,7 +341,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(NamespaceUpdateResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceUpdateResponse], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -416,7 +416,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -428,7 +428,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: @@ -440,7 +440,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(NamespaceDeleteResponse, namespace, path=["response"]) + assert_matches_type(Optional[NamespaceDeleteResponse], namespace, path=["response"]) assert cast(Any, response.is_closed) is True @@ -464,7 +464,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "0f2ac74b498b48028cb68387c421e279", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -476,7 +476,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" namespace = await response.parse() - assert_matches_type(Namespace, namespace, path=["response"]) + assert_matches_type(Optional[Namespace], namespace, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/storage/test_analytics.py b/tests/api_resources/storage/test_analytics.py index bd9e182261e..d75ef09d287 100644 --- a/tests/api_resources/storage/test_analytics.py +++ b/tests/api_resources/storage/test_analytics.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -23,7 +23,7 @@ def test_method_list(self, client: Cloudflare) -> None: analytics = client.storage.analytics.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: @@ -39,7 +39,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: "until": parse_datetime("2019-01-02T03:20:00Z"), }, ) - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -50,7 +50,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = response.parse() - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = response.parse() - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) assert cast(Any, response.is_closed) is True @@ -77,7 +77,7 @@ def test_method_stored(self, client: Cloudflare) -> None: analytics = client.storage.analytics.stored( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize def test_method_stored_with_all_params(self, client: Cloudflare) -> None: @@ -93,7 +93,7 @@ def test_method_stored_with_all_params(self, client: Cloudflare) -> None: "until": parse_datetime("2019-01-02T03:20:00Z"), }, ) - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize def test_raw_response_stored(self, client: Cloudflare) -> None: @@ -104,7 +104,7 @@ def test_raw_response_stored(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = response.parse() - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize def test_streaming_response_stored(self, client: Cloudflare) -> None: @@ -115,7 +115,7 @@ def test_streaming_response_stored(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = response.parse() - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) assert cast(Any, response.is_closed) is True @@ -135,7 +135,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: analytics = await async_client.storage.analytics.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -151,7 +151,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) "until": parse_datetime("2019-01-02T03:20:00Z"), }, ) - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -162,7 +162,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = await response.parse() - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -173,7 +173,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = await response.parse() - assert_matches_type(Schema, analytics, path=["response"]) + assert_matches_type(Optional[Schema], analytics, path=["response"]) assert cast(Any, response.is_closed) is True @@ -189,7 +189,7 @@ async def test_method_stored(self, async_client: AsyncCloudflare) -> None: analytics = await async_client.storage.analytics.stored( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize async def test_method_stored_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -205,7 +205,7 @@ async def test_method_stored_with_all_params(self, async_client: AsyncCloudflare "until": parse_datetime("2019-01-02T03:20:00Z"), }, ) - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize async def test_raw_response_stored(self, async_client: AsyncCloudflare) -> None: @@ -216,7 +216,7 @@ async def test_raw_response_stored(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = await response.parse() - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) @parametrize async def test_streaming_response_stored(self, async_client: AsyncCloudflare) -> None: @@ -227,7 +227,7 @@ async def test_streaming_response_stored(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" analytics = await response.parse() - assert_matches_type(Components, analytics, path=["response"]) + assert_matches_type(Optional[Components], analytics, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_memberships.py b/tests/api_resources/test_memberships.py index f476c5a8e2f..cb5e1358a4c 100644 --- a/tests/api_resources/test_memberships.py +++ b/tests/api_resources/test_memberships.py @@ -29,7 +29,7 @@ def test_method_update(self, client: Cloudflare) -> None: "4536bcfad5faccb111b47003c79917fa", status="accepted", ) - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ 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" membership = response.parse() - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -53,7 +53,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True @@ -146,7 +146,7 @@ def test_method_get(self, client: Cloudflare) -> None: membership = client.memberships.get( "4536bcfad5faccb111b47003c79917fa", ) - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -157,7 +157,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -168,7 +168,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = response.parse() - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True @@ -189,7 +189,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "4536bcfad5faccb111b47003c79917fa", status="accepted", ) - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -201,7 +201,7 @@ 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" membership = await response.parse() - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -213,7 +213,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipUpdateResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipUpdateResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True @@ -306,7 +306,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: membership = await async_client.memberships.get( "4536bcfad5faccb111b47003c79917fa", ) - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -317,7 +317,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -328,7 +328,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" membership = await response.parse() - assert_matches_type(MembershipGetResponse, membership, path=["response"]) + assert_matches_type(Optional[MembershipGetResponse], membership, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/user/test_tokens.py b/tests/api_resources/user/test_tokens.py index c91fbe44f60..84f1a588242 100644 --- a/tests/api_resources/user/test_tokens.py +++ b/tests/api_resources/user/test_tokens.py @@ -65,7 +65,20 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: policies=[ { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -73,7 +86,20 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -81,7 +107,20 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -222,7 +261,20 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: policies=[ { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -230,7 +282,20 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -238,7 +303,20 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -506,7 +584,20 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare policies=[ { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -514,7 +605,20 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -522,7 +626,20 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -663,7 +780,20 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare policies=[ { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -671,7 +801,20 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -679,7 +822,20 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare }, { "effect": "allow", - "permission_groups": [{}, {}], + "permission_groups": [ + { + "meta": { + "label": "load_balancer_admin", + "scopes": "com.cloudflare.api.account", + } + }, + { + "meta": { + "label": "fbm_user", + "scopes": "com.cloudflare.api.account", + } + }, + ], "resources": { "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", diff --git a/tests/api_resources/workers/scripts/test_versions.py b/tests/api_resources/workers/scripts/test_versions.py index 11e2b69000d..1642da69882 100644 --- a/tests/api_resources/workers/scripts/test_versions.py +++ b/tests/api_resources/workers/scripts/test_versions.py @@ -9,6 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare.pagination import SyncV4PagePagination, AsyncV4PagePagination from cloudflare.types.workers.scripts import ( VersionGetResponse, VersionListResponse, @@ -107,7 +108,18 @@ def test_method_list(self, client: Cloudflare) -> None: "this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(SyncV4PagePagination[VersionListResponse], version, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + version = client.workers.scripts.versions.list( + "this-is_my_script-01", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + deployable=True, + page=0, + per_page=0, + ) + assert_matches_type(SyncV4PagePagination[VersionListResponse], version, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -119,7 +131,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(SyncV4PagePagination[VersionListResponse], version, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -131,7 +143,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = response.parse() - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(SyncV4PagePagination[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True @@ -299,7 +311,18 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: "this-is_my_script-01", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(AsyncV4PagePagination[VersionListResponse], version, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + version = await async_client.workers.scripts.versions.list( + "this-is_my_script-01", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + deployable=True, + page=0, + per_page=0, + ) + assert_matches_type(AsyncV4PagePagination[VersionListResponse], version, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -311,7 +334,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(AsyncV4PagePagination[VersionListResponse], version, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -323,7 +346,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" version = await response.parse() - assert_matches_type(Optional[VersionListResponse], version, path=["response"]) + assert_matches_type(AsyncV4PagePagination[VersionListResponse], version, path=["response"]) assert cast(Any, response.is_closed) is True From 66380bd32051b0f2a8ab1a5bcde8fa2973c546d7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 09:27:09 +0000 Subject: [PATCH 483/532] feat(api): OpenAPI spec update via Stainless API (#964) --- .stats.yml | 2 +- api.md | 1 + .../resources/user/tokens/tokens.py | 9 +++---- src/cloudflare/types/user/__init__.py | 1 + src/cloudflare/types/user/policy_param.py | 24 +++++++++++++++++++ .../types/user/token_create_params.py | 23 ++++-------------- .../types/user/token_update_params.py | 21 +++------------- 7 files changed, 39 insertions(+), 42 deletions(-) create mode 100644 src/cloudflare/types/user/policy_param.py diff --git a/.stats.yml b/.stats.yml index cf68beefb0d..c1b84218a52 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-af1ecaabf305033e1f88b63fa9ff708149d2e8f79c0050c0e046d010c668038c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f5082157bb70165b34f3a552faa44b9693adacaa9613d4b887b251cd744d076f.yml diff --git a/api.md b/api.md index 8caf9c9dae6..1ecb3510f5f 100644 --- a/api.md +++ b/api.md @@ -233,6 +233,7 @@ Types: ```python from cloudflare.types.user import ( CIDRList, + Policy, Token, TokenCreateResponse, TokenUpdateResponse, diff --git a/src/cloudflare/resources/user/tokens/tokens.py b/src/cloudflare/resources/user/tokens/tokens.py index 4b3f1a41c26..877a4388e81 100644 --- a/src/cloudflare/resources/user/tokens/tokens.py +++ b/src/cloudflare/resources/user/tokens/tokens.py @@ -44,6 +44,7 @@ PermissionGroupsResourceWithStreamingResponse, AsyncPermissionGroupsResourceWithStreamingResponse, ) +from ....types.user.policy_param import PolicyParam from ....types.user.token_create_response import TokenCreateResponse from ....types.user.token_delete_response import TokenDeleteResponse from ....types.user.token_verify_response import TokenVerifyResponse @@ -72,7 +73,7 @@ def create( self, *, name: str, - policies: Iterable[token_create_params.Policy], + policies: Iterable[PolicyParam], condition: token_create_params.Condition | NotGiven = NOT_GIVEN, expires_on: Union[str, datetime] | NotGiven = NOT_GIVEN, not_before: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -131,7 +132,7 @@ def update( token_id: object, *, name: str, - policies: Iterable[token_update_params.Policy], + policies: Iterable[PolicyParam], status: Literal["active", "disabled", "expired"], condition: token_update_params.Condition | NotGiven = NOT_GIVEN, expires_on: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -355,7 +356,7 @@ async def create( self, *, name: str, - policies: Iterable[token_create_params.Policy], + policies: Iterable[PolicyParam], condition: token_create_params.Condition | NotGiven = NOT_GIVEN, expires_on: Union[str, datetime] | NotGiven = NOT_GIVEN, not_before: Union[str, datetime] | NotGiven = NOT_GIVEN, @@ -414,7 +415,7 @@ async def update( token_id: object, *, name: str, - policies: Iterable[token_update_params.Policy], + policies: Iterable[PolicyParam], status: Literal["active", "disabled", "expired"], condition: token_update_params.Condition | NotGiven = NOT_GIVEN, expires_on: Union[str, datetime] | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/types/user/__init__.py b/src/cloudflare/types/user/__init__.py index 5b1b8c37ba1..fa5f8dd0d13 100644 --- a/src/cloudflare/types/user/__init__.py +++ b/src/cloudflare/types/user/__init__.py @@ -6,6 +6,7 @@ from .cidr_list import CIDRList as CIDRList from .rate_plan import RatePlan as RatePlan from .organization import Organization as Organization +from .policy_param import PolicyParam as PolicyParam from .subscription import Subscription as Subscription from .rate_plan_param import RatePlanParam as RatePlanParam from .user_edit_params import UserEditParams as UserEditParams diff --git a/src/cloudflare/types/user/policy_param.py b/src/cloudflare/types/user/policy_param.py new file mode 100644 index 00000000000..f6b62435dfe --- /dev/null +++ b/src/cloudflare/types/user/policy_param.py @@ -0,0 +1,24 @@ +# 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 Literal, Required, TypedDict + +__all__ = ["PolicyParam", "PermissionGroup"] + + +class PermissionGroup(TypedDict, total=False): + meta: object + """Attributes associated to the permission group.""" + + +class PolicyParam(TypedDict, total=False): + effect: Required[Literal["allow", "deny"]] + """Allow or deny operations against the resources.""" + + permission_groups: Required[Iterable[PermissionGroup]] + """A set of permission groups that are specified to the policy.""" + + resources: Required[object] + """A list of resource names that the policy applies to.""" diff --git a/src/cloudflare/types/user/token_create_params.py b/src/cloudflare/types/user/token_create_params.py index b10b10f24ca..4ab228c06c6 100644 --- a/src/cloudflare/types/user/token_create_params.py +++ b/src/cloudflare/types/user/token_create_params.py @@ -4,19 +4,20 @@ from typing import List, Union, Iterable from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Required, Annotated, TypedDict from ..._utils import PropertyInfo from .cidr_list import CIDRList +from .policy_param import PolicyParam -__all__ = ["TokenCreateParams", "Policy", "PolicyPermissionGroup", "Condition", "ConditionRequestIP"] +__all__ = ["TokenCreateParams", "Condition", "ConditionRequestIP"] class TokenCreateParams(TypedDict, total=False): name: Required[str] """Token name.""" - policies: Required[Iterable[Policy]] + policies: Required[Iterable[PolicyParam]] """List of access policies assigned to the token.""" condition: Condition @@ -31,22 +32,6 @@ class TokenCreateParams(TypedDict, total=False): """The time before which the token MUST NOT be accepted for processing.""" -class PolicyPermissionGroup(TypedDict, total=False): - meta: object - """Attributes associated to the permission group.""" - - -class Policy(TypedDict, total=False): - effect: Required[Literal["allow", "deny"]] - """Allow or deny operations against the resources.""" - - permission_groups: Required[Iterable[PolicyPermissionGroup]] - """A set of permission groups that are specified to the policy.""" - - resources: Required[object] - """A list of resource names that the policy applies to.""" - - _ConditionRequestIPReservedKeywords = TypedDict( "_ConditionRequestIPReservedKeywords", { diff --git a/src/cloudflare/types/user/token_update_params.py b/src/cloudflare/types/user/token_update_params.py index 7cd89a8938a..d564213465b 100644 --- a/src/cloudflare/types/user/token_update_params.py +++ b/src/cloudflare/types/user/token_update_params.py @@ -8,15 +8,16 @@ from ..._utils import PropertyInfo from .cidr_list import CIDRList +from .policy_param import PolicyParam -__all__ = ["TokenUpdateParams", "Policy", "PolicyPermissionGroup", "Condition", "ConditionRequestIP"] +__all__ = ["TokenUpdateParams", "Condition", "ConditionRequestIP"] class TokenUpdateParams(TypedDict, total=False): name: Required[str] """Token name.""" - policies: Required[Iterable[Policy]] + policies: Required[Iterable[PolicyParam]] """List of access policies assigned to the token.""" status: Required[Literal["active", "disabled", "expired"]] @@ -34,22 +35,6 @@ class TokenUpdateParams(TypedDict, total=False): """The time before which the token MUST NOT be accepted for processing.""" -class PolicyPermissionGroup(TypedDict, total=False): - meta: object - """Attributes associated to the permission group.""" - - -class Policy(TypedDict, total=False): - effect: Required[Literal["allow", "deny"]] - """Allow or deny operations against the resources.""" - - permission_groups: Required[Iterable[PolicyPermissionGroup]] - """A set of permission groups that are specified to the policy.""" - - resources: Required[object] - """A list of resource names that the policy applies to.""" - - _ConditionRequestIPReservedKeywords = TypedDict( "_ConditionRequestIPReservedKeywords", { From 6adbe9ad9f873f7ed67a46b412d310995947810a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 09:29:25 +0000 Subject: [PATCH 484/532] feat(api): OpenAPI spec update via Stainless API (#965) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c1b84218a52..cf68beefb0d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f5082157bb70165b34f3a552faa44b9693adacaa9613d4b887b251cd744d076f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-af1ecaabf305033e1f88b63fa9ff708149d2e8f79c0050c0e046d010c668038c.yml From e8189fd35144f716a5b55dfe26194abda2f00e13 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:02:54 +0000 Subject: [PATCH 485/532] feat(api): OpenAPI spec update via Stainless API (#966) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index cf68beefb0d..c1b84218a52 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-af1ecaabf305033e1f88b63fa9ff708149d2e8f79c0050c0e046d010c668038c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f5082157bb70165b34f3a552faa44b9693adacaa9613d4b887b251cd744d076f.yml From a4c88dfb7e357ff1a44da1e6d75bfe05911fb577 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:05:09 +0000 Subject: [PATCH 486/532] feat(api): OpenAPI spec update via Stainless API (#967) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c1b84218a52..cf68beefb0d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f5082157bb70165b34f3a552faa44b9693adacaa9613d4b887b251cd744d076f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-af1ecaabf305033e1f88b63fa9ff708149d2e8f79c0050c0e046d010c668038c.yml From cefb09fd18869c7a25a6b02c92b489056d510f87 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:09:17 +0000 Subject: [PATCH 487/532] feat(api): OpenAPI spec update via Stainless API (#968) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index cf68beefb0d..f298910cbc3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-af1ecaabf305033e1f88b63fa9ff708149d2e8f79c0050c0e046d010c668038c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263a561e908d0670ade328d0bf353bb05356c254b1f3031b18b06a0d0bf40b44.yml From 71e97aa998ff64ea105d88198f981fb9ffcfae71 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:11:28 +0000 Subject: [PATCH 488/532] feat(api): OpenAPI spec update via Stainless API (#969) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f298910cbc3..c1b84218a52 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263a561e908d0670ade328d0bf353bb05356c254b1f3031b18b06a0d0bf40b44.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f5082157bb70165b34f3a552faa44b9693adacaa9613d4b887b251cd744d076f.yml From 9ced3bb626f729053d508b37e233fac9df9ed909 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:55:30 +0000 Subject: [PATCH 489/532] feat(api): OpenAPI spec update via Stainless API (#970) --- .stats.yml | 2 +- api.md | 23 ++- .../resources/page_shield/connections.py | 26 ++- .../resources/page_shield/page_shield.py | 26 +-- .../resources/page_shield/policies.py | 111 ++++++++----- .../resources/page_shield/scripts.py | 26 ++- src/cloudflare/types/page_shield/__init__.py | 5 +- .../types/page_shield/connection.py | 26 ++- .../page_shield_update_response.py | 10 +- .../types/page_shield/policy_create_params.py | 10 +- .../{policy.py => policy_create_response.py} | 19 +-- .../types/page_shield/policy_get_response.py | 30 ++++ .../types/page_shield/policy_list_response.py | 30 ++++ .../page_shield/policy_update_response.py | 30 ++++ src/cloudflare/types/page_shield/script.py | 37 +++-- .../types/page_shield/script_get_response.py | 37 +++-- src/cloudflare/types/page_shield/setting.py | 10 +- .../page_shield/test_connections.py | 30 ++-- .../page_shield/test_policies.py | 157 ++++++++++-------- .../api_resources/page_shield/test_scripts.py | 30 ++-- tests/api_resources/test_page_shield.py | 30 ++-- 21 files changed, 453 insertions(+), 252 deletions(-) rename src/cloudflare/types/page_shield/{policy.py => policy_create_response.py} (59%) create mode 100644 src/cloudflare/types/page_shield/policy_get_response.py create mode 100644 src/cloudflare/types/page_shield/policy_list_response.py create mode 100644 src/cloudflare/types/page_shield/policy_update_response.py diff --git a/.stats.yml b/.stats.yml index c1b84218a52..fdf1e9f7f3b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f5082157bb70165b34f3a552faa44b9693adacaa9613d4b887b251cd744d076f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml diff --git a/api.md b/api.md index 1ecb3510f5f..0fcdd96ea84 100644 --- a/api.md +++ b/api.md @@ -3122,24 +3122,29 @@ from cloudflare.types.page_shield import Setting, PageShieldUpdateResponse Methods: -- client.page_shield.update(\*, zone_id, \*\*params) -> PageShieldUpdateResponse -- client.page_shield.get(\*, zone_id) -> Setting +- client.page_shield.update(\*, zone_id, \*\*params) -> Optional +- client.page_shield.get(\*, zone_id) -> Optional ## Policies Types: ```python -from cloudflare.types.page_shield import Policy +from cloudflare.types.page_shield import ( + PolicyCreateResponse, + PolicyUpdateResponse, + PolicyListResponse, + PolicyGetResponse, +) ``` Methods: -- client.page_shield.policies.create(\*, zone_id, \*\*params) -> Policy -- client.page_shield.policies.update(policy_id, \*, zone_id, \*\*params) -> Policy -- client.page_shield.policies.list(\*, zone_id) -> SyncSinglePage[Policy] +- client.page_shield.policies.create(\*, zone_id, \*\*params) -> Optional +- client.page_shield.policies.update(policy_id, \*, zone_id, \*\*params) -> Optional +- client.page_shield.policies.list(\*, zone_id) -> SyncSinglePage[PolicyListResponse] - client.page_shield.policies.delete(policy_id, \*, zone_id) -> None -- client.page_shield.policies.get(policy_id, \*, zone_id) -> Policy +- client.page_shield.policies.get(policy_id, \*, zone_id) -> Optional ## Connections @@ -3152,7 +3157,7 @@ from cloudflare.types.page_shield import Connection Methods: - client.page_shield.connections.list(\*, zone_id, \*\*params) -> SyncSinglePage[Connection] -- client.page_shield.connections.get(connection_id, \*, zone_id) -> Connection +- client.page_shield.connections.get(connection_id, \*, zone_id) -> Optional ## Scripts @@ -3165,7 +3170,7 @@ from cloudflare.types.page_shield import Script, ScriptGetResponse Methods: - client.page_shield.scripts.list(\*, zone_id, \*\*params) -> SyncSinglePage[Script] -- client.page_shield.scripts.get(script_id, \*, zone_id) -> ScriptGetResponse +- client.page_shield.scripts.get(script_id, \*, zone_id) -> Optional # Rulesets diff --git a/src/cloudflare/resources/page_shield/connections.py b/src/cloudflare/resources/page_shield/connections.py index c9d5a5c7c71..e961e1e4bc6 100644 --- a/src/cloudflare/resources/page_shield/connections.py +++ b/src/cloudflare/resources/page_shield/connections.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -16,6 +17,7 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) +from ..._wrappers import ResultWrapper from ...pagination import SyncSinglePage, AsyncSinglePage from ..._base_client import ( AsyncPaginator, @@ -161,14 +163,14 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Connection: + ) -> Optional[Connection]: """ Fetches a connection detected by Page Shield by connection ID. Args: zone_id: Identifier - connection_id: The ID of the resource. + connection_id: Identifier extra_headers: Send extra headers @@ -185,9 +187,13 @@ def get( return self._get( f"/zones/{zone_id}/page_shield/connections/{connection_id}", 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, + post_parser=ResultWrapper[Optional[Connection]]._unwrapper, ), - cast_to=Connection, + cast_to=cast(Type[Optional[Connection]], ResultWrapper[Connection]), ) @@ -325,14 +331,14 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Connection: + ) -> Optional[Connection]: """ Fetches a connection detected by Page Shield by connection ID. Args: zone_id: Identifier - connection_id: The ID of the resource. + connection_id: Identifier extra_headers: Send extra headers @@ -349,9 +355,13 @@ async def get( return await self._get( f"/zones/{zone_id}/page_shield/connections/{connection_id}", 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, + post_parser=ResultWrapper[Optional[Connection]]._unwrapper, ), - cast_to=Connection, + cast_to=cast(Type[Optional[Connection]], ResultWrapper[Connection]), ) diff --git a/src/cloudflare/resources/page_shield/page_shield.py b/src/cloudflare/resources/page_shield/page_shield.py index ef88a6b37e0..655f3b4c4fd 100644 --- a/src/cloudflare/resources/page_shield/page_shield.py +++ b/src/cloudflare/resources/page_shield/page_shield.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -88,7 +88,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PageShieldUpdateResponse: + ) -> Optional[PageShieldUpdateResponse]: """ Updates Page Shield settings. @@ -127,9 +127,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PageShieldUpdateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PageShieldUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[PageShieldUpdateResponse], ResultWrapper[PageShieldUpdateResponse]), + cast_to=cast(Type[Optional[PageShieldUpdateResponse]], ResultWrapper[PageShieldUpdateResponse]), ) def get( @@ -142,7 +142,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Setting: + ) -> Optional[Setting]: """ Fetches the Page Shield settings. @@ -166,9 +166,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Setting]._unwrapper, + post_parser=ResultWrapper[Optional[Setting]]._unwrapper, ), - cast_to=cast(Type[Setting], ResultWrapper[Setting]), + cast_to=cast(Type[Optional[Setting]], ResultWrapper[Setting]), ) @@ -206,7 +206,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> PageShieldUpdateResponse: + ) -> Optional[PageShieldUpdateResponse]: """ Updates Page Shield settings. @@ -245,9 +245,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[PageShieldUpdateResponse]._unwrapper, + post_parser=ResultWrapper[Optional[PageShieldUpdateResponse]]._unwrapper, ), - cast_to=cast(Type[PageShieldUpdateResponse], ResultWrapper[PageShieldUpdateResponse]), + cast_to=cast(Type[Optional[PageShieldUpdateResponse]], ResultWrapper[PageShieldUpdateResponse]), ) async def get( @@ -260,7 +260,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Setting: + ) -> Optional[Setting]: """ Fetches the Page Shield settings. @@ -284,9 +284,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Setting]._unwrapper, + post_parser=ResultWrapper[Optional[Setting]]._unwrapper, ), - cast_to=cast(Type[Setting], ResultWrapper[Setting]), + cast_to=cast(Type[Optional[Setting]], ResultWrapper[Setting]), ) diff --git a/src/cloudflare/resources/page_shield/policies.py b/src/cloudflare/resources/page_shield/policies.py index 2a0ecdd591b..de2822019e7 100644 --- a/src/cloudflare/resources/page_shield/policies.py +++ b/src/cloudflare/resources/page_shield/policies.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -19,13 +20,17 @@ 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.page_shield import policy_create_params, policy_update_params -from ...types.page_shield.policy import Policy +from ...types.page_shield.policy_get_response import PolicyGetResponse +from ...types.page_shield.policy_list_response import PolicyListResponse +from ...types.page_shield.policy_create_response import PolicyCreateResponse +from ...types.page_shield.policy_update_response import PolicyUpdateResponse __all__ = ["PoliciesResource", "AsyncPoliciesResource"] @@ -43,18 +48,18 @@ def create( self, *, zone_id: str, - action: Literal["allow", "log"] | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - value: str | NotGiven = NOT_GIVEN, + action: Literal["allow", "log"], + description: str, + enabled: bool, + expression: str, + value: 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, - ) -> Policy: + ) -> Optional[PolicyCreateResponse]: """ Create a Page Shield policy. @@ -95,9 +100,13 @@ def create( policy_create_params.PolicyCreateParams, ), 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, + post_parser=ResultWrapper[Optional[PolicyCreateResponse]]._unwrapper, ), - cast_to=Policy, + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), ) def update( @@ -116,14 +125,14 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Policy: + ) -> Optional[PolicyUpdateResponse]: """ Update a Page Shield policy by ID. Args: zone_id: Identifier - policy_id: The ID of the policy. + policy_id: Identifier action: The action to take if the expression matches @@ -161,9 +170,13 @@ def update( policy_update_params.PolicyUpdateParams, ), 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, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, ), - cast_to=Policy, + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) def list( @@ -176,7 +189,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[Policy]: + ) -> SyncSinglePage[PolicyListResponse]: """ Lists all Page Shield policies. @@ -195,11 +208,11 @@ def list( raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get_api_list( f"/zones/{zone_id}/page_shield/policies", - page=SyncSinglePage[Policy], + page=SyncSinglePage[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Policy, + model=PolicyListResponse, ) def delete( @@ -220,7 +233,7 @@ def delete( Args: zone_id: Identifier - policy_id: The ID of the policy. + policy_id: Identifier extra_headers: Send extra headers @@ -254,14 +267,14 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Policy: + ) -> Optional[PolicyGetResponse]: """ Fetches a Page Shield policy by ID. Args: zone_id: Identifier - policy_id: The ID of the policy. + policy_id: Identifier extra_headers: Send extra headers @@ -278,9 +291,13 @@ def get( return self._get( f"/zones/{zone_id}/page_shield/policies/{policy_id}", 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, + post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, ), - cast_to=Policy, + cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), ) @@ -297,18 +314,18 @@ async def create( self, *, zone_id: str, - action: Literal["allow", "log"] | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - value: str | NotGiven = NOT_GIVEN, + action: Literal["allow", "log"], + description: str, + enabled: bool, + expression: str, + value: 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, - ) -> Policy: + ) -> Optional[PolicyCreateResponse]: """ Create a Page Shield policy. @@ -349,9 +366,13 @@ async def create( policy_create_params.PolicyCreateParams, ), 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, + post_parser=ResultWrapper[Optional[PolicyCreateResponse]]._unwrapper, ), - cast_to=Policy, + cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]), ) async def update( @@ -370,14 +391,14 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Policy: + ) -> Optional[PolicyUpdateResponse]: """ Update a Page Shield policy by ID. Args: zone_id: Identifier - policy_id: The ID of the policy. + policy_id: Identifier action: The action to take if the expression matches @@ -415,9 +436,13 @@ async def update( policy_update_params.PolicyUpdateParams, ), 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, + post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper, ), - cast_to=Policy, + cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]), ) def list( @@ -430,7 +455,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Policy, AsyncSinglePage[Policy]]: + ) -> AsyncPaginator[PolicyListResponse, AsyncSinglePage[PolicyListResponse]]: """ Lists all Page Shield policies. @@ -449,11 +474,11 @@ def list( raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return self._get_api_list( f"/zones/{zone_id}/page_shield/policies", - page=AsyncSinglePage[Policy], + page=AsyncSinglePage[PolicyListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=Policy, + model=PolicyListResponse, ) async def delete( @@ -474,7 +499,7 @@ async def delete( Args: zone_id: Identifier - policy_id: The ID of the policy. + policy_id: Identifier extra_headers: Send extra headers @@ -508,14 +533,14 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Policy: + ) -> Optional[PolicyGetResponse]: """ Fetches a Page Shield policy by ID. Args: zone_id: Identifier - policy_id: The ID of the policy. + policy_id: Identifier extra_headers: Send extra headers @@ -532,9 +557,13 @@ async def get( return await self._get( f"/zones/{zone_id}/page_shield/policies/{policy_id}", 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, + post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper, ), - cast_to=Policy, + cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]), ) diff --git a/src/cloudflare/resources/page_shield/scripts.py b/src/cloudflare/resources/page_shield/scripts.py index 147bef3320b..2a3e556f7cc 100644 --- a/src/cloudflare/resources/page_shield/scripts.py +++ b/src/cloudflare/resources/page_shield/scripts.py @@ -2,6 +2,7 @@ from __future__ import annotations +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -16,6 +17,7 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) +from ..._wrappers import ResultWrapper from ...pagination import SyncSinglePage, AsyncSinglePage from ..._base_client import ( AsyncPaginator, @@ -169,14 +171,14 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ScriptGetResponse: + ) -> Optional[ScriptGetResponse]: """ Fetches a script detected by Page Shield by script ID. Args: zone_id: Identifier - script_id: The ID of the resource. + script_id: Identifier extra_headers: Send extra headers @@ -193,9 +195,13 @@ def get( return self._get( f"/zones/{zone_id}/page_shield/scripts/{script_id}", 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, + post_parser=ResultWrapper[Optional[ScriptGetResponse]]._unwrapper, ), - cast_to=ScriptGetResponse, + cast_to=cast(Type[Optional[ScriptGetResponse]], ResultWrapper[ScriptGetResponse]), ) @@ -340,14 +346,14 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ScriptGetResponse: + ) -> Optional[ScriptGetResponse]: """ Fetches a script detected by Page Shield by script ID. Args: zone_id: Identifier - script_id: The ID of the resource. + script_id: Identifier extra_headers: Send extra headers @@ -364,9 +370,13 @@ async def get( return await self._get( f"/zones/{zone_id}/page_shield/scripts/{script_id}", 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, + post_parser=ResultWrapper[Optional[ScriptGetResponse]]._unwrapper, ), - cast_to=ScriptGetResponse, + cast_to=cast(Type[Optional[ScriptGetResponse]], ResultWrapper[ScriptGetResponse]), ) diff --git a/src/cloudflare/types/page_shield/__init__.py b/src/cloudflare/types/page_shield/__init__.py index 6f07ca60629..1442bda6660 100644 --- a/src/cloudflare/types/page_shield/__init__.py +++ b/src/cloudflare/types/page_shield/__init__.py @@ -2,14 +2,17 @@ from __future__ import annotations -from .policy import Policy as Policy from .script import Script as Script from .setting import Setting as Setting from .connection import Connection as Connection from .script_list_params import ScriptListParams as ScriptListParams +from .policy_get_response import PolicyGetResponse as PolicyGetResponse from .script_get_response import ScriptGetResponse as ScriptGetResponse from .policy_create_params import PolicyCreateParams as PolicyCreateParams +from .policy_list_response import PolicyListResponse as PolicyListResponse from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams from .connection_list_params import ConnectionListParams as ConnectionListParams +from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse +from .policy_update_response import PolicyUpdateResponse as PolicyUpdateResponse from .page_shield_update_params import PageShieldUpdateParams as PageShieldUpdateParams from .page_shield_update_response import PageShieldUpdateResponse as PageShieldUpdateResponse diff --git a/src/cloudflare/types/page_shield/connection.py b/src/cloudflare/types/page_shield/connection.py index e89e575b52a..252091a2c85 100644 --- a/src/cloudflare/types/page_shield/connection.py +++ b/src/cloudflare/types/page_shield/connection.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Optional +from datetime import datetime from ..._models import BaseModel @@ -8,22 +9,29 @@ class Connection(BaseModel): - id: Optional[str] = None + id: str + """Identifier""" - added_at: Optional[str] = None + added_at: datetime + + first_seen_at: datetime + + host: str + + last_seen_at: datetime + + url: str + + url_contains_cdn_cgi_path: bool domain_reported_malicious: Optional[bool] = None first_page_url: Optional[str] = None - first_seen_at: Optional[str] = None - - host: Optional[str] = None + malicious_domain_categories: Optional[List[str]] = None - last_seen_at: Optional[str] = None + malicious_url_categories: Optional[List[str]] = None page_urls: Optional[List[str]] = None - url: Optional[str] = None - - url_contains_cdn_cgi_path: Optional[bool] = None + url_reported_malicious: Optional[bool] = None diff --git a/src/cloudflare/types/page_shield/page_shield_update_response.py b/src/cloudflare/types/page_shield/page_shield_update_response.py index d0410913b2d..ad2852df732 100644 --- a/src/cloudflare/types/page_shield/page_shield_update_response.py +++ b/src/cloudflare/types/page_shield/page_shield_update_response.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional + from ..._models import BaseModel @@ -8,17 +8,17 @@ class PageShieldUpdateResponse(BaseModel): - enabled: Optional[bool] = None + enabled: bool """When true, indicates that Page Shield is enabled.""" - updated_at: Optional[str] = None + updated_at: str """The timestamp of when Page Shield was last updated.""" - use_cloudflare_reporting_endpoint: Optional[bool] = None + use_cloudflare_reporting_endpoint: bool """ When true, CSP reports will be sent to https://csp-reporting.cloudflare.com/cdn-cgi/script_monitor/report """ - use_connection_url_path: Optional[bool] = None + use_connection_url_path: bool """When true, the paths associated with connections URLs will also be analyzed.""" diff --git a/src/cloudflare/types/page_shield/policy_create_params.py b/src/cloudflare/types/page_shield/policy_create_params.py index 724923121d7..6578a38230b 100644 --- a/src/cloudflare/types/page_shield/policy_create_params.py +++ b/src/cloudflare/types/page_shield/policy_create_params.py @@ -11,20 +11,20 @@ class PolicyCreateParams(TypedDict, total=False): zone_id: Required[str] """Identifier""" - action: Literal["allow", "log"] + action: Required[Literal["allow", "log"]] """The action to take if the expression matches""" - description: str + description: Required[str] """A description for the policy""" - enabled: bool + enabled: Required[bool] """Whether the policy is enabled""" - expression: str + expression: Required[str] """ The expression which must match for the policy to be applied, using the Cloudflare Firewall rule expression syntax """ - value: str + value: Required[str] """The policy which will be applied""" diff --git a/src/cloudflare/types/page_shield/policy.py b/src/cloudflare/types/page_shield/policy_create_response.py similarity index 59% rename from src/cloudflare/types/page_shield/policy.py rename to src/cloudflare/types/page_shield/policy_create_response.py index 3f838d934c7..483d2835764 100644 --- a/src/cloudflare/types/page_shield/policy.py +++ b/src/cloudflare/types/page_shield/policy_create_response.py @@ -1,31 +1,30 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional from typing_extensions import Literal from ..._models import BaseModel -__all__ = ["Policy"] +__all__ = ["PolicyCreateResponse"] -class Policy(BaseModel): - id: Optional[str] = None - """The ID of the policy""" +class PolicyCreateResponse(BaseModel): + id: str + """Identifier""" - action: Optional[Literal["allow", "log"]] = None + action: Literal["allow", "log"] """The action to take if the expression matches""" - description: Optional[str] = None + description: str """A description for the policy""" - enabled: Optional[bool] = None + enabled: bool """Whether the policy is enabled""" - expression: Optional[str] = None + expression: str """ The expression which must match for the policy to be applied, using the Cloudflare Firewall rule expression syntax """ - value: Optional[str] = None + value: str """The policy which will be applied""" diff --git a/src/cloudflare/types/page_shield/policy_get_response.py b/src/cloudflare/types/page_shield/policy_get_response.py new file mode 100644 index 00000000000..3b28c295122 --- /dev/null +++ b/src/cloudflare/types/page_shield/policy_get_response.py @@ -0,0 +1,30 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["PolicyGetResponse"] + + +class PolicyGetResponse(BaseModel): + id: str + """Identifier""" + + action: Literal["allow", "log"] + """The action to take if the expression matches""" + + description: str + """A description for the policy""" + + enabled: bool + """Whether the policy is enabled""" + + expression: str + """ + The expression which must match for the policy to be applied, using the + Cloudflare Firewall rule expression syntax + """ + + value: str + """The policy which will be applied""" diff --git a/src/cloudflare/types/page_shield/policy_list_response.py b/src/cloudflare/types/page_shield/policy_list_response.py new file mode 100644 index 00000000000..5ce2180de2f --- /dev/null +++ b/src/cloudflare/types/page_shield/policy_list_response.py @@ -0,0 +1,30 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["PolicyListResponse"] + + +class PolicyListResponse(BaseModel): + id: str + """Identifier""" + + action: Literal["allow", "log"] + """The action to take if the expression matches""" + + description: str + """A description for the policy""" + + enabled: bool + """Whether the policy is enabled""" + + expression: str + """ + The expression which must match for the policy to be applied, using the + Cloudflare Firewall rule expression syntax + """ + + value: str + """The policy which will be applied""" diff --git a/src/cloudflare/types/page_shield/policy_update_response.py b/src/cloudflare/types/page_shield/policy_update_response.py new file mode 100644 index 00000000000..dcc40a8c6cb --- /dev/null +++ b/src/cloudflare/types/page_shield/policy_update_response.py @@ -0,0 +1,30 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["PolicyUpdateResponse"] + + +class PolicyUpdateResponse(BaseModel): + id: str + """Identifier""" + + action: Literal["allow", "log"] + """The action to take if the expression matches""" + + description: str + """A description for the policy""" + + enabled: bool + """Whether the policy is enabled""" + + expression: str + """ + The expression which must match for the policy to be applied, using the + Cloudflare Firewall rule expression syntax + """ + + value: str + """The policy which will be applied""" diff --git a/src/cloudflare/types/page_shield/script.py b/src/cloudflare/types/page_shield/script.py index 60d4a295f50..2db2c549968 100644 --- a/src/cloudflare/types/page_shield/script.py +++ b/src/cloudflare/types/page_shield/script.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Optional +from datetime import datetime from ..._models import BaseModel @@ -8,32 +9,44 @@ class Script(BaseModel): - id: Optional[str] = None + id: str + """Identifier""" - added_at: Optional[str] = None + added_at: datetime - dataflow_score: Optional[float] = None + first_seen_at: datetime + + host: str + + last_seen_at: datetime + + url: str + + url_contains_cdn_cgi_path: bool + + dataflow_score: Optional[int] = None + """The dataflow score of the JavaScript content.""" domain_reported_malicious: Optional[bool] = None fetched_at: Optional[str] = None + """The timestamp of when the script was last fetched.""" first_page_url: Optional[str] = None - first_seen_at: Optional[str] = None - hash: Optional[str] = None + """The computed hash of the analyzed script.""" - host: Optional[str] = None + js_integrity_score: Optional[int] = None + """The integrity score of the JavaScript content.""" - js_integrity_score: Optional[float] = None + malicious_domain_categories: Optional[List[str]] = None - last_seen_at: Optional[str] = None + malicious_url_categories: Optional[List[str]] = None - obfuscation_score: Optional[float] = None + obfuscation_score: Optional[int] = None + """The obfuscation score of the JavaScript content.""" page_urls: Optional[List[str]] = None - url: Optional[str] = None - - url_contains_cdn_cgi_path: Optional[bool] = None + url_reported_malicious: Optional[bool] = None diff --git a/src/cloudflare/types/page_shield/script_get_response.py b/src/cloudflare/types/page_shield/script_get_response.py index 171d5e24c6b..56d60bc2164 100644 --- a/src/cloudflare/types/page_shield/script_get_response.py +++ b/src/cloudflare/types/page_shield/script_get_response.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Optional +from datetime import datetime from ..._models import BaseModel @@ -25,34 +26,46 @@ class Version(BaseModel): class ScriptGetResponse(BaseModel): - id: Optional[str] = None + id: str + """Identifier""" - added_at: Optional[str] = None + added_at: datetime - dataflow_score: Optional[float] = None + first_seen_at: datetime + + host: str + + last_seen_at: datetime + + url: str + + url_contains_cdn_cgi_path: bool + + dataflow_score: Optional[int] = None + """The dataflow score of the JavaScript content.""" domain_reported_malicious: Optional[bool] = None fetched_at: Optional[str] = None + """The timestamp of when the script was last fetched.""" first_page_url: Optional[str] = None - first_seen_at: Optional[str] = None - hash: Optional[str] = None + """The computed hash of the analyzed script.""" - host: Optional[str] = None + js_integrity_score: Optional[int] = None + """The integrity score of the JavaScript content.""" - js_integrity_score: Optional[float] = None + malicious_domain_categories: Optional[List[str]] = None - last_seen_at: Optional[str] = None + malicious_url_categories: Optional[List[str]] = None - obfuscation_score: Optional[float] = None + obfuscation_score: Optional[int] = None + """The obfuscation score of the JavaScript content.""" page_urls: Optional[List[str]] = None - url: Optional[str] = None - - url_contains_cdn_cgi_path: Optional[bool] = None + url_reported_malicious: Optional[bool] = None versions: Optional[List[Version]] = None diff --git a/src/cloudflare/types/page_shield/setting.py b/src/cloudflare/types/page_shield/setting.py index fee7e5dc567..46e4fd6da65 100644 --- a/src/cloudflare/types/page_shield/setting.py +++ b/src/cloudflare/types/page_shield/setting.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional + from ..._models import BaseModel @@ -8,17 +8,17 @@ class Setting(BaseModel): - enabled: Optional[bool] = None + enabled: bool """When true, indicates that Page Shield is enabled.""" - updated_at: Optional[str] = None + updated_at: str """The timestamp of when Page Shield was last updated.""" - use_cloudflare_reporting_endpoint: Optional[bool] = None + use_cloudflare_reporting_endpoint: bool """ When true, CSP reports will be sent to https://csp-reporting.cloudflare.com/cdn-cgi/script_monitor/report """ - use_connection_url_path: Optional[bool] = None + use_connection_url_path: bool """When true, the paths associated with connections URLs will also be analyzed.""" diff --git a/tests/api_resources/page_shield/test_connections.py b/tests/api_resources/page_shield/test_connections.py index f0a138460d7..74e8e45713e 100644 --- a/tests/api_resources/page_shield/test_connections.py +++ b/tests/api_resources/page_shield/test_connections.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -78,34 +78,34 @@ def test_path_params_list(self, client: Cloudflare) -> None: @parametrize def test_method_get(self, client: Cloudflare) -> None: connection = client.page_shield.connections.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Connection, connection, path=["response"]) + assert_matches_type(Optional[Connection], connection, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.page_shield.connections.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" connection = response.parse() - assert_matches_type(Connection, connection, path=["response"]) + assert_matches_type(Optional[Connection], connection, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.page_shield.connections.with_streaming_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" connection = response.parse() - assert_matches_type(Connection, connection, path=["response"]) + assert_matches_type(Optional[Connection], connection, path=["response"]) assert cast(Any, response.is_closed) is True @@ -113,7 +113,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): client.page_shield.connections.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) @@ -187,34 +187,34 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: connection = await async_client.page_shield.connections.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Connection, connection, path=["response"]) + assert_matches_type(Optional[Connection], connection, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.page_shield.connections.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" connection = await response.parse() - assert_matches_type(Connection, connection, path=["response"]) + assert_matches_type(Optional[Connection], connection, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.page_shield.connections.with_streaming_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" connection = await response.parse() - assert_matches_type(Connection, connection, path=["response"]) + assert_matches_type(Optional[Connection], connection, path=["response"]) assert cast(Any, response.is_closed) is True @@ -222,7 +222,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): await async_client.page_shield.connections.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) diff --git a/tests/api_resources/page_shield/test_policies.py b/tests/api_resources/page_shield/test_policies.py index 500d4d23d0e..d2ff101721c 100644 --- a/tests/api_resources/page_shield/test_policies.py +++ b/tests/api_resources/page_shield/test_policies.py @@ -3,14 +3,19 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.page_shield import Policy +from cloudflare.types.page_shield import ( + PolicyGetResponse, + PolicyListResponse, + PolicyCreateResponse, + PolicyUpdateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -20,13 +25,6 @@ class TestPolicies: @parametrize def test_method_create(self, client: Cloudflare) -> None: - policy = client.page_shield.policies.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Policy, policy, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: policy = client.page_shield.policies.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", action="allow", @@ -35,29 +33,39 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: expression='ends_with(http.request.uri.path, "/checkout")', value="script-src 'none';", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.page_shield.policies.with_raw_response.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", + action="allow", + description="Checkout page CSP policy", + enabled=True, + expression='ends_with(http.request.uri.path, "/checkout")', + value="script-src 'none';", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.page_shield.policies.with_streaming_response.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", + action="allow", + description="Checkout page CSP policy", + enabled=True, + expression='ends_with(http.request.uri.path, "/checkout")', + value="script-src 'none';", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -66,20 +74,25 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): client.page_shield.policies.with_raw_response.create( zone_id="", + action="allow", + description="Checkout page CSP policy", + enabled=True, + expression='ends_with(http.request.uri.path, "/checkout")', + value="script-src 'none';", ) @parametrize def test_method_update(self, client: Cloudflare) -> None: policy = client.page_shield.policies.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: policy = client.page_shield.policies.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", action="allow", description="Checkout page CSP policy", @@ -87,31 +100,31 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: expression='ends_with(http.request.uri.path, "/checkout")', value="script-src 'none';", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.page_shield.policies.with_raw_response.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.page_shield.policies.with_streaming_response.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -119,7 +132,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): client.page_shield.policies.with_raw_response.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) @@ -134,7 +147,7 @@ def test_method_list(self, client: Cloudflare) -> None: policy = client.page_shield.policies.list( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(SyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -145,7 +158,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(SyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -156,7 +169,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(SyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -170,7 +183,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: @parametrize def test_method_delete(self, client: Cloudflare) -> None: policy = client.page_shield.policies.delete( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert policy is None @@ -178,7 +191,7 @@ def test_method_delete(self, client: Cloudflare) -> None: @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.page_shield.policies.with_raw_response.delete( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -190,7 +203,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.page_shield.policies.with_streaming_response.delete( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed @@ -205,7 +218,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): client.page_shield.policies.with_raw_response.delete( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) @@ -218,34 +231,34 @@ def test_path_params_delete(self, client: Cloudflare) -> None: @parametrize def test_method_get(self, client: Cloudflare) -> None: policy = client.page_shield.policies.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.page_shield.policies.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.page_shield.policies.with_streaming_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +266,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): client.page_shield.policies.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) @@ -269,13 +282,6 @@ class TestAsyncPolicies: @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.page_shield.policies.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Policy, policy, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: policy = await async_client.page_shield.policies.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", action="allow", @@ -284,29 +290,39 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare expression='ends_with(http.request.uri.path, "/checkout")', value="script-src 'none';", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.page_shield.policies.with_raw_response.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", + action="allow", + description="Checkout page CSP policy", + enabled=True, + expression='ends_with(http.request.uri.path, "/checkout")', + value="script-src 'none';", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.page_shield.policies.with_streaming_response.create( zone_id="023e105f4ecef8ad9ca31a8372d0c353", + action="allow", + description="Checkout page CSP policy", + enabled=True, + expression='ends_with(http.request.uri.path, "/checkout")', + value="script-src 'none';", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -315,20 +331,25 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): await async_client.page_shield.policies.with_raw_response.create( zone_id="", + action="allow", + description="Checkout page CSP policy", + enabled=True, + expression='ends_with(http.request.uri.path, "/checkout")', + value="script-src 'none';", ) @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: policy = await async_client.page_shield.policies.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: policy = await async_client.page_shield.policies.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", action="allow", description="Checkout page CSP policy", @@ -336,31 +357,31 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare expression='ends_with(http.request.uri.path, "/checkout")', value="script-src 'none';", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.page_shield.policies.with_raw_response.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.page_shield.policies.with_streaming_response.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -368,7 +389,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): await async_client.page_shield.policies.with_raw_response.update( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) @@ -383,7 +404,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: policy = await async_client.page_shield.policies.list( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -394,7 +415,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -405,7 +426,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"]) + assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +440,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: policy = await async_client.page_shield.policies.delete( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert policy is None @@ -427,7 +448,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.page_shield.policies.with_raw_response.delete( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -439,7 +460,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.page_shield.policies.with_streaming_response.delete( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed @@ -454,7 +475,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): await async_client.page_shield.policies.with_raw_response.delete( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) @@ -467,34 +488,34 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: policy = await async_client.page_shield.policies.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.page_shield.policies.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.page_shield.policies.with_streaming_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" policy = await response.parse() - assert_matches_type(Policy, policy, path=["response"]) + assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"]) assert cast(Any, response.is_closed) is True @@ -502,7 +523,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): await async_client.page_shield.policies.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) diff --git a/tests/api_resources/page_shield/test_scripts.py b/tests/api_resources/page_shield/test_scripts.py index a93e18c8b85..c874f315be8 100644 --- a/tests/api_resources/page_shield/test_scripts.py +++ b/tests/api_resources/page_shield/test_scripts.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -79,34 +79,34 @@ def test_path_params_list(self, client: Cloudflare) -> None: @parametrize def test_method_get(self, client: Cloudflare) -> None: script = client.page_shield.scripts.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(ScriptGetResponse, script, path=["response"]) + assert_matches_type(Optional[ScriptGetResponse], script, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.page_shield.scripts.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" script = response.parse() - assert_matches_type(ScriptGetResponse, script, path=["response"]) + assert_matches_type(Optional[ScriptGetResponse], script, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.page_shield.scripts.with_streaming_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" script = response.parse() - assert_matches_type(ScriptGetResponse, script, path=["response"]) + assert_matches_type(Optional[ScriptGetResponse], script, path=["response"]) assert cast(Any, response.is_closed) is True @@ -114,7 +114,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): client.page_shield.scripts.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) @@ -189,34 +189,34 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: script = await async_client.page_shield.scripts.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(ScriptGetResponse, script, path=["response"]) + assert_matches_type(Optional[ScriptGetResponse], script, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.page_shield.scripts.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" script = await response.parse() - assert_matches_type(ScriptGetResponse, script, path=["response"]) + assert_matches_type(Optional[ScriptGetResponse], script, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.page_shield.scripts.with_streaming_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" script = await response.parse() - assert_matches_type(ScriptGetResponse, script, path=["response"]) + assert_matches_type(Optional[ScriptGetResponse], script, path=["response"]) assert cast(Any, response.is_closed) is True @@ -224,7 +224,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): await async_client.page_shield.scripts.with_raw_response.get( - "c9ef84a6bf5e47138c75d95e2f933e8f", + "023e105f4ecef8ad9ca31a8372d0c353", zone_id="", ) diff --git a/tests/api_resources/test_page_shield.py b/tests/api_resources/test_page_shield.py index 9e7112a8b9c..2511ba986b2 100644 --- a/tests/api_resources/test_page_shield.py +++ b/tests/api_resources/test_page_shield.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_update(self, client: Cloudflare) -> None: page_shield = client.page_shield.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"]) + assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -32,7 +32,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: use_cloudflare_reporting_endpoint=True, use_connection_url_path=True, ) - assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"]) + assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ 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" page_shield = response.parse() - assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"]) + assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" page_shield = response.parse() - assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"]) + assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"]) assert cast(Any, response.is_closed) is True @@ -70,7 +70,7 @@ def test_method_get(self, client: Cloudflare) -> None: page_shield = client.page_shield.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Setting, page_shield, path=["response"]) + assert_matches_type(Optional[Setting], page_shield, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -81,7 +81,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" page_shield = response.parse() - assert_matches_type(Setting, page_shield, path=["response"]) + assert_matches_type(Optional[Setting], page_shield, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -92,7 +92,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" page_shield = response.parse() - assert_matches_type(Setting, page_shield, path=["response"]) + assert_matches_type(Optional[Setting], page_shield, path=["response"]) assert cast(Any, response.is_closed) is True @@ -112,7 +112,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: page_shield = await async_client.page_shield.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"]) + assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -122,7 +122,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare use_cloudflare_reporting_endpoint=True, use_connection_url_path=True, ) - assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"]) + assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -133,7 +133,7 @@ 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" page_shield = await response.parse() - assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"]) + assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -144,7 +144,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" page_shield = await response.parse() - assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"]) + assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"]) assert cast(Any, response.is_closed) is True @@ -160,7 +160,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page_shield = await async_client.page_shield.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Setting, page_shield, path=["response"]) + assert_matches_type(Optional[Setting], page_shield, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -171,7 +171,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" page_shield = await response.parse() - assert_matches_type(Setting, page_shield, path=["response"]) + assert_matches_type(Optional[Setting], page_shield, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -182,7 +182,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" page_shield = await response.parse() - assert_matches_type(Setting, page_shield, path=["response"]) + assert_matches_type(Optional[Setting], page_shield, path=["response"]) assert cast(Any, response.is_closed) is True From 843c4ab7b0fbd684d1a90b94a4af5060d308f439 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:09:53 +0000 Subject: [PATCH 490/532] feat(api): OpenAPI spec update via Stainless API (#971) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fdf1e9f7f3b..d0e1162265c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-67424229bbbde1877c65e166d223383650df240860d79d57acb342e150117579.yml From 187d46db1fc70b7031f3d0c63569f3d49c1ea9de Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:12:03 +0000 Subject: [PATCH 491/532] feat(api): OpenAPI spec update via Stainless API (#972) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d0e1162265c..fdf1e9f7f3b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-67424229bbbde1877c65e166d223383650df240860d79d57acb342e150117579.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml From 568efe921e631808baa64520df55692e351db1ce Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:32:37 +0000 Subject: [PATCH 492/532] feat(api): OpenAPI spec update via Stainless API (#973) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fdf1e9f7f3b..d938ad6a2a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml From edccbd62ef420f8a3d3fea10006e728fbaa90194 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:34:51 +0000 Subject: [PATCH 493/532] feat(api): OpenAPI spec update via Stainless API (#974) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d938ad6a2a8..d0e1162265c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-67424229bbbde1877c65e166d223383650df240860d79d57acb342e150117579.yml From 46f1cc127ba7a692d3fbd9ecabfc469b7c551a41 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:13:53 +0000 Subject: [PATCH 494/532] feat(api): OpenAPI spec update via Stainless API (#975) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d0e1162265c..23108291da9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-67424229bbbde1877c65e166d223383650df240860d79d57acb342e150117579.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml From b4a7375244c24f9635fec7a075567f0bdcd1ca2d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:09:29 +0000 Subject: [PATCH 495/532] feat(api): OpenAPI spec update via Stainless API (#976) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 23108291da9..d938ad6a2a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml From 816c7b3eaf99b4bad259a1434a07d51784fa0db7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:12:13 +0000 Subject: [PATCH 496/532] feat(api): OpenAPI spec update via Stainless API (#977) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d938ad6a2a8..d0e1162265c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-67424229bbbde1877c65e166d223383650df240860d79d57acb342e150117579.yml From 2d44575915b107e5a829a869d1fc589b2d6b231b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:50:36 +0000 Subject: [PATCH 497/532] feat(api): OpenAPI spec update via Stainless API (#978) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d0e1162265c..d938ad6a2a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-67424229bbbde1877c65e166d223383650df240860d79d57acb342e150117579.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml From c57c9060afa88e36970657fc9721c743f9b013d8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:54:56 +0000 Subject: [PATCH 498/532] feat(api): OpenAPI spec update via Stainless API (#979) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d938ad6a2a8..23108291da9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml From 974259348041aee050a3b00ba4f05309dd831280 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:29:21 +0000 Subject: [PATCH 499/532] feat(api): OpenAPI spec update via Stainless API (#980) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 23108291da9..fdf1e9f7f3b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml From 8543fae03e0d0e700c198cf571df5f0441875a42 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:31:50 +0000 Subject: [PATCH 500/532] feat(api): OpenAPI spec update via Stainless API (#981) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fdf1e9f7f3b..d938ad6a2a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml From 04cd78a2fb2db9cea0fa2e7481cf88f7e8dacf43 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:34:06 +0000 Subject: [PATCH 501/532] feat(api): OpenAPI spec update via Stainless API (#982) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d938ad6a2a8..23108291da9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml From 06307a82040a4d26f2da6de687f9f9fcef220505 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:36:14 +0000 Subject: [PATCH 502/532] feat(api): OpenAPI spec update via Stainless API (#983) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 23108291da9..d938ad6a2a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml From c7023433bda54769e048b2e9f106d42e9296474e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:44:16 +0000 Subject: [PATCH 503/532] feat(api): OpenAPI spec update via Stainless API (#984) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d938ad6a2a8..23108291da9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml From 6ee5e162f922d90b1006641505edb8284c334bf4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:46:26 +0000 Subject: [PATCH 504/532] feat(api): OpenAPI spec update via Stainless API (#985) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 23108291da9..fdf1e9f7f3b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml From 4f82091a8bcd193f25ce42b3e505d052425d9b3b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 17:09:01 +0000 Subject: [PATCH 505/532] feat(api): OpenAPI spec update via Stainless API (#986) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fdf1e9f7f3b..d938ad6a2a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml From b1e35493ea6456711b912450eb05f2cc28bc2a2e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 17:11:16 +0000 Subject: [PATCH 506/532] feat(api): OpenAPI spec update via Stainless API (#987) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d938ad6a2a8..fdf1e9f7f3b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-016087db0edf333b0548ecf575e5b28bbb19576fd8e2d7764d122d938b4f947b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml From 1be11e847dbb0966c7a2821a5faaea7bcf16f622 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:29:46 +0000 Subject: [PATCH 507/532] feat(api): OpenAPI spec update via Stainless API (#988) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fdf1e9f7f3b..23108291da9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml From d8131eaecc741a1f4b6b8498965bd39b4e6f2abc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:44:47 +0000 Subject: [PATCH 508/532] feat(api): OpenAPI spec update via Stainless API (#989) --- .stats.yml | 2 +- .../intel/indicator_feeds/indicator_feeds.py | 8 ++++++++ .../types/intel/indicator_feed_get_response.py | 12 ++++++++++++ .../types/intel/indicator_feed_update_params.py | 3 +++ tests/api_resources/intel/test_indicator_feeds.py | 2 ++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 23108291da9..829aeb28bc3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-263576da5eb5ab2ac4e94b5546f7851d1bba6cc4c7cda43454f07e0fc3feed13.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5e74e6bc5452012a8e268e22531fc275f2e79381aa2f2dd3fd8c0d16e6cd0a28.yml diff --git a/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py b/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py index 89be9cf8218..59883527aab 100644 --- a/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py +++ b/src/cloudflare/resources/intel/indicator_feeds/indicator_feeds.py @@ -127,6 +127,7 @@ def update( description: str | NotGiven = NOT_GIVEN, is_attributable: bool | NotGiven = NOT_GIVEN, is_public: bool | NotGiven = NOT_GIVEN, + name: 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, @@ -148,6 +149,8 @@ def update( is_public: The new is_public value of the feed + name: The new name of the feed + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -165,6 +168,7 @@ def update( "description": description, "is_attributable": is_attributable, "is_public": is_public, + "name": name, }, indicator_feed_update_params.IndicatorFeedUpdateParams, ), @@ -373,6 +377,7 @@ async def update( description: str | NotGiven = NOT_GIVEN, is_attributable: bool | NotGiven = NOT_GIVEN, is_public: bool | NotGiven = NOT_GIVEN, + name: 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, @@ -394,6 +399,8 @@ async def update( is_public: The new is_public value of the feed + name: The new name of the feed + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -411,6 +418,7 @@ async def update( "description": description, "is_attributable": is_attributable, "is_public": is_public, + "name": name, }, indicator_feed_update_params.IndicatorFeedUpdateParams, ), diff --git a/src/cloudflare/types/intel/indicator_feed_get_response.py b/src/cloudflare/types/intel/indicator_feed_get_response.py index 1fd0e75e82b..2ba6e9a1cfa 100644 --- a/src/cloudflare/types/intel/indicator_feed_get_response.py +++ b/src/cloudflare/types/intel/indicator_feed_get_response.py @@ -19,6 +19,12 @@ class IndicatorFeedGetResponse(BaseModel): description: Optional[str] = None """The description of the example test""" + is_attributable: Optional[bool] = None + """Whether the indicator feed can be attributed to a provider""" + + is_public: Optional[bool] = None + """Whether the indicator feed is exposed to customers""" + latest_upload_status: Optional[ Literal["Mirroring", "Unifying", "Loading", "Provisioning", "Complete", "Error"] ] = None @@ -29,3 +35,9 @@ class IndicatorFeedGetResponse(BaseModel): name: Optional[str] = None """The name of the indicator feed""" + + provider_id: Optional[str] = None + """The unique identifier for the provider""" + + provider_name: Optional[str] = None + """The provider of the indicator feed""" diff --git a/src/cloudflare/types/intel/indicator_feed_update_params.py b/src/cloudflare/types/intel/indicator_feed_update_params.py index 86c871309be..0d1eeb4f5da 100644 --- a/src/cloudflare/types/intel/indicator_feed_update_params.py +++ b/src/cloudflare/types/intel/indicator_feed_update_params.py @@ -19,3 +19,6 @@ class IndicatorFeedUpdateParams(TypedDict, total=False): is_public: bool """The new is_public value of the feed""" + + name: str + """The new name of the feed""" diff --git a/tests/api_resources/intel/test_indicator_feeds.py b/tests/api_resources/intel/test_indicator_feeds.py index 2e3f9022dd1..45aee641fae 100644 --- a/tests/api_resources/intel/test_indicator_feeds.py +++ b/tests/api_resources/intel/test_indicator_feeds.py @@ -86,6 +86,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: description="This is an example description", is_attributable=True, is_public=True, + name="indicator_list", ) assert_matches_type(Optional[IndicatorFeedUpdateResponse], indicator_feed, path=["response"]) @@ -312,6 +313,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare description="This is an example description", is_attributable=True, is_public=True, + name="indicator_list", ) assert_matches_type(Optional[IndicatorFeedUpdateResponse], indicator_feed, path=["response"]) From cc76cffbc92ab4a7c88108459723b19be60b6fd5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:47:11 +0000 Subject: [PATCH 509/532] feat(api): OpenAPI spec update via Stainless API (#990) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 829aeb28bc3..ff2efbe667d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5e74e6bc5452012a8e268e22531fc275f2e79381aa2f2dd3fd8c0d16e6cd0a28.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e3875d4464358c7aee5cbb9a4e0e39f0e400536dfadb684e8f217a2800897d0e.yml From 0d3feacc6e64117014242505b3b9d4222b5cc471 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:49:24 +0000 Subject: [PATCH 510/532] feat(api): OpenAPI spec update via Stainless API (#991) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ff2efbe667d..829aeb28bc3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e3875d4464358c7aee5cbb9a4e0e39f0e400536dfadb684e8f217a2800897d0e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5e74e6bc5452012a8e268e22531fc275f2e79381aa2f2dd3fd8c0d16e6cd0a28.yml From 05e0b92bd3b15a1a89e6c390046c027cb87fa6fd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 22:05:54 +0000 Subject: [PATCH 511/532] feat(api): OpenAPI spec update via Stainless API (#992) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 829aeb28bc3..ff2efbe667d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5e74e6bc5452012a8e268e22531fc275f2e79381aa2f2dd3fd8c0d16e6cd0a28.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e3875d4464358c7aee5cbb9a4e0e39f0e400536dfadb684e8f217a2800897d0e.yml From 9cb5cd7d018e59fbc6d2c069932cb222aaa81377 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 22:08:06 +0000 Subject: [PATCH 512/532] feat(api): OpenAPI spec update via Stainless API (#993) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ff2efbe667d..9b7ba14e5c6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e3875d4464358c7aee5cbb9a4e0e39f0e400536dfadb684e8f217a2800897d0e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d492ae5acff80b29c47150117fb6934a23891c45978e644382ebaa5bbee60222.yml From 349941a0f10e78688bec3cac9cab06fa22d13b68 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 22:28:14 +0000 Subject: [PATCH 513/532] feat(api): OpenAPI spec update via Stainless API (#994) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9b7ba14e5c6..ff2efbe667d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1343 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d492ae5acff80b29c47150117fb6934a23891c45978e644382ebaa5bbee60222.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e3875d4464358c7aee5cbb9a4e0e39f0e400536dfadb684e8f217a2800897d0e.yml From 3de54540a0c98b9069eb2d61e7a2aafd76270223 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 03:51:03 +0000 Subject: [PATCH 514/532] feat(api): update via SDK Studio (#995) --- .stats.yml | 2 +- api.md | 51 ++ src/cloudflare/_client.py | 8 + src/cloudflare/resources/__init__.py | 14 + src/cloudflare/resources/iam/__init__.py | 47 ++ src/cloudflare/resources/iam/iam.py | 112 +++ .../resources/iam/permission_groups.py | 305 ++++++++ .../resources/iam/resource_groups.py | 628 ++++++++++++++++ .../resources/page_shield/__init__.py | 14 + .../resources/page_shield/cookies.py | 412 +++++++++++ .../resources/page_shield/page_shield.py | 32 + src/cloudflare/types/iam/__init__.py | 13 + .../iam/permission_group_get_response.py | 18 + .../types/iam/permission_group_list_params.py | 27 + .../types/iam/resource_group_create_params.py | 41 + .../iam/resource_group_create_response.py | 40 + .../iam/resource_group_delete_response.py | 12 + .../types/iam/resource_group_get_response.py | 40 + .../types/iam/resource_group_list_params.py | 24 + .../types/iam/resource_group_update_params.py | 41 + .../iam/resource_group_update_response.py | 40 + src/cloudflare/types/page_shield/__init__.py | 4 + .../types/page_shield/cookie_get_response.py | 40 + .../types/page_shield/cookie_list_params.py | 75 ++ .../types/page_shield/cookie_list_response.py | 40 + src/cloudflare/types/page_shield/policy.py | 27 + tests/api_resources/iam/__init__.py | 1 + .../iam/test_permission_groups.py | 219 ++++++ .../api_resources/iam/test_resource_groups.py | 700 ++++++++++++++++++ .../api_resources/page_shield/test_cookies.py | 237 ++++++ 30 files changed, 3263 insertions(+), 1 deletion(-) create mode 100644 src/cloudflare/resources/iam/__init__.py create mode 100644 src/cloudflare/resources/iam/iam.py create mode 100644 src/cloudflare/resources/iam/permission_groups.py create mode 100644 src/cloudflare/resources/iam/resource_groups.py create mode 100644 src/cloudflare/resources/page_shield/cookies.py create mode 100644 src/cloudflare/types/iam/__init__.py create mode 100644 src/cloudflare/types/iam/permission_group_get_response.py create mode 100644 src/cloudflare/types/iam/permission_group_list_params.py create mode 100644 src/cloudflare/types/iam/resource_group_create_params.py create mode 100644 src/cloudflare/types/iam/resource_group_create_response.py create mode 100644 src/cloudflare/types/iam/resource_group_delete_response.py create mode 100644 src/cloudflare/types/iam/resource_group_get_response.py create mode 100644 src/cloudflare/types/iam/resource_group_list_params.py create mode 100644 src/cloudflare/types/iam/resource_group_update_params.py create mode 100644 src/cloudflare/types/iam/resource_group_update_response.py create mode 100644 src/cloudflare/types/page_shield/cookie_get_response.py create mode 100644 src/cloudflare/types/page_shield/cookie_list_params.py create mode 100644 src/cloudflare/types/page_shield/cookie_list_response.py create mode 100644 src/cloudflare/types/page_shield/policy.py create mode 100644 tests/api_resources/iam/__init__.py create mode 100644 tests/api_resources/iam/test_permission_groups.py create mode 100644 tests/api_resources/iam/test_resource_groups.py create mode 100644 tests/api_resources/page_shield/test_cookies.py diff --git a/.stats.yml b/.stats.yml index ff2efbe667d..21c949824d8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1343 +configured_endpoints: 1352 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e3875d4464358c7aee5cbb9a4e0e39f0e400536dfadb684e8f217a2800897d0e.yml diff --git a/api.md b/api.md index 0fcdd96ea84..d3993e81805 100644 --- a/api.md +++ b/api.md @@ -3131,6 +3131,7 @@ Types: ```python from cloudflare.types.page_shield import ( + Policy, PolicyCreateResponse, PolicyUpdateResponse, PolicyListResponse, @@ -3172,6 +3173,19 @@ Methods: - client.page_shield.scripts.list(\*, zone_id, \*\*params) -> SyncSinglePage[Script] - client.page_shield.scripts.get(script_id, \*, zone_id) -> Optional +## Cookies + +Types: + +```python +from cloudflare.types.page_shield import CookieListResponse, CookieGetResponse +``` + +Methods: + +- client.page_shield.cookies.list(\*, zone_id, \*\*params) -> SyncSinglePage[CookieListResponse] +- client.page_shield.cookies.get(cookie_id, \*, zone_id) -> Optional + # Rulesets Types: @@ -7882,3 +7896,40 @@ from cloudflare.types.ai_gateway import LogGetResponse Methods: - client.ai_gateway.logs.get(id, \*, account_id, \*\*params) -> LogGetResponse + +# Iam + +## PermissionGroups + +Types: + +```python +from cloudflare.types.iam import PermissionGroupListResponse, PermissionGroupGetResponse +``` + +Methods: + +- client.iam.permission_groups.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[object] +- client.iam.permission_groups.get(permission_group_id, \*, account_id) -> PermissionGroupGetResponse + +## ResourceGroups + +Types: + +```python +from cloudflare.types.iam import ( + ResourceGroupCreateResponse, + ResourceGroupUpdateResponse, + ResourceGroupListResponse, + ResourceGroupDeleteResponse, + ResourceGroupGetResponse, +) +``` + +Methods: + +- client.iam.resource_groups.create(\*, account_id, \*\*params) -> ResourceGroupCreateResponse +- client.iam.resource_groups.update(resource_group_id, \*, account_id, \*\*params) -> ResourceGroupUpdateResponse +- client.iam.resource_groups.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[object] +- client.iam.resource_groups.delete(resource_group_id, \*, account_id) -> Optional +- client.iam.resource_groups.get(resource_group_id, \*, account_id) -> ResourceGroupGetResponse diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index c31dee6829f..1c536763963 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -130,6 +130,7 @@ class Cloudflare(SyncAPIClient): cloudforce_one: resources.CloudforceOneResource event_notifications: resources.EventNotificationsResource ai_gateway: resources.AIGatewayResource + iam: resources.IamResource with_raw_response: CloudflareWithRawResponse with_streaming_response: CloudflareWithStreamedResponse @@ -288,6 +289,7 @@ def __init__( self.cloudforce_one = resources.CloudforceOneResource(self) self.event_notifications = resources.EventNotificationsResource(self) self.ai_gateway = resources.AIGatewayResource(self) + self.iam = resources.IamResource(self) self.with_raw_response = CloudflareWithRawResponse(self) self.with_streaming_response = CloudflareWithStreamedResponse(self) @@ -549,6 +551,7 @@ class AsyncCloudflare(AsyncAPIClient): cloudforce_one: resources.AsyncCloudforceOneResource event_notifications: resources.AsyncEventNotificationsResource ai_gateway: resources.AsyncAIGatewayResource + iam: resources.AsyncIamResource with_raw_response: AsyncCloudflareWithRawResponse with_streaming_response: AsyncCloudflareWithStreamedResponse @@ -707,6 +710,7 @@ def __init__( self.cloudforce_one = resources.AsyncCloudforceOneResource(self) self.event_notifications = resources.AsyncEventNotificationsResource(self) self.ai_gateway = resources.AsyncAIGatewayResource(self) + self.iam = resources.AsyncIamResource(self) self.with_raw_response = AsyncCloudflareWithRawResponse(self) self.with_streaming_response = AsyncCloudflareWithStreamedResponse(self) @@ -979,6 +983,7 @@ def __init__(self, client: Cloudflare) -> None: self.cloudforce_one = resources.CloudforceOneResourceWithRawResponse(client.cloudforce_one) self.event_notifications = resources.EventNotificationsResourceWithRawResponse(client.event_notifications) self.ai_gateway = resources.AIGatewayResourceWithRawResponse(client.ai_gateway) + self.iam = resources.IamResourceWithRawResponse(client.iam) class AsyncCloudflareWithRawResponse: @@ -1080,6 +1085,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.cloudforce_one = resources.AsyncCloudforceOneResourceWithRawResponse(client.cloudforce_one) self.event_notifications = resources.AsyncEventNotificationsResourceWithRawResponse(client.event_notifications) self.ai_gateway = resources.AsyncAIGatewayResourceWithRawResponse(client.ai_gateway) + self.iam = resources.AsyncIamResourceWithRawResponse(client.iam) class CloudflareWithStreamedResponse: @@ -1181,6 +1187,7 @@ def __init__(self, client: Cloudflare) -> None: self.cloudforce_one = resources.CloudforceOneResourceWithStreamingResponse(client.cloudforce_one) self.event_notifications = resources.EventNotificationsResourceWithStreamingResponse(client.event_notifications) self.ai_gateway = resources.AIGatewayResourceWithStreamingResponse(client.ai_gateway) + self.iam = resources.IamResourceWithStreamingResponse(client.iam) class AsyncCloudflareWithStreamedResponse: @@ -1290,6 +1297,7 @@ def __init__(self, client: AsyncCloudflare) -> None: client.event_notifications ) self.ai_gateway = resources.AsyncAIGatewayResourceWithStreamingResponse(client.ai_gateway) + self.iam = resources.AsyncIamResourceWithStreamingResponse(client.iam) Client = Cloudflare diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index 5eacc4bdd5c..e5fa7b69add 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -40,6 +40,14 @@ DNSResourceWithStreamingResponse, AsyncDNSResourceWithStreamingResponse, ) +from .iam import ( + IamResource, + AsyncIamResource, + IamResourceWithRawResponse, + AsyncIamResourceWithRawResponse, + IamResourceWithStreamingResponse, + AsyncIamResourceWithStreamingResponse, +) from .ips import ( IPsResource, AsyncIPsResource, @@ -1164,4 +1172,10 @@ "AsyncAIGatewayResourceWithRawResponse", "AIGatewayResourceWithStreamingResponse", "AsyncAIGatewayResourceWithStreamingResponse", + "IamResource", + "AsyncIamResource", + "IamResourceWithRawResponse", + "AsyncIamResourceWithRawResponse", + "IamResourceWithStreamingResponse", + "AsyncIamResourceWithStreamingResponse", ] diff --git a/src/cloudflare/resources/iam/__init__.py b/src/cloudflare/resources/iam/__init__.py new file mode 100644 index 00000000000..0384bf2c0e0 --- /dev/null +++ b/src/cloudflare/resources/iam/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .iam import ( + IamResource, + AsyncIamResource, + IamResourceWithRawResponse, + AsyncIamResourceWithRawResponse, + IamResourceWithStreamingResponse, + AsyncIamResourceWithStreamingResponse, +) +from .resource_groups import ( + ResourceGroupsResource, + AsyncResourceGroupsResource, + ResourceGroupsResourceWithRawResponse, + AsyncResourceGroupsResourceWithRawResponse, + ResourceGroupsResourceWithStreamingResponse, + AsyncResourceGroupsResourceWithStreamingResponse, +) +from .permission_groups import ( + PermissionGroupsResource, + AsyncPermissionGroupsResource, + PermissionGroupsResourceWithRawResponse, + AsyncPermissionGroupsResourceWithRawResponse, + PermissionGroupsResourceWithStreamingResponse, + AsyncPermissionGroupsResourceWithStreamingResponse, +) + +__all__ = [ + "PermissionGroupsResource", + "AsyncPermissionGroupsResource", + "PermissionGroupsResourceWithRawResponse", + "AsyncPermissionGroupsResourceWithRawResponse", + "PermissionGroupsResourceWithStreamingResponse", + "AsyncPermissionGroupsResourceWithStreamingResponse", + "ResourceGroupsResource", + "AsyncResourceGroupsResource", + "ResourceGroupsResourceWithRawResponse", + "AsyncResourceGroupsResourceWithRawResponse", + "ResourceGroupsResourceWithStreamingResponse", + "AsyncResourceGroupsResourceWithStreamingResponse", + "IamResource", + "AsyncIamResource", + "IamResourceWithRawResponse", + "AsyncIamResourceWithRawResponse", + "IamResourceWithStreamingResponse", + "AsyncIamResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/iam/iam.py b/src/cloudflare/resources/iam/iam.py new file mode 100644 index 00000000000..ec7756d7f63 --- /dev/null +++ b/src/cloudflare/resources/iam/iam.py @@ -0,0 +1,112 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from .resource_groups import ( + ResourceGroupsResource, + AsyncResourceGroupsResource, + ResourceGroupsResourceWithRawResponse, + AsyncResourceGroupsResourceWithRawResponse, + ResourceGroupsResourceWithStreamingResponse, + AsyncResourceGroupsResourceWithStreamingResponse, +) +from .permission_groups import ( + PermissionGroupsResource, + AsyncPermissionGroupsResource, + PermissionGroupsResourceWithRawResponse, + AsyncPermissionGroupsResourceWithRawResponse, + PermissionGroupsResourceWithStreamingResponse, + AsyncPermissionGroupsResourceWithStreamingResponse, +) + +__all__ = ["IamResource", "AsyncIamResource"] + + +class IamResource(SyncAPIResource): + @cached_property + def permission_groups(self) -> PermissionGroupsResource: + return PermissionGroupsResource(self._client) + + @cached_property + def resource_groups(self) -> ResourceGroupsResource: + return ResourceGroupsResource(self._client) + + @cached_property + def with_raw_response(self) -> IamResourceWithRawResponse: + return IamResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IamResourceWithStreamingResponse: + return IamResourceWithStreamingResponse(self) + + +class AsyncIamResource(AsyncAPIResource): + @cached_property + def permission_groups(self) -> AsyncPermissionGroupsResource: + return AsyncPermissionGroupsResource(self._client) + + @cached_property + def resource_groups(self) -> AsyncResourceGroupsResource: + return AsyncResourceGroupsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncIamResourceWithRawResponse: + return AsyncIamResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIamResourceWithStreamingResponse: + return AsyncIamResourceWithStreamingResponse(self) + + +class IamResourceWithRawResponse: + def __init__(self, iam: IamResource) -> None: + self._iam = iam + + @cached_property + def permission_groups(self) -> PermissionGroupsResourceWithRawResponse: + return PermissionGroupsResourceWithRawResponse(self._iam.permission_groups) + + @cached_property + def resource_groups(self) -> ResourceGroupsResourceWithRawResponse: + return ResourceGroupsResourceWithRawResponse(self._iam.resource_groups) + + +class AsyncIamResourceWithRawResponse: + def __init__(self, iam: AsyncIamResource) -> None: + self._iam = iam + + @cached_property + def permission_groups(self) -> AsyncPermissionGroupsResourceWithRawResponse: + return AsyncPermissionGroupsResourceWithRawResponse(self._iam.permission_groups) + + @cached_property + def resource_groups(self) -> AsyncResourceGroupsResourceWithRawResponse: + return AsyncResourceGroupsResourceWithRawResponse(self._iam.resource_groups) + + +class IamResourceWithStreamingResponse: + def __init__(self, iam: IamResource) -> None: + self._iam = iam + + @cached_property + def permission_groups(self) -> PermissionGroupsResourceWithStreamingResponse: + return PermissionGroupsResourceWithStreamingResponse(self._iam.permission_groups) + + @cached_property + def resource_groups(self) -> ResourceGroupsResourceWithStreamingResponse: + return ResourceGroupsResourceWithStreamingResponse(self._iam.resource_groups) + + +class AsyncIamResourceWithStreamingResponse: + def __init__(self, iam: AsyncIamResource) -> None: + self._iam = iam + + @cached_property + def permission_groups(self) -> AsyncPermissionGroupsResourceWithStreamingResponse: + return AsyncPermissionGroupsResourceWithStreamingResponse(self._iam.permission_groups) + + @cached_property + def resource_groups(self) -> AsyncResourceGroupsResourceWithStreamingResponse: + return AsyncResourceGroupsResourceWithStreamingResponse(self._iam.resource_groups) diff --git a/src/cloudflare/resources/iam/permission_groups.py b/src/cloudflare/resources/iam/permission_groups.py new file mode 100644 index 00000000000..1bb7effc98d --- /dev/null +++ b/src/cloudflare/resources/iam/permission_groups.py @@ -0,0 +1,305 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...types.iam import permission_group_list_params +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import ( + AsyncPaginator, + make_request_options, +) +from ...types.iam.permission_group_get_response import PermissionGroupGetResponse + +__all__ = ["PermissionGroupsResource", "AsyncPermissionGroupsResource"] + + +class PermissionGroupsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PermissionGroupsResourceWithRawResponse: + return PermissionGroupsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PermissionGroupsResourceWithStreamingResponse: + return PermissionGroupsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + id: str | NotGiven = NOT_GIVEN, + label: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + page: float | NotGiven = NOT_GIVEN, + per_page: float | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncV4PagePaginationArray[object]: + """ + List all the permissions groups for an account. + + Args: + account_id: Account identifier tag. + + id: ID of the permission group to be fetched. + + label: Label of the permission group to be fetched. + + name: Name of the permission group to be fetched. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/iam/permission_groups", + page=SyncV4PagePaginationArray[object], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "label": label, + "name": name, + "page": page, + "per_page": per_page, + }, + permission_group_list_params.PermissionGroupListParams, + ), + ), + model=object, + ) + + def get( + self, + permission_group_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, + ) -> PermissionGroupGetResponse: + """ + Get information about a specific permission group in an account. + + Args: + account_id: Account identifier tag. + + permission_group_id: Permission Group identifier tag. + + 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 permission_group_id: + raise ValueError( + f"Expected a non-empty value for `permission_group_id` but received {permission_group_id!r}" + ) + return self._get( + f"/accounts/{account_id}/iam/permission_groups/{permission_group_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=PermissionGroupGetResponse, + ) + + +class AsyncPermissionGroupsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPermissionGroupsResourceWithRawResponse: + return AsyncPermissionGroupsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPermissionGroupsResourceWithStreamingResponse: + return AsyncPermissionGroupsResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + id: str | NotGiven = NOT_GIVEN, + label: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + page: float | NotGiven = NOT_GIVEN, + per_page: float | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[object, AsyncV4PagePaginationArray[object]]: + """ + List all the permissions groups for an account. + + Args: + account_id: Account identifier tag. + + id: ID of the permission group to be fetched. + + label: Label of the permission group to be fetched. + + name: Name of the permission group to be fetched. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/iam/permission_groups", + page=AsyncV4PagePaginationArray[object], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "label": label, + "name": name, + "page": page, + "per_page": per_page, + }, + permission_group_list_params.PermissionGroupListParams, + ), + ), + model=object, + ) + + async def get( + self, + permission_group_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, + ) -> PermissionGroupGetResponse: + """ + Get information about a specific permission group in an account. + + Args: + account_id: Account identifier tag. + + permission_group_id: Permission Group identifier tag. + + 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 permission_group_id: + raise ValueError( + f"Expected a non-empty value for `permission_group_id` but received {permission_group_id!r}" + ) + return await self._get( + f"/accounts/{account_id}/iam/permission_groups/{permission_group_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=PermissionGroupGetResponse, + ) + + +class PermissionGroupsResourceWithRawResponse: + def __init__(self, permission_groups: PermissionGroupsResource) -> None: + self._permission_groups = permission_groups + + self.list = to_raw_response_wrapper( + permission_groups.list, + ) + self.get = to_raw_response_wrapper( + permission_groups.get, + ) + + +class AsyncPermissionGroupsResourceWithRawResponse: + def __init__(self, permission_groups: AsyncPermissionGroupsResource) -> None: + self._permission_groups = permission_groups + + self.list = async_to_raw_response_wrapper( + permission_groups.list, + ) + self.get = async_to_raw_response_wrapper( + permission_groups.get, + ) + + +class PermissionGroupsResourceWithStreamingResponse: + def __init__(self, permission_groups: PermissionGroupsResource) -> None: + self._permission_groups = permission_groups + + self.list = to_streamed_response_wrapper( + permission_groups.list, + ) + self.get = to_streamed_response_wrapper( + permission_groups.get, + ) + + +class AsyncPermissionGroupsResourceWithStreamingResponse: + def __init__(self, permission_groups: AsyncPermissionGroupsResource) -> None: + self._permission_groups = permission_groups + + self.list = async_to_streamed_response_wrapper( + permission_groups.list, + ) + self.get = async_to_streamed_response_wrapper( + permission_groups.get, + ) diff --git a/src/cloudflare/resources/iam/resource_groups.py b/src/cloudflare/resources/iam/resource_groups.py new file mode 100644 index 00000000000..9d524bcea8e --- /dev/null +++ b/src/cloudflare/resources/iam/resource_groups.py @@ -0,0 +1,628 @@ +# 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 ..._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 ...types.iam import resource_group_list_params, resource_group_create_params, resource_group_update_params +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ..._base_client import ( + AsyncPaginator, + make_request_options, +) +from ...types.iam.resource_group_get_response import ResourceGroupGetResponse +from ...types.iam.resource_group_create_response import ResourceGroupCreateResponse +from ...types.iam.resource_group_delete_response import ResourceGroupDeleteResponse +from ...types.iam.resource_group_update_response import ResourceGroupUpdateResponse + +__all__ = ["ResourceGroupsResource", "AsyncResourceGroupsResource"] + + +class ResourceGroupsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ResourceGroupsResourceWithRawResponse: + return ResourceGroupsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ResourceGroupsResourceWithStreamingResponse: + return ResourceGroupsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + scope: resource_group_create_params.Scope, + meta: object | 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, + ) -> ResourceGroupCreateResponse: + """ + Create a new Resource Group under the specified account. + + Args: + account_id: Account identifier tag. + + scope: A scope is a combination of scope objects which provides additional context. + + meta: Attributes associated to the resource group. + + 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}/iam/resource_groups", + body=maybe_transform( + { + "scope": scope, + "meta": meta, + }, + resource_group_create_params.ResourceGroupCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ResourceGroupCreateResponse, + ) + + def update( + self, + resource_group_id: str, + *, + account_id: str, + scope: resource_group_update_params.Scope, + meta: object | 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, + ) -> ResourceGroupUpdateResponse: + """ + Modify an existing resource group. + + Args: + account_id: Account identifier tag. + + resource_group_id: Resource Group identifier tag. + + scope: A scope is a combination of scope objects which provides additional context. + + meta: Attributes associated to the resource group. + + 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 resource_group_id: + raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") + return self._put( + f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + body=maybe_transform( + { + "scope": scope, + "meta": meta, + }, + resource_group_update_params.ResourceGroupUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ResourceGroupUpdateResponse, + ) + + def list( + self, + *, + account_id: str, + id: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + page: float | NotGiven = NOT_GIVEN, + per_page: float | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncV4PagePaginationArray[object]: + """ + List all the resource groups for an account. + + Args: + account_id: Account identifier tag. + + id: ID of the resource group to be fetched. + + name: Name of the resource group to be fetched. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/iam/resource_groups", + page=SyncV4PagePaginationArray[object], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "name": name, + "page": page, + "per_page": per_page, + }, + resource_group_list_params.ResourceGroupListParams, + ), + ), + model=object, + ) + + def delete( + self, + resource_group_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[ResourceGroupDeleteResponse]: + """ + Remove a resource group from an account. + + Args: + account_id: Account identifier tag. + + resource_group_id: Resource Group identifier tag. + + 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 resource_group_id: + raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") + return self._delete( + f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceGroupDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceGroupDeleteResponse]], ResultWrapper[ResourceGroupDeleteResponse]), + ) + + def get( + self, + resource_group_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, + ) -> ResourceGroupGetResponse: + """ + Get information about a specific resource group in an account. + + Args: + account_id: Account identifier tag. + + resource_group_id: Resource Group identifier tag. + + 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 resource_group_id: + raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") + return self._get( + f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ResourceGroupGetResponse, + ) + + +class AsyncResourceGroupsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncResourceGroupsResourceWithRawResponse: + return AsyncResourceGroupsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncResourceGroupsResourceWithStreamingResponse: + return AsyncResourceGroupsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + scope: resource_group_create_params.Scope, + meta: object | 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, + ) -> ResourceGroupCreateResponse: + """ + Create a new Resource Group under the specified account. + + Args: + account_id: Account identifier tag. + + scope: A scope is a combination of scope objects which provides additional context. + + meta: Attributes associated to the resource group. + + 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}/iam/resource_groups", + body=await async_maybe_transform( + { + "scope": scope, + "meta": meta, + }, + resource_group_create_params.ResourceGroupCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ResourceGroupCreateResponse, + ) + + async def update( + self, + resource_group_id: str, + *, + account_id: str, + scope: resource_group_update_params.Scope, + meta: object | 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, + ) -> ResourceGroupUpdateResponse: + """ + Modify an existing resource group. + + Args: + account_id: Account identifier tag. + + resource_group_id: Resource Group identifier tag. + + scope: A scope is a combination of scope objects which provides additional context. + + meta: Attributes associated to the resource group. + + 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 resource_group_id: + raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") + return await self._put( + f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + body=await async_maybe_transform( + { + "scope": scope, + "meta": meta, + }, + resource_group_update_params.ResourceGroupUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ResourceGroupUpdateResponse, + ) + + def list( + self, + *, + account_id: str, + id: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + page: float | NotGiven = NOT_GIVEN, + per_page: float | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[object, AsyncV4PagePaginationArray[object]]: + """ + List all the resource groups for an account. + + Args: + account_id: Account identifier tag. + + id: ID of the resource group to be fetched. + + name: Name of the resource group to be fetched. + + page: Page number of paginated results. + + per_page: Maximum number of results per page. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not 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}/iam/resource_groups", + page=AsyncV4PagePaginationArray[object], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "id": id, + "name": name, + "page": page, + "per_page": per_page, + }, + resource_group_list_params.ResourceGroupListParams, + ), + ), + model=object, + ) + + async def delete( + self, + resource_group_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[ResourceGroupDeleteResponse]: + """ + Remove a resource group from an account. + + Args: + account_id: Account identifier tag. + + resource_group_id: Resource Group identifier tag. + + 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 resource_group_id: + raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") + return await self._delete( + f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ResourceGroupDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ResourceGroupDeleteResponse]], ResultWrapper[ResourceGroupDeleteResponse]), + ) + + async def get( + self, + resource_group_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, + ) -> ResourceGroupGetResponse: + """ + Get information about a specific resource group in an account. + + Args: + account_id: Account identifier tag. + + resource_group_id: Resource Group identifier tag. + + 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 resource_group_id: + raise ValueError(f"Expected a non-empty value for `resource_group_id` but received {resource_group_id!r}") + return await self._get( + f"/accounts/{account_id}/iam/resource_groups/{resource_group_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ResourceGroupGetResponse, + ) + + +class ResourceGroupsResourceWithRawResponse: + def __init__(self, resource_groups: ResourceGroupsResource) -> None: + self._resource_groups = resource_groups + + self.create = to_raw_response_wrapper( + resource_groups.create, + ) + self.update = to_raw_response_wrapper( + resource_groups.update, + ) + self.list = to_raw_response_wrapper( + resource_groups.list, + ) + self.delete = to_raw_response_wrapper( + resource_groups.delete, + ) + self.get = to_raw_response_wrapper( + resource_groups.get, + ) + + +class AsyncResourceGroupsResourceWithRawResponse: + def __init__(self, resource_groups: AsyncResourceGroupsResource) -> None: + self._resource_groups = resource_groups + + self.create = async_to_raw_response_wrapper( + resource_groups.create, + ) + self.update = async_to_raw_response_wrapper( + resource_groups.update, + ) + self.list = async_to_raw_response_wrapper( + resource_groups.list, + ) + self.delete = async_to_raw_response_wrapper( + resource_groups.delete, + ) + self.get = async_to_raw_response_wrapper( + resource_groups.get, + ) + + +class ResourceGroupsResourceWithStreamingResponse: + def __init__(self, resource_groups: ResourceGroupsResource) -> None: + self._resource_groups = resource_groups + + self.create = to_streamed_response_wrapper( + resource_groups.create, + ) + self.update = to_streamed_response_wrapper( + resource_groups.update, + ) + self.list = to_streamed_response_wrapper( + resource_groups.list, + ) + self.delete = to_streamed_response_wrapper( + resource_groups.delete, + ) + self.get = to_streamed_response_wrapper( + resource_groups.get, + ) + + +class AsyncResourceGroupsResourceWithStreamingResponse: + def __init__(self, resource_groups: AsyncResourceGroupsResource) -> None: + self._resource_groups = resource_groups + + self.create = async_to_streamed_response_wrapper( + resource_groups.create, + ) + self.update = async_to_streamed_response_wrapper( + resource_groups.update, + ) + self.list = async_to_streamed_response_wrapper( + resource_groups.list, + ) + self.delete = async_to_streamed_response_wrapper( + resource_groups.delete, + ) + self.get = async_to_streamed_response_wrapper( + resource_groups.get, + ) diff --git a/src/cloudflare/resources/page_shield/__init__.py b/src/cloudflare/resources/page_shield/__init__.py index 42a42e10c4d..31bb6daa0ad 100644 --- a/src/cloudflare/resources/page_shield/__init__.py +++ b/src/cloudflare/resources/page_shield/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .cookies import ( + CookiesResource, + AsyncCookiesResource, + CookiesResourceWithRawResponse, + AsyncCookiesResourceWithRawResponse, + CookiesResourceWithStreamingResponse, + AsyncCookiesResourceWithStreamingResponse, +) from .scripts import ( ScriptsResource, AsyncScriptsResource, @@ -52,6 +60,12 @@ "AsyncScriptsResourceWithRawResponse", "ScriptsResourceWithStreamingResponse", "AsyncScriptsResourceWithStreamingResponse", + "CookiesResource", + "AsyncCookiesResource", + "CookiesResourceWithRawResponse", + "AsyncCookiesResourceWithRawResponse", + "CookiesResourceWithStreamingResponse", + "AsyncCookiesResourceWithStreamingResponse", "PageShieldResource", "AsyncPageShieldResource", "PageShieldResourceWithRawResponse", diff --git a/src/cloudflare/resources/page_shield/cookies.py b/src/cloudflare/resources/page_shield/cookies.py new file mode 100644 index 00000000000..d35ffba6734 --- /dev/null +++ b/src/cloudflare/resources/page_shield/cookies.py @@ -0,0 +1,412 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast +from typing_extensions import Literal + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ...pagination import SyncSinglePage, AsyncSinglePage +from ..._base_client import ( + AsyncPaginator, + make_request_options, +) +from ...types.page_shield import cookie_list_params +from ...types.page_shield.cookie_get_response import CookieGetResponse +from ...types.page_shield.cookie_list_response import CookieListResponse + +__all__ = ["CookiesResource", "AsyncCookiesResource"] + + +class CookiesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> CookiesResourceWithRawResponse: + return CookiesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CookiesResourceWithStreamingResponse: + return CookiesResourceWithStreamingResponse(self) + + def list( + self, + *, + zone_id: str, + direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + domain: str | NotGiven = NOT_GIVEN, + export: Literal["csv"] | NotGiven = NOT_GIVEN, + hosts: str | NotGiven = NOT_GIVEN, + http_only: bool | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + order_by: Literal["first_seen_at", "last_seen_at"] | NotGiven = NOT_GIVEN, + page: str | NotGiven = NOT_GIVEN, + page_url: str | NotGiven = NOT_GIVEN, + path: str | NotGiven = NOT_GIVEN, + per_page: float | NotGiven = NOT_GIVEN, + same_site: Literal["lax", "strict", "none"] | NotGiven = NOT_GIVEN, + secure: bool | NotGiven = NOT_GIVEN, + type: Literal["first_party", "unknown"] | 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, + ) -> SyncSinglePage[CookieListResponse]: + """ + Lists all cookies collected by Page Shield. + + Args: + zone_id: Identifier + + direction: The direction used to sort returned cookies.' + + domain: Filters the returned cookies that match the specified domain attribute + + export: Export the list of cookies as a file. Cannot be used with per_page or page + options. + + hosts: Includes cookies that match one or more URL-encoded hostnames separated by + commas. + + Wildcards are supported at the start and end of each hostname to support starts + with, ends with and contains. If no wildcards are used, results will be filtered + by exact match + + http_only: Filters the returned cookies that are set with HttpOnly + + name: Filters the returned cookies that match the specified name. Wildcards are + supported at the start and end to support starts with, ends with and contains. + e.g. session\\** + + order_by: The field used to sort returned cookies. + + page: The current page number of the paginated results. + + page_url: Includes connections that match one or more page URLs (separated by commas) + where they were last seen + + Wildcards are supported at the start and end of each page URL to support starts + with, ends with and contains. If no wildcards are used, results will be filtered + by exact match + + path: Filters the returned cookies that match the specified path attribute + + per_page: The number of results per page. + + same_site: Filters the returned cookies that match the specified same_site attribute + + secure: Filters the returned cookies that are set with Secure + + type: Filters the returned cookies that match the specified type attribute + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/page_shield/cookies", + page=SyncSinglePage[CookieListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "domain": domain, + "export": export, + "hosts": hosts, + "http_only": http_only, + "name": name, + "order_by": order_by, + "page": page, + "page_url": page_url, + "path": path, + "per_page": per_page, + "same_site": same_site, + "secure": secure, + "type": type, + }, + cookie_list_params.CookieListParams, + ), + ), + model=CookieListResponse, + ) + + def get( + self, + cookie_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CookieGetResponse]: + """ + Fetches a cookie collected by Page Shield by cookie ID. + + Args: + zone_id: Identifier + + cookie_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not cookie_id: + raise ValueError(f"Expected a non-empty value for `cookie_id` but received {cookie_id!r}") + return self._get( + f"/zones/{zone_id}/page_shield/cookies/{cookie_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CookieGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CookieGetResponse]], ResultWrapper[CookieGetResponse]), + ) + + +class AsyncCookiesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncCookiesResourceWithRawResponse: + return AsyncCookiesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCookiesResourceWithStreamingResponse: + return AsyncCookiesResourceWithStreamingResponse(self) + + def list( + self, + *, + zone_id: str, + direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + domain: str | NotGiven = NOT_GIVEN, + export: Literal["csv"] | NotGiven = NOT_GIVEN, + hosts: str | NotGiven = NOT_GIVEN, + http_only: bool | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + order_by: Literal["first_seen_at", "last_seen_at"] | NotGiven = NOT_GIVEN, + page: str | NotGiven = NOT_GIVEN, + page_url: str | NotGiven = NOT_GIVEN, + path: str | NotGiven = NOT_GIVEN, + per_page: float | NotGiven = NOT_GIVEN, + same_site: Literal["lax", "strict", "none"] | NotGiven = NOT_GIVEN, + secure: bool | NotGiven = NOT_GIVEN, + type: Literal["first_party", "unknown"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[CookieListResponse, AsyncSinglePage[CookieListResponse]]: + """ + Lists all cookies collected by Page Shield. + + Args: + zone_id: Identifier + + direction: The direction used to sort returned cookies.' + + domain: Filters the returned cookies that match the specified domain attribute + + export: Export the list of cookies as a file. Cannot be used with per_page or page + options. + + hosts: Includes cookies that match one or more URL-encoded hostnames separated by + commas. + + Wildcards are supported at the start and end of each hostname to support starts + with, ends with and contains. If no wildcards are used, results will be filtered + by exact match + + http_only: Filters the returned cookies that are set with HttpOnly + + name: Filters the returned cookies that match the specified name. Wildcards are + supported at the start and end to support starts with, ends with and contains. + e.g. session\\** + + order_by: The field used to sort returned cookies. + + page: The current page number of the paginated results. + + page_url: Includes connections that match one or more page URLs (separated by commas) + where they were last seen + + Wildcards are supported at the start and end of each page URL to support starts + with, ends with and contains. If no wildcards are used, results will be filtered + by exact match + + path: Filters the returned cookies that match the specified path attribute + + per_page: The number of results per page. + + same_site: Filters the returned cookies that match the specified same_site attribute + + secure: Filters the returned cookies that are set with Secure + + type: Filters the returned cookies that match the specified type attribute + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._get_api_list( + f"/zones/{zone_id}/page_shield/cookies", + page=AsyncSinglePage[CookieListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "domain": domain, + "export": export, + "hosts": hosts, + "http_only": http_only, + "name": name, + "order_by": order_by, + "page": page, + "page_url": page_url, + "path": path, + "per_page": per_page, + "same_site": same_site, + "secure": secure, + "type": type, + }, + cookie_list_params.CookieListParams, + ), + ), + model=CookieListResponse, + ) + + async def get( + self, + cookie_id: str, + *, + zone_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CookieGetResponse]: + """ + Fetches a cookie collected by Page Shield by cookie ID. + + Args: + zone_id: Identifier + + cookie_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not cookie_id: + raise ValueError(f"Expected a non-empty value for `cookie_id` but received {cookie_id!r}") + return await self._get( + f"/zones/{zone_id}/page_shield/cookies/{cookie_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CookieGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CookieGetResponse]], ResultWrapper[CookieGetResponse]), + ) + + +class CookiesResourceWithRawResponse: + def __init__(self, cookies: CookiesResource) -> None: + self._cookies = cookies + + self.list = to_raw_response_wrapper( + cookies.list, + ) + self.get = to_raw_response_wrapper( + cookies.get, + ) + + +class AsyncCookiesResourceWithRawResponse: + def __init__(self, cookies: AsyncCookiesResource) -> None: + self._cookies = cookies + + self.list = async_to_raw_response_wrapper( + cookies.list, + ) + self.get = async_to_raw_response_wrapper( + cookies.get, + ) + + +class CookiesResourceWithStreamingResponse: + def __init__(self, cookies: CookiesResource) -> None: + self._cookies = cookies + + self.list = to_streamed_response_wrapper( + cookies.list, + ) + self.get = to_streamed_response_wrapper( + cookies.get, + ) + + +class AsyncCookiesResourceWithStreamingResponse: + def __init__(self, cookies: AsyncCookiesResource) -> None: + self._cookies = cookies + + self.list = async_to_streamed_response_wrapper( + cookies.list, + ) + self.get = async_to_streamed_response_wrapper( + cookies.get, + ) diff --git a/src/cloudflare/resources/page_shield/page_shield.py b/src/cloudflare/resources/page_shield/page_shield.py index 655f3b4c4fd..9e7d2e27f74 100644 --- a/src/cloudflare/resources/page_shield/page_shield.py +++ b/src/cloudflare/resources/page_shield/page_shield.py @@ -6,6 +6,14 @@ import httpx +from .cookies import ( + CookiesResource, + AsyncCookiesResource, + CookiesResourceWithRawResponse, + AsyncCookiesResourceWithRawResponse, + CookiesResourceWithStreamingResponse, + AsyncCookiesResourceWithStreamingResponse, +) from .scripts import ( ScriptsResource, AsyncScriptsResource, @@ -67,6 +75,10 @@ def connections(self) -> ConnectionsResource: def scripts(self) -> ScriptsResource: return ScriptsResource(self._client) + @cached_property + def cookies(self) -> CookiesResource: + return CookiesResource(self._client) + @cached_property def with_raw_response(self) -> PageShieldResourceWithRawResponse: return PageShieldResourceWithRawResponse(self) @@ -185,6 +197,10 @@ def connections(self) -> AsyncConnectionsResource: def scripts(self) -> AsyncScriptsResource: return AsyncScriptsResource(self._client) + @cached_property + def cookies(self) -> AsyncCookiesResource: + return AsyncCookiesResource(self._client) + @cached_property def with_raw_response(self) -> AsyncPageShieldResourceWithRawResponse: return AsyncPageShieldResourceWithRawResponse(self) @@ -313,6 +329,10 @@ def connections(self) -> ConnectionsResourceWithRawResponse: def scripts(self) -> ScriptsResourceWithRawResponse: return ScriptsResourceWithRawResponse(self._page_shield.scripts) + @cached_property + def cookies(self) -> CookiesResourceWithRawResponse: + return CookiesResourceWithRawResponse(self._page_shield.cookies) + class AsyncPageShieldResourceWithRawResponse: def __init__(self, page_shield: AsyncPageShieldResource) -> None: @@ -337,6 +357,10 @@ def connections(self) -> AsyncConnectionsResourceWithRawResponse: def scripts(self) -> AsyncScriptsResourceWithRawResponse: return AsyncScriptsResourceWithRawResponse(self._page_shield.scripts) + @cached_property + def cookies(self) -> AsyncCookiesResourceWithRawResponse: + return AsyncCookiesResourceWithRawResponse(self._page_shield.cookies) + class PageShieldResourceWithStreamingResponse: def __init__(self, page_shield: PageShieldResource) -> None: @@ -361,6 +385,10 @@ def connections(self) -> ConnectionsResourceWithStreamingResponse: def scripts(self) -> ScriptsResourceWithStreamingResponse: return ScriptsResourceWithStreamingResponse(self._page_shield.scripts) + @cached_property + def cookies(self) -> CookiesResourceWithStreamingResponse: + return CookiesResourceWithStreamingResponse(self._page_shield.cookies) + class AsyncPageShieldResourceWithStreamingResponse: def __init__(self, page_shield: AsyncPageShieldResource) -> None: @@ -384,3 +412,7 @@ def connections(self) -> AsyncConnectionsResourceWithStreamingResponse: @cached_property def scripts(self) -> AsyncScriptsResourceWithStreamingResponse: return AsyncScriptsResourceWithStreamingResponse(self._page_shield.scripts) + + @cached_property + def cookies(self) -> AsyncCookiesResourceWithStreamingResponse: + return AsyncCookiesResourceWithStreamingResponse(self._page_shield.cookies) diff --git a/src/cloudflare/types/iam/__init__.py b/src/cloudflare/types/iam/__init__.py new file mode 100644 index 00000000000..5982e2443a2 --- /dev/null +++ b/src/cloudflare/types/iam/__init__.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .resource_group_list_params import ResourceGroupListParams as ResourceGroupListParams +from .resource_group_get_response import ResourceGroupGetResponse as ResourceGroupGetResponse +from .permission_group_list_params import PermissionGroupListParams as PermissionGroupListParams +from .resource_group_create_params import ResourceGroupCreateParams as ResourceGroupCreateParams +from .resource_group_update_params import ResourceGroupUpdateParams as ResourceGroupUpdateParams +from .permission_group_get_response import PermissionGroupGetResponse as PermissionGroupGetResponse +from .resource_group_create_response import ResourceGroupCreateResponse as ResourceGroupCreateResponse +from .resource_group_delete_response import ResourceGroupDeleteResponse as ResourceGroupDeleteResponse +from .resource_group_update_response import ResourceGroupUpdateResponse as ResourceGroupUpdateResponse diff --git a/src/cloudflare/types/iam/permission_group_get_response.py b/src/cloudflare/types/iam/permission_group_get_response.py new file mode 100644 index 00000000000..bfafb28bc92 --- /dev/null +++ b/src/cloudflare/types/iam/permission_group_get_response.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ..._models import BaseModel + +__all__ = ["PermissionGroupGetResponse"] + + +class PermissionGroupGetResponse(BaseModel): + id: str + """Identifier of the group.""" + + meta: Optional[object] = None + """Attributes associated to the permission group.""" + + name: Optional[str] = None + """Name of the group.""" diff --git a/src/cloudflare/types/iam/permission_group_list_params.py b/src/cloudflare/types/iam/permission_group_list_params.py new file mode 100644 index 00000000000..04f58ce75ce --- /dev/null +++ b/src/cloudflare/types/iam/permission_group_list_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["PermissionGroupListParams"] + + +class PermissionGroupListParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + id: str + """ID of the permission group to be fetched.""" + + label: str + """Label of the permission group to be fetched.""" + + name: str + """Name of the permission group to be fetched.""" + + page: float + """Page number of paginated results.""" + + per_page: float + """Maximum number of results per page.""" diff --git a/src/cloudflare/types/iam/resource_group_create_params.py b/src/cloudflare/types/iam/resource_group_create_params.py new file mode 100644 index 00000000000..7f583c5f87c --- /dev/null +++ b/src/cloudflare/types/iam/resource_group_create_params.py @@ -0,0 +1,41 @@ +# 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 + +__all__ = ["ResourceGroupCreateParams", "Scope", "ScopeObject"] + + +class ResourceGroupCreateParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + scope: Required[Scope] + """A scope is a combination of scope objects which provides additional context.""" + + meta: object + """Attributes associated to the resource group.""" + + +class ScopeObject(TypedDict, total=False): + key: Required[str] + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class Scope(TypedDict, total=False): + key: Required[str] + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: Required[Iterable[ScopeObject]] + """A list of scope objects for additional context. + + The number of Scope objects should not be zero. + """ diff --git a/src/cloudflare/types/iam/resource_group_create_response.py b/src/cloudflare/types/iam/resource_group_create_response.py new file mode 100644 index 00000000000..a6c3b5dc1b0 --- /dev/null +++ b/src/cloudflare/types/iam/resource_group_create_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["ResourceGroupCreateResponse", "Scope", "ScopeObject"] + + +class ScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class Scope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[ScopeObject] + """A list of scope objects for additional context. + + The number of Scope objects should not be zero. + """ + + +class ResourceGroupCreateResponse(BaseModel): + id: Optional[str] = None + """Identifier of the group.""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + scope: Optional[Scope] = None + """A scope is a combination of scope objects which provides additional context.""" diff --git a/src/cloudflare/types/iam/resource_group_delete_response.py b/src/cloudflare/types/iam/resource_group_delete_response.py new file mode 100644 index 00000000000..604eafbe8f0 --- /dev/null +++ b/src/cloudflare/types/iam/resource_group_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + + +from ..._models import BaseModel + +__all__ = ["ResourceGroupDeleteResponse"] + + +class ResourceGroupDeleteResponse(BaseModel): + id: str + """Identifier""" diff --git a/src/cloudflare/types/iam/resource_group_get_response.py b/src/cloudflare/types/iam/resource_group_get_response.py new file mode 100644 index 00000000000..26cc4314edc --- /dev/null +++ b/src/cloudflare/types/iam/resource_group_get_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["ResourceGroupGetResponse", "Scope", "ScopeObject"] + + +class ScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class Scope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[ScopeObject] + """A list of scope objects for additional context.""" + + +class ResourceGroupGetResponse(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[Scope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" diff --git a/src/cloudflare/types/iam/resource_group_list_params.py b/src/cloudflare/types/iam/resource_group_list_params.py new file mode 100644 index 00000000000..f6153181a2f --- /dev/null +++ b/src/cloudflare/types/iam/resource_group_list_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ResourceGroupListParams"] + + +class ResourceGroupListParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + id: str + """ID of the resource group to be fetched.""" + + name: str + """Name of the resource group to be fetched.""" + + page: float + """Page number of paginated results.""" + + per_page: float + """Maximum number of results per page.""" diff --git a/src/cloudflare/types/iam/resource_group_update_params.py b/src/cloudflare/types/iam/resource_group_update_params.py new file mode 100644 index 00000000000..eb50831f7be --- /dev/null +++ b/src/cloudflare/types/iam/resource_group_update_params.py @@ -0,0 +1,41 @@ +# 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 + +__all__ = ["ResourceGroupUpdateParams", "Scope", "ScopeObject"] + + +class ResourceGroupUpdateParams(TypedDict, total=False): + account_id: Required[str] + """Account identifier tag.""" + + scope: Required[Scope] + """A scope is a combination of scope objects which provides additional context.""" + + meta: object + """Attributes associated to the resource group.""" + + +class ScopeObject(TypedDict, total=False): + key: Required[str] + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class Scope(TypedDict, total=False): + key: Required[str] + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: Required[Iterable[ScopeObject]] + """A list of scope objects for additional context. + + The number of Scope objects should not be zero. + """ diff --git a/src/cloudflare/types/iam/resource_group_update_response.py b/src/cloudflare/types/iam/resource_group_update_response.py new file mode 100644 index 00000000000..8aa70682f42 --- /dev/null +++ b/src/cloudflare/types/iam/resource_group_update_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["ResourceGroupUpdateResponse", "Scope", "ScopeObject"] + + +class ScopeObject(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Zone ID + etc.) + """ + + +class Scope(BaseModel): + key: str + """ + This is a combination of pre-defined resource name and identifier (like Account + ID etc.) + """ + + objects: List[ScopeObject] + """A list of scope objects for additional context.""" + + +class ResourceGroupUpdateResponse(BaseModel): + id: str + """Identifier of the group.""" + + scope: List[Scope] + """The scope associated to the resource group""" + + meta: Optional[object] = None + """Attributes associated to the resource group.""" + + name: Optional[str] = None + """Name of the resource group.""" diff --git a/src/cloudflare/types/page_shield/__init__.py b/src/cloudflare/types/page_shield/__init__.py index 1442bda6660..a115366d760 100644 --- a/src/cloudflare/types/page_shield/__init__.py +++ b/src/cloudflare/types/page_shield/__init__.py @@ -2,12 +2,16 @@ from __future__ import annotations +from .policy import Policy as Policy from .script import Script as Script from .setting import Setting as Setting from .connection import Connection as Connection +from .cookie_list_params import CookieListParams as CookieListParams from .script_list_params import ScriptListParams as ScriptListParams +from .cookie_get_response import CookieGetResponse as CookieGetResponse from .policy_get_response import PolicyGetResponse as PolicyGetResponse from .script_get_response import ScriptGetResponse as ScriptGetResponse +from .cookie_list_response import CookieListResponse as CookieListResponse from .policy_create_params import PolicyCreateParams as PolicyCreateParams from .policy_list_response import PolicyListResponse as PolicyListResponse from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams diff --git a/src/cloudflare/types/page_shield/cookie_get_response.py b/src/cloudflare/types/page_shield/cookie_get_response.py new file mode 100644 index 00000000000..45735f30051 --- /dev/null +++ b/src/cloudflare/types/page_shield/cookie_get_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["CookieGetResponse"] + + +class CookieGetResponse(BaseModel): + id: str + """Identifier""" + + first_seen_at: datetime + + host: str + + last_seen_at: datetime + + name: str + + type: Literal["first_party", "unknown"] + + domain_attribute: Optional[str] = None + + expires_attribute: Optional[datetime] = None + + http_only_attribute: Optional[bool] = None + + max_age_attribute: Optional[int] = None + + page_urls: Optional[List[str]] = None + + path_attribute: Optional[str] = None + + same_site_attribute: Optional[Literal["lax", "strict", "none"]] = None + + secure_attribute: Optional[bool] = None diff --git a/src/cloudflare/types/page_shield/cookie_list_params.py b/src/cloudflare/types/page_shield/cookie_list_params.py new file mode 100644 index 00000000000..3daf5bdee9c --- /dev/null +++ b/src/cloudflare/types/page_shield/cookie_list_params.py @@ -0,0 +1,75 @@ +# 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__ = ["CookieListParams"] + + +class CookieListParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + direction: Literal["asc", "desc"] + """The direction used to sort returned cookies.'""" + + domain: str + """Filters the returned cookies that match the specified domain attribute""" + + export: Literal["csv"] + """Export the list of cookies as a file. + + Cannot be used with per_page or page options. + """ + + hosts: str + """ + Includes cookies that match one or more URL-encoded hostnames separated by + commas. + + Wildcards are supported at the start and end of each hostname to support starts + with, ends with and contains. If no wildcards are used, results will be filtered + by exact match + """ + + http_only: bool + """Filters the returned cookies that are set with HttpOnly""" + + name: str + """ + Filters the returned cookies that match the specified name. Wildcards are + supported at the start and end to support starts with, ends with and contains. + e.g. session\\** + """ + + order_by: Literal["first_seen_at", "last_seen_at"] + """The field used to sort returned cookies.""" + + page: str + """The current page number of the paginated results.""" + + page_url: str + """ + Includes connections that match one or more page URLs (separated by commas) + where they were last seen + + Wildcards are supported at the start and end of each page URL to support starts + with, ends with and contains. If no wildcards are used, results will be filtered + by exact match + """ + + path: str + """Filters the returned cookies that match the specified path attribute""" + + per_page: float + """The number of results per page.""" + + same_site: Literal["lax", "strict", "none"] + """Filters the returned cookies that match the specified same_site attribute""" + + secure: bool + """Filters the returned cookies that are set with Secure""" + + type: Literal["first_party", "unknown"] + """Filters the returned cookies that match the specified type attribute""" diff --git a/src/cloudflare/types/page_shield/cookie_list_response.py b/src/cloudflare/types/page_shield/cookie_list_response.py new file mode 100644 index 00000000000..144fd84b510 --- /dev/null +++ b/src/cloudflare/types/page_shield/cookie_list_response.py @@ -0,0 +1,40 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["CookieListResponse"] + + +class CookieListResponse(BaseModel): + id: str + """Identifier""" + + first_seen_at: datetime + + host: str + + last_seen_at: datetime + + name: str + + type: Literal["first_party", "unknown"] + + domain_attribute: Optional[str] = None + + expires_attribute: Optional[datetime] = None + + http_only_attribute: Optional[bool] = None + + max_age_attribute: Optional[int] = None + + page_urls: Optional[List[str]] = None + + path_attribute: Optional[str] = None + + same_site_attribute: Optional[Literal["lax", "strict", "none"]] = None + + secure_attribute: Optional[bool] = None diff --git a/src/cloudflare/types/page_shield/policy.py b/src/cloudflare/types/page_shield/policy.py new file mode 100644 index 00000000000..e2c5e6b02a5 --- /dev/null +++ b/src/cloudflare/types/page_shield/policy.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["Policy"] + + +class Policy(BaseModel): + action: Literal["allow", "log"] + """The action to take if the expression matches""" + + description: str + """A description for the policy""" + + enabled: bool + """Whether the policy is enabled""" + + expression: str + """ + The expression which must match for the policy to be applied, using the + Cloudflare Firewall rule expression syntax + """ + + value: str + """The policy which will be applied""" diff --git a/tests/api_resources/iam/__init__.py b/tests/api_resources/iam/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/iam/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/iam/test_permission_groups.py b/tests/api_resources/iam/test_permission_groups.py new file mode 100644 index 00000000000..298235ce84e --- /dev/null +++ b/tests/api_resources/iam/test_permission_groups.py @@ -0,0 +1,219 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.iam import PermissionGroupGetResponse +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestPermissionGroups: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + permission_group = client.iam.permission_groups.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(SyncV4PagePaginationArray[object], permission_group, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + permission_group = client.iam.permission_groups.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + id="6d7f2f5f5b1d4a0e9081fdc98d432fd1", + label="labelOfThePermissionGroup", + name="NameOfThePermissionGroup", + page=1, + per_page=5, + ) + assert_matches_type(SyncV4PagePaginationArray[object], permission_group, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.iam.permission_groups.with_raw_response.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + permission_group = response.parse() + assert_matches_type(SyncV4PagePaginationArray[object], permission_group, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.iam.permission_groups.with_streaming_response.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + permission_group = response.parse() + assert_matches_type(SyncV4PagePaginationArray[object], permission_group, 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.iam.permission_groups.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + permission_group = client.iam.permission_groups.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(PermissionGroupGetResponse, permission_group, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.iam.permission_groups.with_raw_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + permission_group = response.parse() + assert_matches_type(PermissionGroupGetResponse, permission_group, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.iam.permission_groups.with_streaming_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + permission_group = response.parse() + assert_matches_type(PermissionGroupGetResponse, permission_group, 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.iam.permission_groups.with_raw_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `permission_group_id` but received ''"): + client.iam.permission_groups.with_raw_response.get( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + +class TestAsyncPermissionGroups: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + permission_group = await async_client.iam.permission_groups.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(AsyncV4PagePaginationArray[object], permission_group, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + permission_group = await async_client.iam.permission_groups.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + id="6d7f2f5f5b1d4a0e9081fdc98d432fd1", + label="labelOfThePermissionGroup", + name="NameOfThePermissionGroup", + page=1, + per_page=5, + ) + assert_matches_type(AsyncV4PagePaginationArray[object], permission_group, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.iam.permission_groups.with_raw_response.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + permission_group = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[object], permission_group, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.iam.permission_groups.with_streaming_response.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + permission_group = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[object], permission_group, 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.iam.permission_groups.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + permission_group = await async_client.iam.permission_groups.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(PermissionGroupGetResponse, permission_group, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.iam.permission_groups.with_raw_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + permission_group = await response.parse() + assert_matches_type(PermissionGroupGetResponse, permission_group, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.iam.permission_groups.with_streaming_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + permission_group = await response.parse() + assert_matches_type(PermissionGroupGetResponse, permission_group, 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.iam.permission_groups.with_raw_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `permission_group_id` but received ''"): + await async_client.iam.permission_groups.with_raw_response.get( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) diff --git a/tests/api_resources/iam/test_resource_groups.py b/tests/api_resources/iam/test_resource_groups.py new file mode 100644 index 00000000000..a08c3160026 --- /dev/null +++ b/tests/api_resources/iam/test_resource_groups.py @@ -0,0 +1,700 @@ +# 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.iam import ( + ResourceGroupGetResponse, + ResourceGroupCreateResponse, + ResourceGroupDeleteResponse, + ResourceGroupUpdateResponse, +) +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestResourceGroups: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + resource_group = client.iam.resource_groups.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + assert_matches_type(ResourceGroupCreateResponse, resource_group, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + resource_group = client.iam.resource_groups.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + meta={"editable": "false"}, + ) + assert_matches_type(ResourceGroupCreateResponse, resource_group, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.iam.resource_groups.with_raw_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = response.parse() + assert_matches_type(ResourceGroupCreateResponse, resource_group, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.iam.resource_groups.with_streaming_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = response.parse() + assert_matches_type(ResourceGroupCreateResponse, resource_group, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.iam.resource_groups.with_raw_response.create( + account_id="", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + resource_group = client.iam.resource_groups.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + assert_matches_type(ResourceGroupUpdateResponse, resource_group, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + resource_group = client.iam.resource_groups.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + meta={"editable": "false"}, + ) + assert_matches_type(ResourceGroupUpdateResponse, resource_group, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.iam.resource_groups.with_raw_response.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = response.parse() + assert_matches_type(ResourceGroupUpdateResponse, resource_group, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.iam.resource_groups.with_streaming_response.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = response.parse() + assert_matches_type(ResourceGroupUpdateResponse, resource_group, 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.iam.resource_groups.with_raw_response.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_group_id` but received ''"): + client.iam.resource_groups.with_raw_response.update( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + resource_group = client.iam.resource_groups.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(SyncV4PagePaginationArray[object], resource_group, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + resource_group = client.iam.resource_groups.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + id="6d7f2f5f5b1d4a0e9081fdc98d432fd1", + name="NameOfTheResourceGroup", + page=1, + per_page=5, + ) + assert_matches_type(SyncV4PagePaginationArray[object], resource_group, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.iam.resource_groups.with_raw_response.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = response.parse() + assert_matches_type(SyncV4PagePaginationArray[object], resource_group, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.iam.resource_groups.with_streaming_response.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = response.parse() + assert_matches_type(SyncV4PagePaginationArray[object], resource_group, 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.iam.resource_groups.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + resource_group = client.iam.resource_groups.delete( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(Optional[ResourceGroupDeleteResponse], resource_group, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.iam.resource_groups.with_raw_response.delete( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = response.parse() + assert_matches_type(Optional[ResourceGroupDeleteResponse], resource_group, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.iam.resource_groups.with_streaming_response.delete( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = response.parse() + assert_matches_type(Optional[ResourceGroupDeleteResponse], resource_group, 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.iam.resource_groups.with_raw_response.delete( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_group_id` but received ''"): + client.iam.resource_groups.with_raw_response.delete( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + resource_group = client.iam.resource_groups.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(ResourceGroupGetResponse, resource_group, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.iam.resource_groups.with_raw_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = response.parse() + assert_matches_type(ResourceGroupGetResponse, resource_group, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.iam.resource_groups.with_streaming_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = response.parse() + assert_matches_type(ResourceGroupGetResponse, resource_group, 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.iam.resource_groups.with_raw_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_group_id` but received ''"): + client.iam.resource_groups.with_raw_response.get( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + +class TestAsyncResourceGroups: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + resource_group = await async_client.iam.resource_groups.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + assert_matches_type(ResourceGroupCreateResponse, resource_group, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + resource_group = await async_client.iam.resource_groups.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + meta={"editable": "false"}, + ) + assert_matches_type(ResourceGroupCreateResponse, resource_group, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.iam.resource_groups.with_raw_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = await response.parse() + assert_matches_type(ResourceGroupCreateResponse, resource_group, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.iam.resource_groups.with_streaming_response.create( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = await response.parse() + assert_matches_type(ResourceGroupCreateResponse, resource_group, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @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.iam.resource_groups.with_raw_response.create( + account_id="", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + resource_group = await async_client.iam.resource_groups.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + assert_matches_type(ResourceGroupUpdateResponse, resource_group, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + resource_group = await async_client.iam.resource_groups.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + meta={"editable": "false"}, + ) + assert_matches_type(ResourceGroupUpdateResponse, resource_group, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.iam.resource_groups.with_raw_response.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = await response.parse() + assert_matches_type(ResourceGroupUpdateResponse, resource_group, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.iam.resource_groups.with_streaming_response.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = await response.parse() + assert_matches_type(ResourceGroupUpdateResponse, resource_group, 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.iam.resource_groups.with_raw_response.update( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_group_id` but received ''"): + await async_client.iam.resource_groups.with_raw_response.update( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + scope={ + "key": "com.cloudflare.api.account.eb78d65290b24279ba6f44721b3ea3c4", + "objects": [ + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + {"key": "com.cloudflare.api.account.zone.23f8d65290b24279ba6f44721b3eaad5"}, + ], + }, + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + resource_group = await async_client.iam.resource_groups.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(AsyncV4PagePaginationArray[object], resource_group, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + resource_group = await async_client.iam.resource_groups.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + id="6d7f2f5f5b1d4a0e9081fdc98d432fd1", + name="NameOfTheResourceGroup", + page=1, + per_page=5, + ) + assert_matches_type(AsyncV4PagePaginationArray[object], resource_group, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.iam.resource_groups.with_raw_response.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[object], resource_group, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.iam.resource_groups.with_streaming_response.list( + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[object], resource_group, 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.iam.resource_groups.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + resource_group = await async_client.iam.resource_groups.delete( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(Optional[ResourceGroupDeleteResponse], resource_group, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.iam.resource_groups.with_raw_response.delete( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = await response.parse() + assert_matches_type(Optional[ResourceGroupDeleteResponse], resource_group, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.iam.resource_groups.with_streaming_response.delete( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = await response.parse() + assert_matches_type(Optional[ResourceGroupDeleteResponse], resource_group, 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.iam.resource_groups.with_raw_response.delete( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_group_id` but received ''"): + await async_client.iam.resource_groups.with_raw_response.delete( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + resource_group = await async_client.iam.resource_groups.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + assert_matches_type(ResourceGroupGetResponse, resource_group, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.iam.resource_groups.with_raw_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_group = await response.parse() + assert_matches_type(ResourceGroupGetResponse, resource_group, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.iam.resource_groups.with_streaming_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_group = await response.parse() + assert_matches_type(ResourceGroupGetResponse, resource_group, 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.iam.resource_groups.with_raw_response.get( + "6d7f2f5f5b1d4a0e9081fdc98d432fd1", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `resource_group_id` but received ''"): + await async_client.iam.resource_groups.with_raw_response.get( + "", + account_id="eb78d65290b24279ba6f44721b3ea3c4", + ) diff --git a/tests/api_resources/page_shield/test_cookies.py b/tests/api_resources/page_shield/test_cookies.py new file mode 100644 index 00000000000..7c516ab4e7d --- /dev/null +++ b/tests/api_resources/page_shield/test_cookies.py @@ -0,0 +1,237 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.page_shield import CookieGetResponse, CookieListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestCookies: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + cookie = client.page_shield.cookies.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncSinglePage[CookieListResponse], cookie, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + cookie = client.page_shield.cookies.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="asc", + domain="example.com", + export="csv", + hosts="blog.cloudflare.com,www.example*,*cloudflare.com", + http_only=True, + name="session_id", + order_by="first_seen_at", + page="2", + page_url="example.com/page,*/checkout,example.com/*,*checkout*", + path="/", + per_page=100, + same_site="strict", + secure=True, + type="first_party", + ) + assert_matches_type(SyncSinglePage[CookieListResponse], cookie, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.page_shield.cookies.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cookie = response.parse() + assert_matches_type(SyncSinglePage[CookieListResponse], cookie, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.page_shield.cookies.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cookie = response.parse() + assert_matches_type(SyncSinglePage[CookieListResponse], cookie, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.page_shield.cookies.with_raw_response.list( + zone_id="", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + cookie = client.page_shield.cookies.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[CookieGetResponse], cookie, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.page_shield.cookies.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cookie = response.parse() + assert_matches_type(Optional[CookieGetResponse], cookie, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.page_shield.cookies.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cookie = response.parse() + assert_matches_type(Optional[CookieGetResponse], cookie, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.page_shield.cookies.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `cookie_id` but received ''"): + client.page_shield.cookies.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncCookies: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + cookie = await async_client.page_shield.cookies.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncSinglePage[CookieListResponse], cookie, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + cookie = await async_client.page_shield.cookies.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + direction="asc", + domain="example.com", + export="csv", + hosts="blog.cloudflare.com,www.example*,*cloudflare.com", + http_only=True, + name="session_id", + order_by="first_seen_at", + page="2", + page_url="example.com/page,*/checkout,example.com/*,*checkout*", + path="/", + per_page=100, + same_site="strict", + secure=True, + type="first_party", + ) + assert_matches_type(AsyncSinglePage[CookieListResponse], cookie, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.page_shield.cookies.with_raw_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cookie = await response.parse() + assert_matches_type(AsyncSinglePage[CookieListResponse], cookie, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.page_shield.cookies.with_streaming_response.list( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cookie = await response.parse() + assert_matches_type(AsyncSinglePage[CookieListResponse], cookie, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.page_shield.cookies.with_raw_response.list( + zone_id="", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + cookie = await async_client.page_shield.cookies.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[CookieGetResponse], cookie, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.page_shield.cookies.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cookie = await response.parse() + assert_matches_type(Optional[CookieGetResponse], cookie, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.page_shield.cookies.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cookie = await response.parse() + assert_matches_type(Optional[CookieGetResponse], cookie, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.page_shield.cookies.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + zone_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `cookie_id` but received ''"): + await async_client.page_shield.cookies.with_raw_response.get( + "", + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) From 04b79faf413cf05f4e73d99250d19648b3238a45 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 04:16:35 +0000 Subject: [PATCH 515/532] feat(api): update via SDK Studio (#996) --- api.md | 2 +- src/cloudflare/_client.py | 16 ++++---- src/cloudflare/resources/__init__.py | 24 ++++++------ src/cloudflare/resources/accounts/members.py | 16 ++++---- src/cloudflare/resources/iam/__init__.py | 24 ++++++------ src/cloudflare/resources/iam/iam.py | 38 +++++++++---------- .../types/accounts/member_create_params.py | 28 +++++++------- .../types/accounts/member_update_params.py | 24 ++++++------ 8 files changed, 86 insertions(+), 86 deletions(-) diff --git a/api.md b/api.md index d3993e81805..8f78a3181fd 100644 --- a/api.md +++ b/api.md @@ -7897,7 +7897,7 @@ Methods: - client.ai_gateway.logs.get(id, \*, account_id, \*\*params) -> LogGetResponse -# Iam +# IAM ## PermissionGroups diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index 1c536763963..cf1a1aadb2b 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -130,7 +130,7 @@ class Cloudflare(SyncAPIClient): cloudforce_one: resources.CloudforceOneResource event_notifications: resources.EventNotificationsResource ai_gateway: resources.AIGatewayResource - iam: resources.IamResource + iam: resources.IAMResource with_raw_response: CloudflareWithRawResponse with_streaming_response: CloudflareWithStreamedResponse @@ -289,7 +289,7 @@ def __init__( self.cloudforce_one = resources.CloudforceOneResource(self) self.event_notifications = resources.EventNotificationsResource(self) self.ai_gateway = resources.AIGatewayResource(self) - self.iam = resources.IamResource(self) + self.iam = resources.IAMResource(self) self.with_raw_response = CloudflareWithRawResponse(self) self.with_streaming_response = CloudflareWithStreamedResponse(self) @@ -551,7 +551,7 @@ class AsyncCloudflare(AsyncAPIClient): cloudforce_one: resources.AsyncCloudforceOneResource event_notifications: resources.AsyncEventNotificationsResource ai_gateway: resources.AsyncAIGatewayResource - iam: resources.AsyncIamResource + iam: resources.AsyncIAMResource with_raw_response: AsyncCloudflareWithRawResponse with_streaming_response: AsyncCloudflareWithStreamedResponse @@ -710,7 +710,7 @@ def __init__( self.cloudforce_one = resources.AsyncCloudforceOneResource(self) self.event_notifications = resources.AsyncEventNotificationsResource(self) self.ai_gateway = resources.AsyncAIGatewayResource(self) - self.iam = resources.AsyncIamResource(self) + self.iam = resources.AsyncIAMResource(self) self.with_raw_response = AsyncCloudflareWithRawResponse(self) self.with_streaming_response = AsyncCloudflareWithStreamedResponse(self) @@ -983,7 +983,7 @@ def __init__(self, client: Cloudflare) -> None: self.cloudforce_one = resources.CloudforceOneResourceWithRawResponse(client.cloudforce_one) self.event_notifications = resources.EventNotificationsResourceWithRawResponse(client.event_notifications) self.ai_gateway = resources.AIGatewayResourceWithRawResponse(client.ai_gateway) - self.iam = resources.IamResourceWithRawResponse(client.iam) + self.iam = resources.IAMResourceWithRawResponse(client.iam) class AsyncCloudflareWithRawResponse: @@ -1085,7 +1085,7 @@ def __init__(self, client: AsyncCloudflare) -> None: self.cloudforce_one = resources.AsyncCloudforceOneResourceWithRawResponse(client.cloudforce_one) self.event_notifications = resources.AsyncEventNotificationsResourceWithRawResponse(client.event_notifications) self.ai_gateway = resources.AsyncAIGatewayResourceWithRawResponse(client.ai_gateway) - self.iam = resources.AsyncIamResourceWithRawResponse(client.iam) + self.iam = resources.AsyncIAMResourceWithRawResponse(client.iam) class CloudflareWithStreamedResponse: @@ -1187,7 +1187,7 @@ def __init__(self, client: Cloudflare) -> None: self.cloudforce_one = resources.CloudforceOneResourceWithStreamingResponse(client.cloudforce_one) self.event_notifications = resources.EventNotificationsResourceWithStreamingResponse(client.event_notifications) self.ai_gateway = resources.AIGatewayResourceWithStreamingResponse(client.ai_gateway) - self.iam = resources.IamResourceWithStreamingResponse(client.iam) + self.iam = resources.IAMResourceWithStreamingResponse(client.iam) class AsyncCloudflareWithStreamedResponse: @@ -1297,7 +1297,7 @@ def __init__(self, client: AsyncCloudflare) -> None: client.event_notifications ) self.ai_gateway = resources.AsyncAIGatewayResourceWithStreamingResponse(client.ai_gateway) - self.iam = resources.AsyncIamResourceWithStreamingResponse(client.iam) + self.iam = resources.AsyncIAMResourceWithStreamingResponse(client.iam) Client = Cloudflare diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py index e5fa7b69add..05545390c25 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -41,12 +41,12 @@ AsyncDNSResourceWithStreamingResponse, ) from .iam import ( - IamResource, - AsyncIamResource, - IamResourceWithRawResponse, - AsyncIamResourceWithRawResponse, - IamResourceWithStreamingResponse, - AsyncIamResourceWithStreamingResponse, + IAMResource, + AsyncIAMResource, + IAMResourceWithRawResponse, + AsyncIAMResourceWithRawResponse, + IAMResourceWithStreamingResponse, + AsyncIAMResourceWithStreamingResponse, ) from .ips import ( IPsResource, @@ -1172,10 +1172,10 @@ "AsyncAIGatewayResourceWithRawResponse", "AIGatewayResourceWithStreamingResponse", "AsyncAIGatewayResourceWithStreamingResponse", - "IamResource", - "AsyncIamResource", - "IamResourceWithRawResponse", - "AsyncIamResourceWithRawResponse", - "IamResourceWithStreamingResponse", - "AsyncIamResourceWithStreamingResponse", + "IAMResource", + "AsyncIAMResource", + "IAMResourceWithRawResponse", + "AsyncIAMResourceWithRawResponse", + "IAMResourceWithStreamingResponse", + "AsyncIAMResourceWithStreamingResponse", ] diff --git a/src/cloudflare/resources/accounts/members.py b/src/cloudflare/resources/accounts/members.py index 36ae1a8926f..ab13b631e8f 100644 --- a/src/cloudflare/resources/accounts/members.py +++ b/src/cloudflare/resources/accounts/members.py @@ -87,7 +87,7 @@ def create( *, account_id: str, email: str, - policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], + policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy], status: Literal["accepted", "pending"] | 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. @@ -124,7 +124,7 @@ def create( email: str, roles: List[str] | NotGiven = NOT_GIVEN, status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, - policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, + policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy] | 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, @@ -195,7 +195,7 @@ def update( member_id: str, *, account_id: str, - policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], + policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy], # 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, @@ -230,7 +230,7 @@ def update( *, account_id: str, roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, - policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, + policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy] | 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, @@ -464,7 +464,7 @@ async def create( *, account_id: str, email: str, - policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy], + policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy], status: Literal["accepted", "pending"] | 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. @@ -501,7 +501,7 @@ async def create( email: str, roles: List[str] | NotGiven = NOT_GIVEN, status: Literal["accepted", "pending"] | NotGiven = NOT_GIVEN, - policies: Iterable[member_create_params.IamCreateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, + policies: Iterable[member_create_params.IAMCreateMemberWithPoliciesPolicy] | 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, @@ -572,7 +572,7 @@ async def update( member_id: str, *, account_id: str, - policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy], + policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy], # 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, @@ -607,7 +607,7 @@ async def update( *, account_id: str, roles: Iterable[member_update_params.MemberRole] | NotGiven = NOT_GIVEN, - policies: Iterable[member_update_params.IamUpdateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, + policies: Iterable[member_update_params.IAMUpdateMemberWithPoliciesPolicy] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/cloudflare/resources/iam/__init__.py b/src/cloudflare/resources/iam/__init__.py index 0384bf2c0e0..a233360f769 100644 --- a/src/cloudflare/resources/iam/__init__.py +++ b/src/cloudflare/resources/iam/__init__.py @@ -1,12 +1,12 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from .iam import ( - IamResource, - AsyncIamResource, - IamResourceWithRawResponse, - AsyncIamResourceWithRawResponse, - IamResourceWithStreamingResponse, - AsyncIamResourceWithStreamingResponse, + IAMResource, + AsyncIAMResource, + IAMResourceWithRawResponse, + AsyncIAMResourceWithRawResponse, + IAMResourceWithStreamingResponse, + AsyncIAMResourceWithStreamingResponse, ) from .resource_groups import ( ResourceGroupsResource, @@ -38,10 +38,10 @@ "AsyncResourceGroupsResourceWithRawResponse", "ResourceGroupsResourceWithStreamingResponse", "AsyncResourceGroupsResourceWithStreamingResponse", - "IamResource", - "AsyncIamResource", - "IamResourceWithRawResponse", - "AsyncIamResourceWithRawResponse", - "IamResourceWithStreamingResponse", - "AsyncIamResourceWithStreamingResponse", + "IAMResource", + "AsyncIAMResource", + "IAMResourceWithRawResponse", + "AsyncIAMResourceWithRawResponse", + "IAMResourceWithStreamingResponse", + "AsyncIAMResourceWithStreamingResponse", ] diff --git a/src/cloudflare/resources/iam/iam.py b/src/cloudflare/resources/iam/iam.py index ec7756d7f63..c8dd72b1cdb 100644 --- a/src/cloudflare/resources/iam/iam.py +++ b/src/cloudflare/resources/iam/iam.py @@ -21,10 +21,10 @@ AsyncPermissionGroupsResourceWithStreamingResponse, ) -__all__ = ["IamResource", "AsyncIamResource"] +__all__ = ["IAMResource", "AsyncIAMResource"] -class IamResource(SyncAPIResource): +class IAMResource(SyncAPIResource): @cached_property def permission_groups(self) -> PermissionGroupsResource: return PermissionGroupsResource(self._client) @@ -34,15 +34,15 @@ def resource_groups(self) -> ResourceGroupsResource: return ResourceGroupsResource(self._client) @cached_property - def with_raw_response(self) -> IamResourceWithRawResponse: - return IamResourceWithRawResponse(self) + def with_raw_response(self) -> IAMResourceWithRawResponse: + return IAMResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> IamResourceWithStreamingResponse: - return IamResourceWithStreamingResponse(self) + def with_streaming_response(self) -> IAMResourceWithStreamingResponse: + return IAMResourceWithStreamingResponse(self) -class AsyncIamResource(AsyncAPIResource): +class AsyncIAMResource(AsyncAPIResource): @cached_property def permission_groups(self) -> AsyncPermissionGroupsResource: return AsyncPermissionGroupsResource(self._client) @@ -52,16 +52,16 @@ def resource_groups(self) -> AsyncResourceGroupsResource: return AsyncResourceGroupsResource(self._client) @cached_property - def with_raw_response(self) -> AsyncIamResourceWithRawResponse: - return AsyncIamResourceWithRawResponse(self) + def with_raw_response(self) -> AsyncIAMResourceWithRawResponse: + return AsyncIAMResourceWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncIamResourceWithStreamingResponse: - return AsyncIamResourceWithStreamingResponse(self) + def with_streaming_response(self) -> AsyncIAMResourceWithStreamingResponse: + return AsyncIAMResourceWithStreamingResponse(self) -class IamResourceWithRawResponse: - def __init__(self, iam: IamResource) -> None: +class IAMResourceWithRawResponse: + def __init__(self, iam: IAMResource) -> None: self._iam = iam @cached_property @@ -73,8 +73,8 @@ def resource_groups(self) -> ResourceGroupsResourceWithRawResponse: return ResourceGroupsResourceWithRawResponse(self._iam.resource_groups) -class AsyncIamResourceWithRawResponse: - def __init__(self, iam: AsyncIamResource) -> None: +class AsyncIAMResourceWithRawResponse: + def __init__(self, iam: AsyncIAMResource) -> None: self._iam = iam @cached_property @@ -86,8 +86,8 @@ def resource_groups(self) -> AsyncResourceGroupsResourceWithRawResponse: return AsyncResourceGroupsResourceWithRawResponse(self._iam.resource_groups) -class IamResourceWithStreamingResponse: - def __init__(self, iam: IamResource) -> None: +class IAMResourceWithStreamingResponse: + def __init__(self, iam: IAMResource) -> None: self._iam = iam @cached_property @@ -99,8 +99,8 @@ def resource_groups(self) -> ResourceGroupsResourceWithStreamingResponse: return ResourceGroupsResourceWithStreamingResponse(self._iam.resource_groups) -class AsyncIamResourceWithStreamingResponse: - def __init__(self, iam: AsyncIamResource) -> None: +class AsyncIAMResourceWithStreamingResponse: + def __init__(self, iam: AsyncIAMResource) -> None: self._iam = iam @cached_property diff --git a/src/cloudflare/types/accounts/member_create_params.py b/src/cloudflare/types/accounts/member_create_params.py index 1531d624747..793e4eb5199 100644 --- a/src/cloudflare/types/accounts/member_create_params.py +++ b/src/cloudflare/types/accounts/member_create_params.py @@ -7,15 +7,15 @@ __all__ = [ "MemberCreateParams", - "IamCreateMemberWithRoles", - "IamCreateMemberWithPolicies", - "IamCreateMemberWithPoliciesPolicy", - "IamCreateMemberWithPoliciesPolicyPermissionGroup", - "IamCreateMemberWithPoliciesPolicyResourceGroup", + "IAMCreateMemberWithRoles", + "IAMCreateMemberWithPolicies", + "IAMCreateMemberWithPoliciesPolicy", + "IAMCreateMemberWithPoliciesPolicyPermissionGroup", + "IAMCreateMemberWithPoliciesPolicyResourceGroup", ] -class IamCreateMemberWithRoles(TypedDict, total=False): +class IAMCreateMemberWithRoles(TypedDict, total=False): account_id: Required[str] """Account identifier tag.""" @@ -28,38 +28,38 @@ class IamCreateMemberWithRoles(TypedDict, total=False): status: Literal["accepted", "pending"] -class IamCreateMemberWithPolicies(TypedDict, total=False): +class IAMCreateMemberWithPolicies(TypedDict, total=False): account_id: Required[str] """Account identifier tag.""" email: Required[str] """The contact email address of the user.""" - policies: Required[Iterable[IamCreateMemberWithPoliciesPolicy]] + policies: Required[Iterable[IAMCreateMemberWithPoliciesPolicy]] """Array of policies associated with this member.""" status: Literal["accepted", "pending"] -class IamCreateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): +class IAMCreateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): id: Required[str] """Identifier of the group.""" -class IamCreateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): +class IAMCreateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): id: Required[str] """Identifier of the group.""" -class IamCreateMemberWithPoliciesPolicy(TypedDict, total=False): +class IAMCreateMemberWithPoliciesPolicy(TypedDict, total=False): access: Required[Literal["allow", "deny"]] """Allow or deny operations against the resources.""" - permission_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyPermissionGroup]] + permission_groups: Required[Iterable[IAMCreateMemberWithPoliciesPolicyPermissionGroup]] """A set of permission groups that are specified to the policy.""" - resource_groups: Required[Iterable[IamCreateMemberWithPoliciesPolicyResourceGroup]] + resource_groups: Required[Iterable[IAMCreateMemberWithPoliciesPolicyResourceGroup]] """A list of resource groups that the policy applies to.""" -MemberCreateParams = Union[IamCreateMemberWithRoles, IamCreateMemberWithPolicies] +MemberCreateParams = Union[IAMCreateMemberWithRoles, IAMCreateMemberWithPolicies] diff --git a/src/cloudflare/types/accounts/member_update_params.py b/src/cloudflare/types/accounts/member_update_params.py index 559895f2ca0..e95d51f43fa 100644 --- a/src/cloudflare/types/accounts/member_update_params.py +++ b/src/cloudflare/types/accounts/member_update_params.py @@ -9,10 +9,10 @@ "MemberUpdateParams", "Member", "MemberRole", - "IamUpdateMemberWithPolicies", - "IamUpdateMemberWithPoliciesPolicy", - "IamUpdateMemberWithPoliciesPolicyPermissionGroup", - "IamUpdateMemberWithPoliciesPolicyResourceGroup", + "IAMUpdateMemberWithPolicies", + "IAMUpdateMemberWithPoliciesPolicy", + "IAMUpdateMemberWithPoliciesPolicyPermissionGroup", + "IAMUpdateMemberWithPoliciesPolicyResourceGroup", ] @@ -29,33 +29,33 @@ class MemberRole(TypedDict, total=False): """Role identifier tag.""" -class IamUpdateMemberWithPolicies(TypedDict, total=False): +class IAMUpdateMemberWithPolicies(TypedDict, total=False): account_id: Required[str] """Account identifier tag.""" - policies: Required[Iterable[IamUpdateMemberWithPoliciesPolicy]] + policies: Required[Iterable[IAMUpdateMemberWithPoliciesPolicy]] """Array of policies associated with this member.""" -class IamUpdateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): +class IAMUpdateMemberWithPoliciesPolicyPermissionGroup(TypedDict, total=False): id: Required[str] """Identifier of the group.""" -class IamUpdateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): +class IAMUpdateMemberWithPoliciesPolicyResourceGroup(TypedDict, total=False): id: Required[str] """Identifier of the group.""" -class IamUpdateMemberWithPoliciesPolicy(TypedDict, total=False): +class IAMUpdateMemberWithPoliciesPolicy(TypedDict, total=False): access: Required[Literal["allow", "deny"]] """Allow or deny operations against the resources.""" - permission_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyPermissionGroup]] + permission_groups: Required[Iterable[IAMUpdateMemberWithPoliciesPolicyPermissionGroup]] """A set of permission groups that are specified to the policy.""" - resource_groups: Required[Iterable[IamUpdateMemberWithPoliciesPolicyResourceGroup]] + resource_groups: Required[Iterable[IAMUpdateMemberWithPoliciesPolicyResourceGroup]] """A list of resource groups that the policy applies to.""" -MemberUpdateParams = Union[Member, IamUpdateMemberWithPolicies] +MemberUpdateParams = Union[Member, IAMUpdateMemberWithPolicies] From f583ec8acf38b39270a15d4eaa6ab5c24646e4ee Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 05:29:13 +0000 Subject: [PATCH 516/532] feat(api): update via SDK Studio (#997) --- .stats.yml | 2 +- api.md | 20 - .../resources/magic_transit/sites/__init__.py | 14 - .../magic_transit/sites/app_configuration.py | 1049 ------------ .../resources/magic_transit/sites/sites.py | 32 - .../types/magic_transit/sites/__init__.py | 6 - .../sites/app_configuration_create_params.py | 27 - .../app_configuration_create_response.py | 28 - .../app_configuration_delete_response.py | 28 - .../sites/app_configuration_list_response.py | 28 - .../sites/app_configuration_update_params.py | 96 -- .../app_configuration_update_response.py | 28 - .../sites/test_app_configuration.py | 1464 ----------------- 13 files changed, 1 insertion(+), 2821 deletions(-) delete mode 100644 src/cloudflare/resources/magic_transit/sites/app_configuration.py delete mode 100644 src/cloudflare/types/magic_transit/sites/app_configuration_create_params.py delete mode 100644 src/cloudflare/types/magic_transit/sites/app_configuration_create_response.py delete mode 100644 src/cloudflare/types/magic_transit/sites/app_configuration_delete_response.py delete mode 100644 src/cloudflare/types/magic_transit/sites/app_configuration_list_response.py delete mode 100644 src/cloudflare/types/magic_transit/sites/app_configuration_update_params.py delete mode 100644 src/cloudflare/types/magic_transit/sites/app_configuration_update_response.py delete mode 100644 tests/api_resources/magic_transit/sites/test_app_configuration.py diff --git a/.stats.yml b/.stats.yml index 21c949824d8..5ef8c274e40 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1352 +configured_endpoints: 1348 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e3875d4464358c7aee5cbb9a4e0e39f0e400536dfadb684e8f217a2800897d0e.yml diff --git a/api.md b/api.md index 8f78a3181fd..85216eb6939 100644 --- a/api.md +++ b/api.md @@ -4095,26 +4095,6 @@ Methods: - client.magic_transit.sites.edit(site_id, \*, account_id, \*\*params) -> Site - client.magic_transit.sites.get(site_id, \*, account_id) -> Site -### AppConfiguration - -Types: - -```python -from cloudflare.types.magic_transit.sites import ( - AppConfigurationCreateResponse, - AppConfigurationUpdateResponse, - AppConfigurationListResponse, - AppConfigurationDeleteResponse, -) -``` - -Methods: - -- client.magic_transit.sites.app_configuration.create(site_id, \*, account_id, \*\*params) -> Optional -- client.magic_transit.sites.app_configuration.update(app_config_id, \*, account_id, site_id, \*\*params) -> Optional -- client.magic_transit.sites.app_configuration.list(site_id, \*, account_id) -> SyncSinglePage[AppConfigurationListResponse] -- client.magic_transit.sites.app_configuration.delete(app_config_id, \*, account_id, site_id) -> Optional - ### ACLs Types: diff --git a/src/cloudflare/resources/magic_transit/sites/__init__.py b/src/cloudflare/resources/magic_transit/sites/__init__.py index 91db8e47261..8a2a07f48db 100644 --- a/src/cloudflare/resources/magic_transit/sites/__init__.py +++ b/src/cloudflare/resources/magic_transit/sites/__init__.py @@ -32,22 +32,8 @@ SitesResourceWithStreamingResponse, AsyncSitesResourceWithStreamingResponse, ) -from .app_configuration import ( - AppConfigurationResource, - AsyncAppConfigurationResource, - AppConfigurationResourceWithRawResponse, - AsyncAppConfigurationResourceWithRawResponse, - AppConfigurationResourceWithStreamingResponse, - AsyncAppConfigurationResourceWithStreamingResponse, -) __all__ = [ - "AppConfigurationResource", - "AsyncAppConfigurationResource", - "AppConfigurationResourceWithRawResponse", - "AsyncAppConfigurationResourceWithRawResponse", - "AppConfigurationResourceWithStreamingResponse", - "AsyncAppConfigurationResourceWithStreamingResponse", "ACLsResource", "AsyncACLsResource", "ACLsResourceWithRawResponse", diff --git a/src/cloudflare/resources/magic_transit/sites/app_configuration.py b/src/cloudflare/resources/magic_transit/sites/app_configuration.py deleted file mode 100644 index ab626ae44b5..00000000000 --- a/src/cloudflare/resources/magic_transit/sites/app_configuration.py +++ /dev/null @@ -1,1049 +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, overload - -import httpx - -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - required_args, - 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 ...._base_client import ( - AsyncPaginator, - make_request_options, -) -from ....types.magic_transit.sites import app_configuration_create_params, app_configuration_update_params -from ....types.magic_transit.sites.app_configuration_list_response import AppConfigurationListResponse -from ....types.magic_transit.sites.app_configuration_create_response import AppConfigurationCreateResponse -from ....types.magic_transit.sites.app_configuration_delete_response import AppConfigurationDeleteResponse -from ....types.magic_transit.sites.app_configuration_update_response import AppConfigurationUpdateResponse - -__all__ = ["AppConfigurationResource", "AsyncAppConfigurationResource"] - - -class AppConfigurationResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> AppConfigurationResourceWithRawResponse: - return AppConfigurationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AppConfigurationResourceWithStreamingResponse: - return AppConfigurationResourceWithStreamingResponse(self) - - @overload - def create( - self, - site_id: str, - *, - account_id: str, - account_app_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[AppConfigurationCreateResponse]: - """ - Creates a new App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - account_app_id: Magic account app 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 - """ - ... - - @overload - def create( - self, - site_id: str, - *, - account_id: str, - managed_app_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[AppConfigurationCreateResponse]: - """ - Creates a new App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - managed_app_id: Managed app 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 - """ - ... - - @required_args(["account_id", "account_app_id"], ["account_id", "managed_app_id"]) - def create( - self, - site_id: str, - *, - account_id: str, - account_app_id: str | NotGiven = NOT_GIVEN, - managed_app_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AppConfigurationCreateResponse]: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not site_id: - raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") - return self._post( - f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", - body=maybe_transform( - { - "account_app_id": account_app_id, - "managed_app_id": managed_app_id, - }, - app_configuration_create_params.AppConfigurationCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AppConfigurationCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AppConfigurationCreateResponse]], ResultWrapper[AppConfigurationCreateResponse]), - ) - - @overload - def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - body: object, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @overload - def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - body: object, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @overload - def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - account_app_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[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - account_app_id: Magic account app 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 - """ - ... - - @overload - def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - managed_app_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[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - managed_app_id: Managed app 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 - """ - ... - - @overload - def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - account_app_id: str, - managed_app_id: Optional[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[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - account_app_id: Magic account app ID. - - managed_app_id: **Must be set to null** - - 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 - """ - ... - - @overload - def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - account_app_id: Optional[str], - managed_app_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[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - account_app_id: **Must be set to null** - - managed_app_id: Managed app 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 - """ - ... - - @required_args( - ["account_id", "site_id", "body"], - ["account_id", "site_id", "account_app_id"], - ["account_id", "site_id", "managed_app_id"], - ["account_id", "site_id", "account_app_id", "managed_app_id"], - ) - def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - body: object | NotGiven = NOT_GIVEN, - account_app_id: str | None | NotGiven = NOT_GIVEN, - managed_app_id: str | None | 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[AppConfigurationUpdateResponse]: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not site_id: - raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") - if not app_config_id: - raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") - return self._put( - f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", - body=maybe_transform(body, app_configuration_update_params.AppConfigurationUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AppConfigurationUpdateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AppConfigurationUpdateResponse]], ResultWrapper[AppConfigurationUpdateResponse]), - ) - - def list( - self, - site_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, - ) -> SyncSinglePage[AppConfigurationListResponse]: - """ - Lists App Configs associated with a site. - - Args: - account_id: Identifier - - site_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not site_id: - raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", - page=SyncSinglePage[AppConfigurationListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=AppConfigurationListResponse, - ) - - def delete( - self, - app_config_id: str, - *, - account_id: str, - site_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[AppConfigurationDeleteResponse]: - """ - Deletes specific App Config associated with a site. - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not site_id: - raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") - if not app_config_id: - raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") - return self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AppConfigurationDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AppConfigurationDeleteResponse]], ResultWrapper[AppConfigurationDeleteResponse]), - ) - - -class AsyncAppConfigurationResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncAppConfigurationResourceWithRawResponse: - return AsyncAppConfigurationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncAppConfigurationResourceWithStreamingResponse: - return AsyncAppConfigurationResourceWithStreamingResponse(self) - - @overload - async def create( - self, - site_id: str, - *, - account_id: str, - account_app_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[AppConfigurationCreateResponse]: - """ - Creates a new App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - account_app_id: Magic account app 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 - """ - ... - - @overload - async def create( - self, - site_id: str, - *, - account_id: str, - managed_app_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[AppConfigurationCreateResponse]: - """ - Creates a new App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - managed_app_id: Managed app 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 - """ - ... - - @required_args(["account_id", "account_app_id"], ["account_id", "managed_app_id"]) - async def create( - self, - site_id: str, - *, - account_id: str, - account_app_id: str | NotGiven = NOT_GIVEN, - managed_app_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AppConfigurationCreateResponse]: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not site_id: - raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") - return await self._post( - f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", - body=await async_maybe_transform( - { - "account_app_id": account_app_id, - "managed_app_id": managed_app_id, - }, - app_configuration_create_params.AppConfigurationCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AppConfigurationCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AppConfigurationCreateResponse]], ResultWrapper[AppConfigurationCreateResponse]), - ) - - @overload - async def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - body: object, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @overload - async def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - body: object, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @overload - async def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - account_app_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[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - account_app_id: Magic account app 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 - """ - ... - - @overload - async def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - managed_app_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[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - managed_app_id: Managed app 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 - """ - ... - - @overload - async def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - account_app_id: str, - managed_app_id: Optional[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[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - account_app_id: Magic account app ID. - - managed_app_id: **Must be set to null** - - 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 - """ - ... - - @overload - async def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - account_app_id: Optional[str], - managed_app_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[AppConfigurationUpdateResponse]: - """ - Updates an App Config for a site - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - account_app_id: **Must be set to null** - - managed_app_id: Managed app 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 - """ - ... - - @required_args( - ["account_id", "site_id", "body"], - ["account_id", "site_id", "account_app_id"], - ["account_id", "site_id", "managed_app_id"], - ["account_id", "site_id", "account_app_id", "managed_app_id"], - ) - async def update( - self, - app_config_id: str, - *, - account_id: str, - site_id: str, - body: object | NotGiven = NOT_GIVEN, - account_app_id: str | None | NotGiven = NOT_GIVEN, - managed_app_id: str | None | 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[AppConfigurationUpdateResponse]: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not site_id: - raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") - if not app_config_id: - raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") - return await self._put( - f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", - body=await async_maybe_transform(body, app_configuration_update_params.AppConfigurationUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AppConfigurationUpdateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AppConfigurationUpdateResponse]], ResultWrapper[AppConfigurationUpdateResponse]), - ) - - def list( - self, - site_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, - ) -> AsyncPaginator[AppConfigurationListResponse, AsyncSinglePage[AppConfigurationListResponse]]: - """ - Lists App Configs associated with a site. - - Args: - account_id: Identifier - - site_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not site_id: - raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/magic/sites/{site_id}/app_configs", - page=AsyncSinglePage[AppConfigurationListResponse], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=AppConfigurationListResponse, - ) - - async def delete( - self, - app_config_id: str, - *, - account_id: str, - site_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[AppConfigurationDeleteResponse]: - """ - Deletes specific App Config associated with a site. - - Args: - account_id: Identifier - - site_id: Identifier - - app_config_id: Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not site_id: - raise ValueError(f"Expected a non-empty value for `site_id` but received {site_id!r}") - if not app_config_id: - raise ValueError(f"Expected a non-empty value for `app_config_id` but received {app_config_id!r}") - return await self._delete( - f"/accounts/{account_id}/magic/sites/{site_id}/app_configs/{app_config_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AppConfigurationDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AppConfigurationDeleteResponse]], ResultWrapper[AppConfigurationDeleteResponse]), - ) - - -class AppConfigurationResourceWithRawResponse: - def __init__(self, app_configuration: AppConfigurationResource) -> None: - self._app_configuration = app_configuration - - self.create = to_raw_response_wrapper( - app_configuration.create, - ) - self.update = to_raw_response_wrapper( - app_configuration.update, - ) - self.list = to_raw_response_wrapper( - app_configuration.list, - ) - self.delete = to_raw_response_wrapper( - app_configuration.delete, - ) - - -class AsyncAppConfigurationResourceWithRawResponse: - def __init__(self, app_configuration: AsyncAppConfigurationResource) -> None: - self._app_configuration = app_configuration - - self.create = async_to_raw_response_wrapper( - app_configuration.create, - ) - self.update = async_to_raw_response_wrapper( - app_configuration.update, - ) - self.list = async_to_raw_response_wrapper( - app_configuration.list, - ) - self.delete = async_to_raw_response_wrapper( - app_configuration.delete, - ) - - -class AppConfigurationResourceWithStreamingResponse: - def __init__(self, app_configuration: AppConfigurationResource) -> None: - self._app_configuration = app_configuration - - self.create = to_streamed_response_wrapper( - app_configuration.create, - ) - self.update = to_streamed_response_wrapper( - app_configuration.update, - ) - self.list = to_streamed_response_wrapper( - app_configuration.list, - ) - self.delete = to_streamed_response_wrapper( - app_configuration.delete, - ) - - -class AsyncAppConfigurationResourceWithStreamingResponse: - def __init__(self, app_configuration: AsyncAppConfigurationResource) -> None: - self._app_configuration = app_configuration - - self.create = async_to_streamed_response_wrapper( - app_configuration.create, - ) - self.update = async_to_streamed_response_wrapper( - app_configuration.update, - ) - self.list = async_to_streamed_response_wrapper( - app_configuration.list, - ) - self.delete = async_to_streamed_response_wrapper( - app_configuration.delete, - ) diff --git a/src/cloudflare/resources/magic_transit/sites/sites.py b/src/cloudflare/resources/magic_transit/sites/sites.py index 2c70cc30a7d..67c24a85c6f 100644 --- a/src/cloudflare/resources/magic_transit/sites/sites.py +++ b/src/cloudflare/resources/magic_transit/sites/sites.py @@ -49,14 +49,6 @@ AsyncPaginator, make_request_options, ) -from .app_configuration import ( - AppConfigurationResource, - AsyncAppConfigurationResource, - AppConfigurationResourceWithRawResponse, - AsyncAppConfigurationResourceWithRawResponse, - AppConfigurationResourceWithStreamingResponse, - AsyncAppConfigurationResourceWithStreamingResponse, -) from ....types.magic_transit import ( site_edit_params, site_list_params, @@ -70,10 +62,6 @@ class SitesResource(SyncAPIResource): - @cached_property - def app_configuration(self) -> AppConfigurationResource: - return AppConfigurationResource(self._client) - @cached_property def acls(self) -> ACLsResource: return ACLsResource(self._client) @@ -431,10 +419,6 @@ def get( class AsyncSitesResource(AsyncAPIResource): - @cached_property - def app_configuration(self) -> AsyncAppConfigurationResource: - return AsyncAppConfigurationResource(self._client) - @cached_property def acls(self) -> AsyncACLsResource: return AsyncACLsResource(self._client) @@ -814,10 +798,6 @@ def __init__(self, sites: SitesResource) -> None: sites.get, ) - @cached_property - def app_configuration(self) -> AppConfigurationResourceWithRawResponse: - return AppConfigurationResourceWithRawResponse(self._sites.app_configuration) - @cached_property def acls(self) -> ACLsResourceWithRawResponse: return ACLsResourceWithRawResponse(self._sites.acls) @@ -854,10 +834,6 @@ def __init__(self, sites: AsyncSitesResource) -> None: sites.get, ) - @cached_property - def app_configuration(self) -> AsyncAppConfigurationResourceWithRawResponse: - return AsyncAppConfigurationResourceWithRawResponse(self._sites.app_configuration) - @cached_property def acls(self) -> AsyncACLsResourceWithRawResponse: return AsyncACLsResourceWithRawResponse(self._sites.acls) @@ -894,10 +870,6 @@ def __init__(self, sites: SitesResource) -> None: sites.get, ) - @cached_property - def app_configuration(self) -> AppConfigurationResourceWithStreamingResponse: - return AppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) - @cached_property def acls(self) -> ACLsResourceWithStreamingResponse: return ACLsResourceWithStreamingResponse(self._sites.acls) @@ -934,10 +906,6 @@ def __init__(self, sites: AsyncSitesResource) -> None: sites.get, ) - @cached_property - def app_configuration(self) -> AsyncAppConfigurationResourceWithStreamingResponse: - return AsyncAppConfigurationResourceWithStreamingResponse(self._sites.app_configuration) - @cached_property def acls(self) -> AsyncACLsResourceWithStreamingResponse: return AsyncACLsResourceWithStreamingResponse(self._sites.acls) diff --git a/src/cloudflare/types/magic_transit/sites/__init__.py b/src/cloudflare/types/magic_transit/sites/__init__.py index 9ce9579033c..38f592bb4e6 100644 --- a/src/cloudflare/types/magic_transit/sites/__init__.py +++ b/src/cloudflare/types/magic_transit/sites/__init__.py @@ -33,9 +33,3 @@ from .acl_configuration_param import ACLConfigurationParam as ACLConfigurationParam from .lan_static_addressing_param import LANStaticAddressingParam as LANStaticAddressingParam from .wan_static_addressing_param import WANStaticAddressingParam as WANStaticAddressingParam -from .app_configuration_create_params import AppConfigurationCreateParams as AppConfigurationCreateParams -from .app_configuration_list_response import AppConfigurationListResponse as AppConfigurationListResponse -from .app_configuration_update_params import AppConfigurationUpdateParams as AppConfigurationUpdateParams -from .app_configuration_create_response import AppConfigurationCreateResponse as AppConfigurationCreateResponse -from .app_configuration_delete_response import AppConfigurationDeleteResponse as AppConfigurationDeleteResponse -from .app_configuration_update_response import AppConfigurationUpdateResponse as AppConfigurationUpdateResponse diff --git a/src/cloudflare/types/magic_transit/sites/app_configuration_create_params.py b/src/cloudflare/types/magic_transit/sites/app_configuration_create_params.py deleted file mode 100644 index e5293390127..00000000000 --- a/src/cloudflare/types/magic_transit/sites/app_configuration_create_params.py +++ /dev/null @@ -1,27 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from typing_extensions import Required, TypedDict - -__all__ = ["AppConfigurationCreateParams", "AccountApp", "ManagedApp"] - - -class AccountApp(TypedDict, total=False): - account_id: Required[str] - """Identifier""" - - account_app_id: Required[str] - """Magic account app ID.""" - - -class ManagedApp(TypedDict, total=False): - account_id: Required[str] - """Identifier""" - - managed_app_id: Required[str] - """Managed app ID.""" - - -AppConfigurationCreateParams = Union[AccountApp, ManagedApp] diff --git a/src/cloudflare/types/magic_transit/sites/app_configuration_create_response.py b/src/cloudflare/types/magic_transit/sites/app_configuration_create_response.py deleted file mode 100644 index 84e52fc8403..00000000000 --- a/src/cloudflare/types/magic_transit/sites/app_configuration_create_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["AppConfigurationCreateResponse"] - - -class AppConfigurationCreateResponse(BaseModel): - id: str - """Identifier""" - - site_id: str - """Identifier""" - - breakout: Optional[bool] = None - """Whether to breakout traffic to the app's endpoints directly. - - Null preserves default behavior. - """ - - priority: Optional[int] = None - """Priority of traffic. - - 0 is default, anything greater is prioritized. (Currently only 0 and 1 are - supported) - """ diff --git a/src/cloudflare/types/magic_transit/sites/app_configuration_delete_response.py b/src/cloudflare/types/magic_transit/sites/app_configuration_delete_response.py deleted file mode 100644 index bffa4cb833d..00000000000 --- a/src/cloudflare/types/magic_transit/sites/app_configuration_delete_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["AppConfigurationDeleteResponse"] - - -class AppConfigurationDeleteResponse(BaseModel): - id: str - """Identifier""" - - site_id: str - """Identifier""" - - breakout: Optional[bool] = None - """Whether to breakout traffic to the app's endpoints directly. - - Null preserves default behavior. - """ - - priority: Optional[int] = None - """Priority of traffic. - - 0 is default, anything greater is prioritized. (Currently only 0 and 1 are - supported) - """ diff --git a/src/cloudflare/types/magic_transit/sites/app_configuration_list_response.py b/src/cloudflare/types/magic_transit/sites/app_configuration_list_response.py deleted file mode 100644 index 15f8a52f3eb..00000000000 --- a/src/cloudflare/types/magic_transit/sites/app_configuration_list_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["AppConfigurationListResponse"] - - -class AppConfigurationListResponse(BaseModel): - id: str - """Identifier""" - - site_id: str - """Identifier""" - - breakout: Optional[bool] = None - """Whether to breakout traffic to the app's endpoints directly. - - Null preserves default behavior. - """ - - priority: Optional[int] = None - """Priority of traffic. - - 0 is default, anything greater is prioritized. (Currently only 0 and 1 are - supported) - """ diff --git a/src/cloudflare/types/magic_transit/sites/app_configuration_update_params.py b/src/cloudflare/types/magic_transit/sites/app_configuration_update_params.py deleted file mode 100644 index eb81278baa2..00000000000 --- a/src/cloudflare/types/magic_transit/sites/app_configuration_update_params.py +++ /dev/null @@ -1,96 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union, Optional -from typing_extensions import Required, TypedDict - -__all__ = [ - "AppConfigurationUpdateParams", - "ChangeBreakoutBehavior", - "ChangePriority", - "UpdateAccountAppID", - "UpdateManagedAppID", - "AccountAppManagedApp", - "ManagedAppAccountApp", -] - - -class ChangeBreakoutBehavior(TypedDict, total=False): - account_id: Required[str] - """Identifier""" - - site_id: Required[str] - """Identifier""" - - body: Required[object] - - -class ChangePriority(TypedDict, total=False): - account_id: Required[str] - """Identifier""" - - site_id: Required[str] - """Identifier""" - - body: Required[object] - - -class UpdateAccountAppID(TypedDict, total=False): - account_id: Required[str] - """Identifier""" - - site_id: Required[str] - """Identifier""" - - account_app_id: Required[str] - """Magic account app ID.""" - - -class UpdateManagedAppID(TypedDict, total=False): - account_id: Required[str] - """Identifier""" - - site_id: Required[str] - """Identifier""" - - managed_app_id: Required[str] - """Managed app ID.""" - - -class AccountAppManagedApp(TypedDict, total=False): - account_id: Required[str] - """Identifier""" - - site_id: Required[str] - """Identifier""" - - account_app_id: Required[str] - """Magic account app ID.""" - - managed_app_id: Required[Optional[str]] - """**Must be set to null**""" - - -class ManagedAppAccountApp(TypedDict, total=False): - account_id: Required[str] - """Identifier""" - - site_id: Required[str] - """Identifier""" - - account_app_id: Required[Optional[str]] - """**Must be set to null**""" - - managed_app_id: Required[str] - """Managed app ID.""" - - -AppConfigurationUpdateParams = Union[ - ChangeBreakoutBehavior, - ChangePriority, - UpdateAccountAppID, - UpdateManagedAppID, - AccountAppManagedApp, - ManagedAppAccountApp, -] diff --git a/src/cloudflare/types/magic_transit/sites/app_configuration_update_response.py b/src/cloudflare/types/magic_transit/sites/app_configuration_update_response.py deleted file mode 100644 index 4cf34ba7780..00000000000 --- a/src/cloudflare/types/magic_transit/sites/app_configuration_update_response.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["AppConfigurationUpdateResponse"] - - -class AppConfigurationUpdateResponse(BaseModel): - id: str - """Identifier""" - - site_id: str - """Identifier""" - - breakout: Optional[bool] = None - """Whether to breakout traffic to the app's endpoints directly. - - Null preserves default behavior. - """ - - priority: Optional[int] = None - """Priority of traffic. - - 0 is default, anything greater is prioritized. (Currently only 0 and 1 are - supported) - """ diff --git a/tests/api_resources/magic_transit/sites/test_app_configuration.py b/tests/api_resources/magic_transit/sites/test_app_configuration.py deleted file mode 100644 index 742259f302f..00000000000 --- a/tests/api_resources/magic_transit/sites/test_app_configuration.py +++ /dev/null @@ -1,1464 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.magic_transit.sites import ( - AppConfigurationListResponse, - AppConfigurationCreateResponse, - AppConfigurationDeleteResponse, - AppConfigurationUpdateResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestAppConfiguration: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_method_create_overload_1(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_path_params_create_overload_1(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.create( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_method_create_overload_2(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_path_params_create_overload_2(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.create( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_method_update_overload_1(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_path_params_update_overload_1(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_method_update_overload_2(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_path_params_update_overload_2(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_method_update_overload_3(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_path_params_update_overload_3(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_method_update_overload_4(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_path_params_update_overload_4(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_method_update_overload_5(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_raw_response_update_overload_5(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_streaming_response_update_overload_5(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_path_params_update_overload_5(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_method_update_overload_6(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_raw_response_update_overload_6(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_streaming_response_update_overload_6(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - def test_path_params_update_overload_6(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - account_app_id="string", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.list( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(SyncSinglePage[AppConfigurationListResponse], app_configuration, 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.magic_transit.sites.app_configuration.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.list( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - app_configuration = client.magic_transit.sites.app_configuration.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.magic_transit.sites.app_configuration.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.magic_transit.sites.app_configuration.with_streaming_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = response.parse() - assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, 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.magic_transit.sites.app_configuration.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - client.magic_transit.sites.app_configuration.with_raw_response.delete( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncAppConfiguration: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.create( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationCreateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.create( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.create( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_streaming_response_update_overload_3(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_path_params_update_overload_3(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_streaming_response_update_overload_4(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_path_params_update_overload_4(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - managed_app_id="cloudflare", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_method_update_overload_5(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_raw_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_streaming_response_update_overload_5(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_path_params_update_overload_5(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="ac60d3d0435248289d446cedd870bcf4", - managed_app_id="string", - ) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_method_update_overload_6(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_raw_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_streaming_response_update_overload_6(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationUpdateResponse], app_configuration, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip( - reason="prism errors - https://github.com/cloudflare/cloudflare-python/actions/runs/9360388260/job/25765690361?pr=482#step:5:7212" - ) - @parametrize - async def test_path_params_update_overload_6(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - account_app_id="string", - managed_app_id="cloudflare", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - account_app_id="string", - managed_app_id="cloudflare", - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.list( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(AsyncSinglePage[AppConfigurationListResponse], app_configuration, 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.magic_transit.sites.app_configuration.with_raw_response.list( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.list( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - app_configuration = await async_client.magic_transit.sites.app_configuration.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.magic_transit.sites.app_configuration.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.magic_transit.sites.app_configuration.with_streaming_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - app_configuration = await response.parse() - assert_matches_type(Optional[AppConfigurationDeleteResponse], app_configuration, 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.magic_transit.sites.app_configuration.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `site_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.delete( - "023e105f4ecef8ad9ca31a8372d0c353", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `app_config_id` but received ''"): - await async_client.magic_transit.sites.app_configuration.with_raw_response.delete( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - site_id="023e105f4ecef8ad9ca31a8372d0c353", - ) From 7e2cd67996f60b19b131fb6dcadc99ebc7900ef4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 05:42:40 +0000 Subject: [PATCH 517/532] feat(api): update via SDK Studio (#998) --- tests/api_resources/accounts/test_members.py | 36 ++++++++++++++++++++ tests/api_resources/dns/test_settings.py | 20 +++++++++++ 2 files changed, 56 insertions(+) diff --git a/tests/api_resources/accounts/test_members.py b/tests/api_resources/accounts/test_members.py index b739eead76a..0b40f4dd9f3 100644 --- a/tests/api_resources/accounts/test_members.py +++ b/tests/api_resources/accounts/test_members.py @@ -24,6 +24,7 @@ class TestMembers: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_method_create_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.create( @@ -37,6 +38,7 @@ def test_method_create_overload_1(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> None: member = client.accounts.members.create( @@ -51,6 +53,7 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N ) assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.create( @@ -68,6 +71,7 @@ def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: member = response.parse() assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.create( @@ -87,6 +91,7 @@ def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_path_params_create_overload_1(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -100,6 +105,7 @@ def test_path_params_create_overload_1(self, client: Cloudflare) -> None: ], ) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_method_create_overload_2(self, client: Cloudflare) -> None: member = client.accounts.members.create( @@ -146,6 +152,7 @@ def test_method_create_overload_2(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> None: member = client.accounts.members.create( @@ -193,6 +200,7 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N ) assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.create( @@ -243,6 +251,7 @@ def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: member = response.parse() assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.create( @@ -295,6 +304,7 @@ def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_path_params_create_overload_2(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -699,6 +709,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_method_delete(self, client: Cloudflare) -> None: member = client.accounts.members.delete( @@ -707,6 +718,7 @@ def test_method_delete(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MemberDeleteResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.delete( @@ -719,6 +731,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: member = response.parse() assert_matches_type(Optional[MemberDeleteResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.delete( @@ -733,6 +746,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 error from prism") @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 ''"): @@ -747,6 +761,7 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="eb78d65290b24279ba6f44721b3ea3c4", ) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_method_get(self, client: Cloudflare) -> None: member = client.accounts.members.get( @@ -755,6 +770,7 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.accounts.members.with_raw_response.get( @@ -767,6 +783,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: member = response.parse() assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.accounts.members.with_streaming_response.get( @@ -781,6 +798,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 error from prism") @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 ''"): @@ -799,6 +817,7 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncMembers: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( @@ -812,6 +831,7 @@ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( @@ -826,6 +846,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn ) assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.create( @@ -843,6 +864,7 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar member = await response.parse() assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.create( @@ -862,6 +884,7 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -875,6 +898,7 @@ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare ], ) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( @@ -921,6 +945,7 @@ async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> ) assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.create( @@ -968,6 +993,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn ) assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.create( @@ -1018,6 +1044,7 @@ async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflar member = await response.parse() assert_matches_type(Optional[MemberCreateResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.create( @@ -1070,6 +1097,7 @@ async def test_streaming_response_create_overload_2(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -1474,6 +1502,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: account_id="", ) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.delete( @@ -1482,6 +1511,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[MemberDeleteResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.delete( @@ -1494,6 +1524,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: member = await response.parse() assert_matches_type(Optional[MemberDeleteResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.delete( @@ -1508,6 +1539,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 error from prism") @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 ''"): @@ -1522,6 +1554,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="eb78d65290b24279ba6f44721b3ea3c4", ) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: member = await async_client.accounts.members.get( @@ -1530,6 +1563,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.accounts.members.with_raw_response.get( @@ -1542,6 +1576,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: member = await response.parse() assert_matches_type(Optional[MemberGetResponse], member, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 error from prism") @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.accounts.members.with_streaming_response.get( @@ -1556,6 +1591,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 error from prism") @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 ''"): diff --git a/tests/api_resources/dns/test_settings.py b/tests/api_resources/dns/test_settings.py index 955b284427b..c0dd59c2aa2 100644 --- a/tests/api_resources/dns/test_settings.py +++ b/tests/api_resources/dns/test_settings.py @@ -17,6 +17,7 @@ class TestSettings: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize def test_method_edit(self, client: Cloudflare) -> None: setting = client.dns.settings.edit( @@ -24,6 +25,7 @@ def test_method_edit(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: setting = client.dns.settings.edit( @@ -48,6 +50,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: response = client.dns.settings.with_raw_response.edit( @@ -59,6 +62,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: setting = response.parse() assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: with client.dns.settings.with_streaming_response.edit( @@ -72,6 +76,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 from prism") @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 ''"): @@ -84,6 +89,7 @@ def test_path_params_edit(self, client: Cloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize def test_method_get(self, client: Cloudflare) -> None: setting = client.dns.settings.get( @@ -91,6 +97,7 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: setting = client.dns.settings.get( @@ -98,6 +105,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.dns.settings.with_raw_response.get( @@ -109,6 +117,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: setting = response.parse() assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.dns.settings.with_streaming_response.get( @@ -122,6 +131,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 from prism") @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 ''"): @@ -138,6 +148,7 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncSettings: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: setting = await async_client.dns.settings.edit( @@ -145,6 +156,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: setting = await async_client.dns.settings.edit( @@ -169,6 +181,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) ) assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: response = await async_client.dns.settings.with_raw_response.edit( @@ -180,6 +193,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: setting = await response.parse() assert_matches_type(Optional[SettingEditResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: async with async_client.dns.settings.with_streaming_response.edit( @@ -193,6 +207,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 from prism") @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 ''"): @@ -205,6 +220,7 @@ async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: account_id="string", ) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: setting = await async_client.dns.settings.get( @@ -212,6 +228,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: setting = await async_client.dns.settings.get( @@ -219,6 +236,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - ) assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.dns.settings.with_raw_response.get( @@ -230,6 +248,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: setting = await response.parse() assert_matches_type(Optional[SettingGetResponse], setting, path=["response"]) + @pytest.mark.skip(reason="HTTP 422 from prism") @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.dns.settings.with_streaming_response.get( @@ -243,6 +262,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="HTTP 422 from prism") @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 ''"): From e0269bba241cfdc1ff1ffad4f5c5ff01d79f3951 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 05:55:21 +0000 Subject: [PATCH 518/532] feat(api): update via SDK Studio (#999) --- tests/api_resources/kv/namespaces/test_values.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/api_resources/kv/namespaces/test_values.py b/tests/api_resources/kv/namespaces/test_values.py index d090fd1683d..36b3d06967a 100644 --- a/tests/api_resources/kv/namespaces/test_values.py +++ b/tests/api_resources/kv/namespaces/test_values.py @@ -161,6 +161,7 @@ def test_path_params_delete(self, client: Cloudflare) -> None: namespace_id="0f2ac74b498b48028cb68387c421e279", ) + @pytest.mark.skip(reason="HTTP 406 from prism") @parametrize @pytest.mark.respx(base_url=base_url) def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: @@ -177,6 +178,7 @@ def test_method_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: assert cast(Any, value.is_closed) is True assert isinstance(value, BinaryAPIResponse) + @pytest.mark.skip(reason="HTTP 406 from prism") @parametrize @pytest.mark.respx(base_url=base_url) def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: @@ -195,6 +197,7 @@ def test_raw_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> N assert value.json() == {"foo": "bar"} assert isinstance(value, BinaryAPIResponse) + @pytest.mark.skip(reason="HTTP 406 from prism") @parametrize @pytest.mark.respx(base_url=base_url) def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter) -> None: @@ -215,6 +218,7 @@ def test_streaming_response_get(self, client: Cloudflare, respx_mock: MockRouter assert cast(Any, value.is_closed) is True + @pytest.mark.skip(reason="HTTP 406 from prism") @parametrize @pytest.mark.respx(base_url=base_url) def test_path_params_get(self, client: Cloudflare) -> None: @@ -379,6 +383,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: namespace_id="0f2ac74b498b48028cb68387c421e279", ) + @pytest.mark.skip(reason="HTTP 406 from prism") @parametrize @pytest.mark.respx(base_url=base_url) async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: @@ -395,6 +400,7 @@ async def test_method_get(self, async_client: AsyncCloudflare, respx_mock: MockR assert cast(Any, value.is_closed) is True assert isinstance(value, AsyncBinaryAPIResponse) + @pytest.mark.skip(reason="HTTP 406 from prism") @parametrize @pytest.mark.respx(base_url=base_url) async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: @@ -413,6 +419,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare, respx_mock: assert await value.json() == {"foo": "bar"} assert isinstance(value, AsyncBinaryAPIResponse) + @pytest.mark.skip(reason="HTTP 406 from prism") @parametrize @pytest.mark.respx(base_url=base_url) async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx_mock: MockRouter) -> None: @@ -433,6 +440,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare, respx assert cast(Any, value.is_closed) is True + @pytest.mark.skip(reason="HTTP 406 from prism") @parametrize @pytest.mark.respx(base_url=base_url) async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: From c97f907888fa632d353590c34923a37f719645ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:58:07 +0000 Subject: [PATCH 519/532] feat(api): OpenAPI spec update via Stainless API (#1000) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5ef8c274e40..fddc3e9a6a1 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-e3875d4464358c7aee5cbb9a4e0e39f0e400536dfadb684e8f217a2800897d0e.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5e74e6bc5452012a8e268e22531fc275f2e79381aa2f2dd3fd8c0d16e6cd0a28.yml From 2f1ef0fd1cfee7f2949a996e517a447ab14b8ebc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:00:33 +0000 Subject: [PATCH 520/532] feat(api): OpenAPI spec update via Stainless API (#1001) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index fddc3e9a6a1..fd3e0235fc0 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-5e74e6bc5452012a8e268e22531fc275f2e79381aa2f2dd3fd8c0d16e6cd0a28.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d492ae5acff80b29c47150117fb6934a23891c45978e644382ebaa5bbee60222.yml From f51ca7bcd209a1093278f87b03b0faf8f4e7a406 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:04:11 +0000 Subject: [PATCH 521/532] feat(api): OpenAPI spec update via Stainless API (#1002) --- .stats.yml | 2 +- src/cloudflare/types/workers/ai_run_response.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index fd3e0235fc0..b882f703b73 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-d492ae5acff80b29c47150117fb6934a23891c45978e644382ebaa5bbee60222.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-60eaec2f4029582531bbb45c66bb499e91203845eeeb3d507ae7ed5675a6bbe6.yml diff --git a/src/cloudflare/types/workers/ai_run_response.py b/src/cloudflare/types/workers/ai_run_response.py index 5877761e02c..87644ee64f6 100644 --- a/src/cloudflare/types/workers/ai_run_response.py +++ b/src/cloudflare/types/workers/ai_run_response.py @@ -13,7 +13,8 @@ "ImageClassification", "ObjectDetection", "ObjectDetectionBox", - "Response", + "UnionMember7", + "UnionMember7ToolCall", "Translation", "Summarization", "ImageToText", @@ -74,9 +75,17 @@ class ObjectDetection(BaseModel): score: Optional[float] = None -class Response(BaseModel): +class UnionMember7ToolCall(BaseModel): + arguments: Optional[object] = None + + name: Optional[str] = None + + +class UnionMember7(BaseModel): response: Optional[str] = None + tool_calls: Optional[List[UnionMember7ToolCall]] = None + class Translation(BaseModel): translated_text: Optional[str] = None @@ -98,7 +107,7 @@ class ImageToText(BaseModel): SpeechRecognition, List[ImageClassification], List[ObjectDetection], - Response, + UnionMember7, object, Translation, Summarization, From 226559c098f9ac4ab349fe7a8e4f764b5ff909e2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:43:44 +0000 Subject: [PATCH 522/532] feat(api): OpenAPI spec update via Stainless API (#1003) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b882f703b73..7e0454c5f8e 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-60eaec2f4029582531bbb45c66bb499e91203845eeeb3d507ae7ed5675a6bbe6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f9e4a773c1c6b2edae803e95a2ba5058b4d4215af88643f237c9f789356fc598.yml From c3c615636067d1f4849d444dd79e36cecbafbeec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:46:06 +0000 Subject: [PATCH 523/532] feat(api): OpenAPI spec update via Stainless API (#1004) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7e0454c5f8e..b882f703b73 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-f9e4a773c1c6b2edae803e95a2ba5058b4d4215af88643f237c9f789356fc598.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-60eaec2f4029582531bbb45c66bb499e91203845eeeb3d507ae7ed5675a6bbe6.yml From ec8a580bb436b5df5b8d5340c7ade0ad303536e5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:48:26 +0000 Subject: [PATCH 524/532] feat(api): OpenAPI spec update via Stainless API (#1005) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b882f703b73..7e0454c5f8e 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-60eaec2f4029582531bbb45c66bb499e91203845eeeb3d507ae7ed5675a6bbe6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f9e4a773c1c6b2edae803e95a2ba5058b4d4215af88643f237c9f789356fc598.yml From 1b3c1867a1b4fcc03d67a510505fb669c2449ac0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:50:38 +0000 Subject: [PATCH 525/532] feat(api): OpenAPI spec update via Stainless API (#1006) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7e0454c5f8e..5635a06fcdd 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-f9e4a773c1c6b2edae803e95a2ba5058b4d4215af88643f237c9f789356fc598.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-460637cf938836bf2619c57e293f6ae014a6b1bcbe0cd2288cc66450928cf3c5.yml From 1451caa51bba02360dd2c6ce3c0f8b8423c67062 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:54:32 +0000 Subject: [PATCH 526/532] feat(api): OpenAPI spec update via Stainless API (#1007) --- .stats.yml | 2 +- src/cloudflare/_base_client.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5635a06fcdd..b882f703b73 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-460637cf938836bf2619c57e293f6ae014a6b1bcbe0cd2288cc66450928cf3c5.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-60eaec2f4029582531bbb45c66bb499e91203845eeeb3d507ae7ed5675a6bbe6.yml diff --git a/src/cloudflare/_base_client.py b/src/cloudflare/_base_client.py index edd993ce049..ca66d5b4018 100644 --- a/src/cloudflare/_base_client.py +++ b/src/cloudflare/_base_client.py @@ -456,7 +456,7 @@ def _build_request( raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`") headers = self._build_headers(options) - params = _merge_mappings(self._custom_query, options.params) + params = _merge_mappings(self.default_query, options.params) content_type = headers.get("Content-Type") # If the given Content-Type header is multipart/form-data then it @@ -592,6 +592,12 @@ def default_headers(self) -> dict[str, str | Omit]: **self._custom_headers, } + @property + def default_query(self) -> dict[str, object]: + return { + **self._custom_query, + } + def _validate_headers( self, headers: Headers, # noqa: ARG002 From 6b66d162abbf562dc203c4389d30247e154fc29c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 18:17:34 +0000 Subject: [PATCH 527/532] feat(api): OpenAPI spec update via Stainless API (#1008) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b882f703b73..7e0454c5f8e 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-60eaec2f4029582531bbb45c66bb499e91203845eeeb3d507ae7ed5675a6bbe6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f9e4a773c1c6b2edae803e95a2ba5058b4d4215af88643f237c9f789356fc598.yml From cba721dfb452ecc2a7e2891907512cdd3df6d49e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:10:27 +0000 Subject: [PATCH 528/532] feat(api): OpenAPI spec update via Stainless API (#1009) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7e0454c5f8e..b882f703b73 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-f9e4a773c1c6b2edae803e95a2ba5058b4d4215af88643f237c9f789356fc598.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-60eaec2f4029582531bbb45c66bb499e91203845eeeb3d507ae7ed5675a6bbe6.yml From edf3d01b2ccf3e3037423363d63c5ffb76288e42 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 22:21:51 +0000 Subject: [PATCH 529/532] feat(api): OpenAPI spec update via Stainless API (#1010) --- .stats.yml | 2 +- src/cloudflare/types/accounts/account.py | 3 +++ src/cloudflare/types/accounts/account_update_params.py | 3 +++ tests/api_resources/test_accounts.py | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b882f703b73..4a8cb087804 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-60eaec2f4029582531bbb45c66bb499e91203845eeeb3d507ae7ed5675a6bbe6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9d1a5f2de8e753867ab88ca1b88d1d1cdc944a7834fb81506a7ace10ed151624.yml diff --git a/src/cloudflare/types/accounts/account.py b/src/cloudflare/types/accounts/account.py index 8c402e4bac9..1c26f03b23e 100644 --- a/src/cloudflare/types/accounts/account.py +++ b/src/cloudflare/types/accounts/account.py @@ -10,6 +10,9 @@ class Settings(BaseModel): + abuse_contact_email: Optional[str] = None + """Sets an abuse contact email to notify for abuse reports.""" + default_nameservers: Optional[Literal["cloudflare.standard", "custom.account", "custom.tenant"]] = None """ Specifies the default nameservers to be used for new zones added to this diff --git a/src/cloudflare/types/accounts/account_update_params.py b/src/cloudflare/types/accounts/account_update_params.py index 031f13d3375..3b472cb0778 100644 --- a/src/cloudflare/types/accounts/account_update_params.py +++ b/src/cloudflare/types/accounts/account_update_params.py @@ -18,6 +18,9 @@ class AccountUpdateParams(TypedDict, total=False): class Settings(TypedDict, total=False): + abuse_contact_email: str + """Sets an abuse contact email to notify for abuse reports.""" + default_nameservers: Literal["cloudflare.standard", "custom.account", "custom.tenant"] """ Specifies the default nameservers to be used for new zones added to this diff --git a/tests/api_resources/test_accounts.py b/tests/api_resources/test_accounts.py index 501299704c4..53f68ccb9e1 100644 --- a/tests/api_resources/test_accounts.py +++ b/tests/api_resources/test_accounts.py @@ -31,6 +31,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: account_id={}, name="Demo Account", settings={ + "abuse_contact_email": "string", "default_nameservers": "cloudflare.standard", "enforce_twofactor": True, "use_account_custom_ns_by_default": True, @@ -148,6 +149,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare account_id={}, name="Demo Account", settings={ + "abuse_contact_email": "string", "default_nameservers": "cloudflare.standard", "enforce_twofactor": True, "use_account_custom_ns_by_default": True, From 6a74ae12a6920b8572d331367774bba1a11d9966 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 00:29:55 +0000 Subject: [PATCH 530/532] feat(api): update via SDK Studio (#1011) --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 1df17ff1948..ec35df6ad25 100644 --- a/mypy.ini +++ b/mypy.ini @@ -5,7 +5,7 @@ show_error_codes = True # Exclude _files.py because mypy isn't smart enough to apply # the correct type narrowing and as this is an internal module # it's fine to just use Pyright. -exclude = ^(src/cloudflare/_files\.py|_dev/.*\.py|src/cloudflare/resources/zero_trust/identity_providers\.py|src/cloudflare/resources/zero_trust/access/applications/applications\.py|src/cloudflare/resources/workers/ai\.py)$ +exclude = ^(src/cloudflare/_files\.py|_dev/.*\.py|src/cloudflare/resources/zero_trust/identity_providers\.py|src/cloudflare/resources/zero_trust/access/applications/applications\.py|src/cloudflare/resources/workers/ai\.py|src/cloudflare/resources/magic_transit/apps\.py)$ strict_equality = True implicit_reexport = True From 044d8e54543e2a2ae1b7545407c675eb7543e6a0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 00:56:17 +0000 Subject: [PATCH 531/532] feat(api): OpenAPI spec update via Stainless API (#1012) --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4a8cb087804..b45dbe1d84d 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-9d1a5f2de8e753867ab88ca1b88d1d1cdc944a7834fb81506a7ace10ed151624.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-49d54760f87326f9200c777f867e4ea579c92a43f481207ae252db9748c9b07b.yml From 7bd7ef61cce703c6eadff56733a61f06a6576381 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 00:57:50 +0000 Subject: [PATCH 532/532] release: 3.0.0-beta.10 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 307 ++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- src/cloudflare/_version.py | 2 +- 4 files changed, 310 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f9ed78f868f..782f39f19fa 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.0.0-beta.9" + ".": "3.0.0-beta.10" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d0adbeed795..3525bc456e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,312 @@ # Changelog +## 3.0.0-beta.10 (2024-06-18) + +Full Changelog: [v3.0.0-beta.9...v3.0.0-beta.10](https://github.com/cloudflare/cloudflare-python/compare/v3.0.0-beta.9...v3.0.0-beta.10) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#1000](https://github.com/cloudflare/cloudflare-python/issues/1000)) ([c97f907](https://github.com/cloudflare/cloudflare-python/commit/c97f907888fa632d353590c34923a37f719645ff)) +* **api:** OpenAPI spec update via Stainless API ([#1001](https://github.com/cloudflare/cloudflare-python/issues/1001)) ([2f1ef0f](https://github.com/cloudflare/cloudflare-python/commit/2f1ef0fd1cfee7f2949a996e517a447ab14b8ebc)) +* **api:** OpenAPI spec update via Stainless API ([#1002](https://github.com/cloudflare/cloudflare-python/issues/1002)) ([f51ca7b](https://github.com/cloudflare/cloudflare-python/commit/f51ca7bcd209a1093278f87b03b0faf8f4e7a406)) +* **api:** OpenAPI spec update via Stainless API ([#1003](https://github.com/cloudflare/cloudflare-python/issues/1003)) ([226559c](https://github.com/cloudflare/cloudflare-python/commit/226559c098f9ac4ab349fe7a8e4f764b5ff909e2)) +* **api:** OpenAPI spec update via Stainless API ([#1004](https://github.com/cloudflare/cloudflare-python/issues/1004)) ([c3c6156](https://github.com/cloudflare/cloudflare-python/commit/c3c615636067d1f4849d444dd79e36cecbafbeec)) +* **api:** OpenAPI spec update via Stainless API ([#1005](https://github.com/cloudflare/cloudflare-python/issues/1005)) ([ec8a580](https://github.com/cloudflare/cloudflare-python/commit/ec8a580bb436b5df5b8d5340c7ade0ad303536e5)) +* **api:** OpenAPI spec update via Stainless API ([#1006](https://github.com/cloudflare/cloudflare-python/issues/1006)) ([1b3c186](https://github.com/cloudflare/cloudflare-python/commit/1b3c1867a1b4fcc03d67a510505fb669c2449ac0)) +* **api:** OpenAPI spec update via Stainless API ([#1007](https://github.com/cloudflare/cloudflare-python/issues/1007)) ([1451caa](https://github.com/cloudflare/cloudflare-python/commit/1451caa51bba02360dd2c6ce3c0f8b8423c67062)) +* **api:** OpenAPI spec update via Stainless API ([#1008](https://github.com/cloudflare/cloudflare-python/issues/1008)) ([6b66d16](https://github.com/cloudflare/cloudflare-python/commit/6b66d162abbf562dc203c4389d30247e154fc29c)) +* **api:** OpenAPI spec update via Stainless API ([#1009](https://github.com/cloudflare/cloudflare-python/issues/1009)) ([cba721d](https://github.com/cloudflare/cloudflare-python/commit/cba721dfb452ecc2a7e2891907512cdd3df6d49e)) +* **api:** OpenAPI spec update via Stainless API ([#1010](https://github.com/cloudflare/cloudflare-python/issues/1010)) ([edf3d01](https://github.com/cloudflare/cloudflare-python/commit/edf3d01b2ccf3e3037423363d63c5ffb76288e42)) +* **api:** OpenAPI spec update via Stainless API ([#1012](https://github.com/cloudflare/cloudflare-python/issues/1012)) ([044d8e5](https://github.com/cloudflare/cloudflare-python/commit/044d8e54543e2a2ae1b7545407c675eb7543e6a0)) +* **api:** OpenAPI spec update via Stainless API ([#713](https://github.com/cloudflare/cloudflare-python/issues/713)) ([a0eeb87](https://github.com/cloudflare/cloudflare-python/commit/a0eeb874726c9d5178b97635ce2d4ee206d76b5d)) +* **api:** OpenAPI spec update via Stainless API ([#714](https://github.com/cloudflare/cloudflare-python/issues/714)) ([7fb3d7e](https://github.com/cloudflare/cloudflare-python/commit/7fb3d7ef1c03925d19bfd4a4f903d1466a324e30)) +* **api:** OpenAPI spec update via Stainless API ([#715](https://github.com/cloudflare/cloudflare-python/issues/715)) ([03f1c56](https://github.com/cloudflare/cloudflare-python/commit/03f1c568d06be069ca7bb5993e9254229d794815)) +* **api:** OpenAPI spec update via Stainless API ([#716](https://github.com/cloudflare/cloudflare-python/issues/716)) ([ddb10a2](https://github.com/cloudflare/cloudflare-python/commit/ddb10a2361a2adbfe8073607aec7d0190a3f7ecd)) +* **api:** OpenAPI spec update via Stainless API ([#717](https://github.com/cloudflare/cloudflare-python/issues/717)) ([dea253d](https://github.com/cloudflare/cloudflare-python/commit/dea253d90dd9f903dc01466398188eed54af94bf)) +* **api:** OpenAPI spec update via Stainless API ([#718](https://github.com/cloudflare/cloudflare-python/issues/718)) ([49c0c0f](https://github.com/cloudflare/cloudflare-python/commit/49c0c0f46fc15923d11e984994ef908ff80250c4)) +* **api:** OpenAPI spec update via Stainless API ([#719](https://github.com/cloudflare/cloudflare-python/issues/719)) ([457ac82](https://github.com/cloudflare/cloudflare-python/commit/457ac8295b5195508086a73cf8faf740a2a91591)) +* **api:** OpenAPI spec update via Stainless API ([#720](https://github.com/cloudflare/cloudflare-python/issues/720)) ([359cd8e](https://github.com/cloudflare/cloudflare-python/commit/359cd8e8121618f6c43ef4415a122613f2cf1baa)) +* **api:** OpenAPI spec update via Stainless API ([#721](https://github.com/cloudflare/cloudflare-python/issues/721)) ([0a5e98b](https://github.com/cloudflare/cloudflare-python/commit/0a5e98b7f27a7440d44b23ac82a97ec9cbf04d7c)) +* **api:** OpenAPI spec update via Stainless API ([#722](https://github.com/cloudflare/cloudflare-python/issues/722)) ([e5ba886](https://github.com/cloudflare/cloudflare-python/commit/e5ba886179519b93c9324c08487cc41b3cd052c7)) +* **api:** OpenAPI spec update via Stainless API ([#723](https://github.com/cloudflare/cloudflare-python/issues/723)) ([014819d](https://github.com/cloudflare/cloudflare-python/commit/014819d5d90311d89c2d74870b5d9be61896fb65)) +* **api:** OpenAPI spec update via Stainless API ([#724](https://github.com/cloudflare/cloudflare-python/issues/724)) ([6cceaf7](https://github.com/cloudflare/cloudflare-python/commit/6cceaf781a7e5c5df4d69c0ce308399d16ccb081)) +* **api:** OpenAPI spec update via Stainless API ([#725](https://github.com/cloudflare/cloudflare-python/issues/725)) ([4b98eab](https://github.com/cloudflare/cloudflare-python/commit/4b98eabcc7782cffd33bc3e90b102aabd28accfc)) +* **api:** OpenAPI spec update via Stainless API ([#727](https://github.com/cloudflare/cloudflare-python/issues/727)) ([5745d99](https://github.com/cloudflare/cloudflare-python/commit/5745d99e6178305eb9e32825bb1a4658a702e33a)) +* **api:** OpenAPI spec update via Stainless API ([#728](https://github.com/cloudflare/cloudflare-python/issues/728)) ([4ca97ec](https://github.com/cloudflare/cloudflare-python/commit/4ca97ec63dcd1baa99ab53a8a8f96435df2c16c2)) +* **api:** OpenAPI spec update via Stainless API ([#729](https://github.com/cloudflare/cloudflare-python/issues/729)) ([26fd504](https://github.com/cloudflare/cloudflare-python/commit/26fd50450a3c626df938dd12c976d71eac604728)) +* **api:** OpenAPI spec update via Stainless API ([#730](https://github.com/cloudflare/cloudflare-python/issues/730)) ([45acdc0](https://github.com/cloudflare/cloudflare-python/commit/45acdc076313cb27bdac600896333e9234a0c304)) +* **api:** OpenAPI spec update via Stainless API ([#731](https://github.com/cloudflare/cloudflare-python/issues/731)) ([799f40e](https://github.com/cloudflare/cloudflare-python/commit/799f40eb7b149090d87ff3bb522621dbe73c8a47)) +* **api:** OpenAPI spec update via Stainless API ([#732](https://github.com/cloudflare/cloudflare-python/issues/732)) ([1bdd586](https://github.com/cloudflare/cloudflare-python/commit/1bdd586a537837b08069faa92af8da6c2b956c88)) +* **api:** OpenAPI spec update via Stainless API ([#733](https://github.com/cloudflare/cloudflare-python/issues/733)) ([5c45e6e](https://github.com/cloudflare/cloudflare-python/commit/5c45e6e24fb544d21bcc07cb5175364ccae157e4)) +* **api:** OpenAPI spec update via Stainless API ([#734](https://github.com/cloudflare/cloudflare-python/issues/734)) ([5b3d98d](https://github.com/cloudflare/cloudflare-python/commit/5b3d98ddcda6958f888607b6e420d125be3ed32b)) +* **api:** OpenAPI spec update via Stainless API ([#735](https://github.com/cloudflare/cloudflare-python/issues/735)) ([45c5755](https://github.com/cloudflare/cloudflare-python/commit/45c575503a9b51403d2ea44b1e250d26dca9467d)) +* **api:** OpenAPI spec update via Stainless API ([#736](https://github.com/cloudflare/cloudflare-python/issues/736)) ([556227a](https://github.com/cloudflare/cloudflare-python/commit/556227a4dea855bf414fdeab4606cbc2d912ccd3)) +* **api:** OpenAPI spec update via Stainless API ([#737](https://github.com/cloudflare/cloudflare-python/issues/737)) ([5a27fe1](https://github.com/cloudflare/cloudflare-python/commit/5a27fe15de393019289ad28a7744f8fda547c9f9)) +* **api:** OpenAPI spec update via Stainless API ([#738](https://github.com/cloudflare/cloudflare-python/issues/738)) ([3258d85](https://github.com/cloudflare/cloudflare-python/commit/3258d858d78449cebec4d0c3f0480eeac15201ff)) +* **api:** OpenAPI spec update via Stainless API ([#739](https://github.com/cloudflare/cloudflare-python/issues/739)) ([760506b](https://github.com/cloudflare/cloudflare-python/commit/760506b6bd05fedcd12e310e7fe87dd9665e7a26)) +* **api:** OpenAPI spec update via Stainless API ([#740](https://github.com/cloudflare/cloudflare-python/issues/740)) ([947a9e9](https://github.com/cloudflare/cloudflare-python/commit/947a9e996d9cd68bb97a6e56ec6d2f9d0a931411)) +* **api:** OpenAPI spec update via Stainless API ([#741](https://github.com/cloudflare/cloudflare-python/issues/741)) ([07a5624](https://github.com/cloudflare/cloudflare-python/commit/07a5624809bb04e45bb08ec7b7dfcde700677fc9)) +* **api:** OpenAPI spec update via Stainless API ([#742](https://github.com/cloudflare/cloudflare-python/issues/742)) ([a730175](https://github.com/cloudflare/cloudflare-python/commit/a7301751431c4306bfc32212ea130a0d900304fa)) +* **api:** OpenAPI spec update via Stainless API ([#743](https://github.com/cloudflare/cloudflare-python/issues/743)) ([0a87d13](https://github.com/cloudflare/cloudflare-python/commit/0a87d13db8a1679a16019159d679f38ed3efb595)) +* **api:** OpenAPI spec update via Stainless API ([#744](https://github.com/cloudflare/cloudflare-python/issues/744)) ([8353bfe](https://github.com/cloudflare/cloudflare-python/commit/8353bfe5af9e60ce20130aa158d5301be016eba2)) +* **api:** OpenAPI spec update via Stainless API ([#745](https://github.com/cloudflare/cloudflare-python/issues/745)) ([dfa69f4](https://github.com/cloudflare/cloudflare-python/commit/dfa69f4694afe0202dbec8e449c38aa1fa09e382)) +* **api:** OpenAPI spec update via Stainless API ([#746](https://github.com/cloudflare/cloudflare-python/issues/746)) ([1dffe01](https://github.com/cloudflare/cloudflare-python/commit/1dffe018eaeb5c4a0424a6f52e3c6f983ab89cf3)) +* **api:** OpenAPI spec update via Stainless API ([#747](https://github.com/cloudflare/cloudflare-python/issues/747)) ([8b8fd23](https://github.com/cloudflare/cloudflare-python/commit/8b8fd23a03c7c20c1cdd260c195e14301a0e687e)) +* **api:** OpenAPI spec update via Stainless API ([#748](https://github.com/cloudflare/cloudflare-python/issues/748)) ([588623e](https://github.com/cloudflare/cloudflare-python/commit/588623e18406e1b3d6a162416a66f34015c31da9)) +* **api:** OpenAPI spec update via Stainless API ([#749](https://github.com/cloudflare/cloudflare-python/issues/749)) ([c642855](https://github.com/cloudflare/cloudflare-python/commit/c64285555159e5f374c06a31a41c88e4e2023b7c)) +* **api:** OpenAPI spec update via Stainless API ([#750](https://github.com/cloudflare/cloudflare-python/issues/750)) ([cb5aa05](https://github.com/cloudflare/cloudflare-python/commit/cb5aa0599c74bf7d6c0a7018ac95677d4d739c2b)) +* **api:** OpenAPI spec update via Stainless API ([#751](https://github.com/cloudflare/cloudflare-python/issues/751)) ([19b730b](https://github.com/cloudflare/cloudflare-python/commit/19b730bd51d04cf93868797e454563ddb62c3372)) +* **api:** OpenAPI spec update via Stainless API ([#752](https://github.com/cloudflare/cloudflare-python/issues/752)) ([9b0b40d](https://github.com/cloudflare/cloudflare-python/commit/9b0b40de707fb282debb67242c7bcf4db4ff9572)) +* **api:** OpenAPI spec update via Stainless API ([#753](https://github.com/cloudflare/cloudflare-python/issues/753)) ([cdb2935](https://github.com/cloudflare/cloudflare-python/commit/cdb293551d9ef2d06e0f3379d79331d66cea3429)) +* **api:** OpenAPI spec update via Stainless API ([#754](https://github.com/cloudflare/cloudflare-python/issues/754)) ([2e9a76c](https://github.com/cloudflare/cloudflare-python/commit/2e9a76c81512a90954d441c12f8feafd2039d099)) +* **api:** OpenAPI spec update via Stainless API ([#755](https://github.com/cloudflare/cloudflare-python/issues/755)) ([adfc559](https://github.com/cloudflare/cloudflare-python/commit/adfc559082bf2dbde589d71408de48de2eb788a9)) +* **api:** OpenAPI spec update via Stainless API ([#756](https://github.com/cloudflare/cloudflare-python/issues/756)) ([2824161](https://github.com/cloudflare/cloudflare-python/commit/2824161b0c8049803c8d94568aeb13b0902e6356)) +* **api:** OpenAPI spec update via Stainless API ([#757](https://github.com/cloudflare/cloudflare-python/issues/757)) ([04ed5f6](https://github.com/cloudflare/cloudflare-python/commit/04ed5f6617139752d3443b9d367a5134865cc358)) +* **api:** OpenAPI spec update via Stainless API ([#758](https://github.com/cloudflare/cloudflare-python/issues/758)) ([509db71](https://github.com/cloudflare/cloudflare-python/commit/509db710e5b72e08a77e67876e07892cfd3ed6f5)) +* **api:** OpenAPI spec update via Stainless API ([#759](https://github.com/cloudflare/cloudflare-python/issues/759)) ([926996c](https://github.com/cloudflare/cloudflare-python/commit/926996cd10c584ea6f0d8a5a52804159f310a9df)) +* **api:** OpenAPI spec update via Stainless API ([#760](https://github.com/cloudflare/cloudflare-python/issues/760)) ([8600f31](https://github.com/cloudflare/cloudflare-python/commit/8600f31343c576979ea0f5ae21ec92dc463bbb0c)) +* **api:** OpenAPI spec update via Stainless API ([#761](https://github.com/cloudflare/cloudflare-python/issues/761)) ([69ec751](https://github.com/cloudflare/cloudflare-python/commit/69ec7516745c71b2443fc365da060f3214e795ed)) +* **api:** OpenAPI spec update via Stainless API ([#762](https://github.com/cloudflare/cloudflare-python/issues/762)) ([9ba0f1b](https://github.com/cloudflare/cloudflare-python/commit/9ba0f1bb8345b87b71c1403ee6d24760603fd3fd)) +* **api:** OpenAPI spec update via Stainless API ([#763](https://github.com/cloudflare/cloudflare-python/issues/763)) ([9d24609](https://github.com/cloudflare/cloudflare-python/commit/9d24609073cad5ba379c97cb0eae4c75a814d997)) +* **api:** OpenAPI spec update via Stainless API ([#764](https://github.com/cloudflare/cloudflare-python/issues/764)) ([d722b7b](https://github.com/cloudflare/cloudflare-python/commit/d722b7b5b364041dfceec62e54f70cb7a79b1b20)) +* **api:** OpenAPI spec update via Stainless API ([#765](https://github.com/cloudflare/cloudflare-python/issues/765)) ([325e2cc](https://github.com/cloudflare/cloudflare-python/commit/325e2cc40a11554b2011d69a947edcfc55258253)) +* **api:** OpenAPI spec update via Stainless API ([#766](https://github.com/cloudflare/cloudflare-python/issues/766)) ([edb1fc5](https://github.com/cloudflare/cloudflare-python/commit/edb1fc53ce83225353d5ba27c8253b18b0b56aa8)) +* **api:** OpenAPI spec update via Stainless API ([#767](https://github.com/cloudflare/cloudflare-python/issues/767)) ([3238c36](https://github.com/cloudflare/cloudflare-python/commit/3238c36d41f544ebc562c560b5c17a5efb0a8b47)) +* **api:** OpenAPI spec update via Stainless API ([#768](https://github.com/cloudflare/cloudflare-python/issues/768)) ([fbc645e](https://github.com/cloudflare/cloudflare-python/commit/fbc645eb9fce79a16c0c0b3774f235698bf5bac2)) +* **api:** OpenAPI spec update via Stainless API ([#769](https://github.com/cloudflare/cloudflare-python/issues/769)) ([563d2cc](https://github.com/cloudflare/cloudflare-python/commit/563d2ccc1d5d45d7bca7b8944d258461ac742a35)) +* **api:** OpenAPI spec update via Stainless API ([#770](https://github.com/cloudflare/cloudflare-python/issues/770)) ([16f2024](https://github.com/cloudflare/cloudflare-python/commit/16f2024592b07624378ae6f584b7be64edb38762)) +* **api:** OpenAPI spec update via Stainless API ([#771](https://github.com/cloudflare/cloudflare-python/issues/771)) ([1aca606](https://github.com/cloudflare/cloudflare-python/commit/1aca60697f409eabe0813e6ff09a888dbecdc832)) +* **api:** OpenAPI spec update via Stainless API ([#772](https://github.com/cloudflare/cloudflare-python/issues/772)) ([3cfe2ab](https://github.com/cloudflare/cloudflare-python/commit/3cfe2ab9c306db44b0d14461adef8b855310b598)) +* **api:** OpenAPI spec update via Stainless API ([#773](https://github.com/cloudflare/cloudflare-python/issues/773)) ([129cd12](https://github.com/cloudflare/cloudflare-python/commit/129cd128f6c2bc7404bc413feb0f99917be5f140)) +* **api:** OpenAPI spec update via Stainless API ([#774](https://github.com/cloudflare/cloudflare-python/issues/774)) ([be4677a](https://github.com/cloudflare/cloudflare-python/commit/be4677a1dd37a8422eb8b7277e8b41451267c924)) +* **api:** OpenAPI spec update via Stainless API ([#776](https://github.com/cloudflare/cloudflare-python/issues/776)) ([af6dfae](https://github.com/cloudflare/cloudflare-python/commit/af6dfae184d6380d5702d575bbbf17f2b3360a65)) +* **api:** OpenAPI spec update via Stainless API ([#777](https://github.com/cloudflare/cloudflare-python/issues/777)) ([ae96268](https://github.com/cloudflare/cloudflare-python/commit/ae962684f6ce3fe43deac956713ff72c53aeab2b)) +* **api:** OpenAPI spec update via Stainless API ([#779](https://github.com/cloudflare/cloudflare-python/issues/779)) ([bd08f43](https://github.com/cloudflare/cloudflare-python/commit/bd08f43b49292706755e2772c876ae1a8cb39dc1)) +* **api:** OpenAPI spec update via Stainless API ([#780](https://github.com/cloudflare/cloudflare-python/issues/780)) ([2d617ad](https://github.com/cloudflare/cloudflare-python/commit/2d617ad49431032b211bb8c5aeb1ca76463866ef)) +* **api:** OpenAPI spec update via Stainless API ([#781](https://github.com/cloudflare/cloudflare-python/issues/781)) ([f5ecfb2](https://github.com/cloudflare/cloudflare-python/commit/f5ecfb2c0e890526d0166fbc300e670659aaaf26)) +* **api:** OpenAPI spec update via Stainless API ([#785](https://github.com/cloudflare/cloudflare-python/issues/785)) ([7f3baa6](https://github.com/cloudflare/cloudflare-python/commit/7f3baa694305a43de27dd61e9278319e309ab3f8)) +* **api:** OpenAPI spec update via Stainless API ([#786](https://github.com/cloudflare/cloudflare-python/issues/786)) ([ffbb106](https://github.com/cloudflare/cloudflare-python/commit/ffbb10669205683229a8ddb18c64cb8a9599fffe)) +* **api:** OpenAPI spec update via Stainless API ([#787](https://github.com/cloudflare/cloudflare-python/issues/787)) ([ecf6363](https://github.com/cloudflare/cloudflare-python/commit/ecf6363a5307ff255892ada1803074856c78ae44)) +* **api:** OpenAPI spec update via Stainless API ([#788](https://github.com/cloudflare/cloudflare-python/issues/788)) ([ee85bf1](https://github.com/cloudflare/cloudflare-python/commit/ee85bf180b6b32b28ef05de2642c53a837721d3f)) +* **api:** OpenAPI spec update via Stainless API ([#789](https://github.com/cloudflare/cloudflare-python/issues/789)) ([e8ed1f8](https://github.com/cloudflare/cloudflare-python/commit/e8ed1f8f7f7cf78b7f1869b1296e8d570d025771)) +* **api:** OpenAPI spec update via Stainless API ([#790](https://github.com/cloudflare/cloudflare-python/issues/790)) ([9091d7b](https://github.com/cloudflare/cloudflare-python/commit/9091d7b0efaf6ece2e99756a6bc91c2d420b6cc8)) +* **api:** OpenAPI spec update via Stainless API ([#791](https://github.com/cloudflare/cloudflare-python/issues/791)) ([45f7884](https://github.com/cloudflare/cloudflare-python/commit/45f7884a795276b12a0c8ab7516193a6500c7583)) +* **api:** OpenAPI spec update via Stainless API ([#792](https://github.com/cloudflare/cloudflare-python/issues/792)) ([cd93b55](https://github.com/cloudflare/cloudflare-python/commit/cd93b55fbaecee453b2682e8efbf5ed490c6c249)) +* **api:** OpenAPI spec update via Stainless API ([#793](https://github.com/cloudflare/cloudflare-python/issues/793)) ([9475e3c](https://github.com/cloudflare/cloudflare-python/commit/9475e3cbe7dc98fa889b44ae43a52346d949371e)) +* **api:** OpenAPI spec update via Stainless API ([#794](https://github.com/cloudflare/cloudflare-python/issues/794)) ([bb3889a](https://github.com/cloudflare/cloudflare-python/commit/bb3889a105c71b02b97ea63e52ae6f310ea878f7)) +* **api:** OpenAPI spec update via Stainless API ([#795](https://github.com/cloudflare/cloudflare-python/issues/795)) ([d84dbbb](https://github.com/cloudflare/cloudflare-python/commit/d84dbbb74d4fd13ab612fcc76f1c3dd95ddbcc71)) +* **api:** OpenAPI spec update via Stainless API ([#796](https://github.com/cloudflare/cloudflare-python/issues/796)) ([bfa8b22](https://github.com/cloudflare/cloudflare-python/commit/bfa8b2256a21a5b5c40eaa5b7904caedb301fce4)) +* **api:** OpenAPI spec update via Stainless API ([#797](https://github.com/cloudflare/cloudflare-python/issues/797)) ([ec2e1e3](https://github.com/cloudflare/cloudflare-python/commit/ec2e1e3670b003dff8a9f41d94e99055b03e9303)) +* **api:** OpenAPI spec update via Stainless API ([#798](https://github.com/cloudflare/cloudflare-python/issues/798)) ([4567f4d](https://github.com/cloudflare/cloudflare-python/commit/4567f4d99ea72da60b5bcf3390ca1fdffedd43e9)) +* **api:** OpenAPI spec update via Stainless API ([#799](https://github.com/cloudflare/cloudflare-python/issues/799)) ([9066b55](https://github.com/cloudflare/cloudflare-python/commit/9066b5546dd19ea3aa0b6bc073ebd20a196bf3a2)) +* **api:** OpenAPI spec update via Stainless API ([#800](https://github.com/cloudflare/cloudflare-python/issues/800)) ([098ce63](https://github.com/cloudflare/cloudflare-python/commit/098ce63b7560e7287b37b76cf9bee389e0551c95)) +* **api:** OpenAPI spec update via Stainless API ([#801](https://github.com/cloudflare/cloudflare-python/issues/801)) ([784447a](https://github.com/cloudflare/cloudflare-python/commit/784447a897b73f8bd2a416e247aaa5a432d43996)) +* **api:** OpenAPI spec update via Stainless API ([#802](https://github.com/cloudflare/cloudflare-python/issues/802)) ([4e8e439](https://github.com/cloudflare/cloudflare-python/commit/4e8e439098c4c1a76dc1f562c90bccf718d17c06)) +* **api:** OpenAPI spec update via Stainless API ([#803](https://github.com/cloudflare/cloudflare-python/issues/803)) ([0bfacd4](https://github.com/cloudflare/cloudflare-python/commit/0bfacd43972e5206b333ab1eed96a453f0c09a86)) +* **api:** OpenAPI spec update via Stainless API ([#804](https://github.com/cloudflare/cloudflare-python/issues/804)) ([442f36f](https://github.com/cloudflare/cloudflare-python/commit/442f36f79e7159a4c3787d6add16016b02f96941)) +* **api:** OpenAPI spec update via Stainless API ([#805](https://github.com/cloudflare/cloudflare-python/issues/805)) ([58169cc](https://github.com/cloudflare/cloudflare-python/commit/58169cc0744c229644294f6da4ad2782df9e3b6b)) +* **api:** OpenAPI spec update via Stainless API ([#806](https://github.com/cloudflare/cloudflare-python/issues/806)) ([565b4a2](https://github.com/cloudflare/cloudflare-python/commit/565b4a2c1a454cd4d47ccb222cc3d0503c66c571)) +* **api:** OpenAPI spec update via Stainless API ([#807](https://github.com/cloudflare/cloudflare-python/issues/807)) ([c974ba0](https://github.com/cloudflare/cloudflare-python/commit/c974ba0ad6e771ada9a9d5454e7c24101b725dc9)) +* **api:** OpenAPI spec update via Stainless API ([#808](https://github.com/cloudflare/cloudflare-python/issues/808)) ([69b665d](https://github.com/cloudflare/cloudflare-python/commit/69b665d94d7124e1f4e150d8b9d727e2ec3a5f5b)) +* **api:** OpenAPI spec update via Stainless API ([#810](https://github.com/cloudflare/cloudflare-python/issues/810)) ([d2a77f2](https://github.com/cloudflare/cloudflare-python/commit/d2a77f29c75f3bd4bf8287e3f1479588f478f338)) +* **api:** OpenAPI spec update via Stainless API ([#811](https://github.com/cloudflare/cloudflare-python/issues/811)) ([8f5a33d](https://github.com/cloudflare/cloudflare-python/commit/8f5a33d507d165445ad10c23c249076cfc30847a)) +* **api:** OpenAPI spec update via Stainless API ([#812](https://github.com/cloudflare/cloudflare-python/issues/812)) ([835829a](https://github.com/cloudflare/cloudflare-python/commit/835829aa939117e91cfd20839de9ef5029bab0c9)) +* **api:** OpenAPI spec update via Stainless API ([#813](https://github.com/cloudflare/cloudflare-python/issues/813)) ([dd703c4](https://github.com/cloudflare/cloudflare-python/commit/dd703c4841fa9a7094057543681fb4e9f97f5d6a)) +* **api:** OpenAPI spec update via Stainless API ([#814](https://github.com/cloudflare/cloudflare-python/issues/814)) ([2b107f5](https://github.com/cloudflare/cloudflare-python/commit/2b107f5ebc465c519b9df346af86134bf6306011)) +* **api:** OpenAPI spec update via Stainless API ([#815](https://github.com/cloudflare/cloudflare-python/issues/815)) ([063d1f3](https://github.com/cloudflare/cloudflare-python/commit/063d1f3067e2427b978e03f93de0a87b8747044d)) +* **api:** OpenAPI spec update via Stainless API ([#816](https://github.com/cloudflare/cloudflare-python/issues/816)) ([98426f4](https://github.com/cloudflare/cloudflare-python/commit/98426f4c32e3421b4e67273e3d85024bc4cfedb8)) +* **api:** OpenAPI spec update via Stainless API ([#817](https://github.com/cloudflare/cloudflare-python/issues/817)) ([f4f82f4](https://github.com/cloudflare/cloudflare-python/commit/f4f82f499061ae2a924b85f8c6328c7f6e13123b)) +* **api:** OpenAPI spec update via Stainless API ([#818](https://github.com/cloudflare/cloudflare-python/issues/818)) ([b3fc97d](https://github.com/cloudflare/cloudflare-python/commit/b3fc97d2227f3607a02f26499c15fd8c70f0489d)) +* **api:** OpenAPI spec update via Stainless API ([#819](https://github.com/cloudflare/cloudflare-python/issues/819)) ([0592df8](https://github.com/cloudflare/cloudflare-python/commit/0592df806648374da2f0a96c5d5ebc679e93b140)) +* **api:** OpenAPI spec update via Stainless API ([#820](https://github.com/cloudflare/cloudflare-python/issues/820)) ([d3c3d58](https://github.com/cloudflare/cloudflare-python/commit/d3c3d58c9b132f63415583fa0804f606688696ef)) +* **api:** OpenAPI spec update via Stainless API ([#821](https://github.com/cloudflare/cloudflare-python/issues/821)) ([f0c83e0](https://github.com/cloudflare/cloudflare-python/commit/f0c83e009e1938d57c261bda5af2e7ba4c3bdfd4)) +* **api:** OpenAPI spec update via Stainless API ([#822](https://github.com/cloudflare/cloudflare-python/issues/822)) ([f61c978](https://github.com/cloudflare/cloudflare-python/commit/f61c978ec97810f9d8e9e81c1ad593c95fd1d82c)) +* **api:** OpenAPI spec update via Stainless API ([#823](https://github.com/cloudflare/cloudflare-python/issues/823)) ([f3749fd](https://github.com/cloudflare/cloudflare-python/commit/f3749fd6d003e3c8fd5da4a5a0c136e469d4c2e9)) +* **api:** OpenAPI spec update via Stainless API ([#824](https://github.com/cloudflare/cloudflare-python/issues/824)) ([3830cda](https://github.com/cloudflare/cloudflare-python/commit/3830cdae38c5feff3a6e50a81ca766b9b31f9b14)) +* **api:** OpenAPI spec update via Stainless API ([#825](https://github.com/cloudflare/cloudflare-python/issues/825)) ([c3a0ecc](https://github.com/cloudflare/cloudflare-python/commit/c3a0ecc86f1df1d40c4da016b032aee4be65ac86)) +* **api:** OpenAPI spec update via Stainless API ([#826](https://github.com/cloudflare/cloudflare-python/issues/826)) ([f47e088](https://github.com/cloudflare/cloudflare-python/commit/f47e0885d02b32499cdb6e4428b6bf1ba775bf70)) +* **api:** OpenAPI spec update via Stainless API ([#827](https://github.com/cloudflare/cloudflare-python/issues/827)) ([82a67f8](https://github.com/cloudflare/cloudflare-python/commit/82a67f8fe5be49f2db639f4f9d22a5b531272a2d)) +* **api:** OpenAPI spec update via Stainless API ([#828](https://github.com/cloudflare/cloudflare-python/issues/828)) ([53c19b3](https://github.com/cloudflare/cloudflare-python/commit/53c19b3eaa76ce8cf8519f045abf6f7d3210a070)) +* **api:** OpenAPI spec update via Stainless API ([#829](https://github.com/cloudflare/cloudflare-python/issues/829)) ([218645a](https://github.com/cloudflare/cloudflare-python/commit/218645a9acae1c15994b3c2d31bf570bf31fd4f0)) +* **api:** OpenAPI spec update via Stainless API ([#830](https://github.com/cloudflare/cloudflare-python/issues/830)) ([8668e02](https://github.com/cloudflare/cloudflare-python/commit/8668e02b24f1e0363cf61f939264df634eeae1a4)) +* **api:** OpenAPI spec update via Stainless API ([#831](https://github.com/cloudflare/cloudflare-python/issues/831)) ([442584f](https://github.com/cloudflare/cloudflare-python/commit/442584f708be371e7717030f50de9ba147f1f879)) +* **api:** OpenAPI spec update via Stainless API ([#832](https://github.com/cloudflare/cloudflare-python/issues/832)) ([fff2454](https://github.com/cloudflare/cloudflare-python/commit/fff2454d959b7ee206f740e1134c268492d579c0)) +* **api:** OpenAPI spec update via Stainless API ([#833](https://github.com/cloudflare/cloudflare-python/issues/833)) ([7ee6553](https://github.com/cloudflare/cloudflare-python/commit/7ee6553a4ce1f41f7d005e30aa9cf42edb2aa1a8)) +* **api:** OpenAPI spec update via Stainless API ([#836](https://github.com/cloudflare/cloudflare-python/issues/836)) ([2d97be7](https://github.com/cloudflare/cloudflare-python/commit/2d97be7aa527f1bf80dd7ead3de6b717f342aa87)) +* **api:** OpenAPI spec update via Stainless API ([#837](https://github.com/cloudflare/cloudflare-python/issues/837)) ([ed6a712](https://github.com/cloudflare/cloudflare-python/commit/ed6a712c10eefc6bc5e4668359cb0082624e8b4e)) +* **api:** OpenAPI spec update via Stainless API ([#838](https://github.com/cloudflare/cloudflare-python/issues/838)) ([9bc4946](https://github.com/cloudflare/cloudflare-python/commit/9bc4946f7489b752a93654bc2ccdda85c2ae1816)) +* **api:** OpenAPI spec update via Stainless API ([#839](https://github.com/cloudflare/cloudflare-python/issues/839)) ([f520ca5](https://github.com/cloudflare/cloudflare-python/commit/f520ca581ccd653787cb58ff4178f77e3dc22826)) +* **api:** OpenAPI spec update via Stainless API ([#840](https://github.com/cloudflare/cloudflare-python/issues/840)) ([287bb9a](https://github.com/cloudflare/cloudflare-python/commit/287bb9a3b7f082a2a1203bf53d3d5aab5443332e)) +* **api:** OpenAPI spec update via Stainless API ([#841](https://github.com/cloudflare/cloudflare-python/issues/841)) ([7a0162e](https://github.com/cloudflare/cloudflare-python/commit/7a0162e173c26d91afae0514599bb30037d87f12)) +* **api:** OpenAPI spec update via Stainless API ([#842](https://github.com/cloudflare/cloudflare-python/issues/842)) ([943e7bf](https://github.com/cloudflare/cloudflare-python/commit/943e7bf32d74a101e690721cebbeb3e5cefca860)) +* **api:** OpenAPI spec update via Stainless API ([#843](https://github.com/cloudflare/cloudflare-python/issues/843)) ([671030a](https://github.com/cloudflare/cloudflare-python/commit/671030ae276bb000db3796ef04a626d0bd4338df)) +* **api:** OpenAPI spec update via Stainless API ([#844](https://github.com/cloudflare/cloudflare-python/issues/844)) ([79eab2f](https://github.com/cloudflare/cloudflare-python/commit/79eab2f86576f5b55e47620be9fbafb1e1fd0852)) +* **api:** OpenAPI spec update via Stainless API ([#845](https://github.com/cloudflare/cloudflare-python/issues/845)) ([2d7391b](https://github.com/cloudflare/cloudflare-python/commit/2d7391be05780a67a1f84a4cb3e2cf7187b46c82)) +* **api:** OpenAPI spec update via Stainless API ([#846](https://github.com/cloudflare/cloudflare-python/issues/846)) ([4d5d4bd](https://github.com/cloudflare/cloudflare-python/commit/4d5d4bd261eff4a436f6c4b2ac768a0fa38e04d1)) +* **api:** OpenAPI spec update via Stainless API ([#847](https://github.com/cloudflare/cloudflare-python/issues/847)) ([33ca608](https://github.com/cloudflare/cloudflare-python/commit/33ca608d5ddc5da50231321e7289308d162f27ec)) +* **api:** OpenAPI spec update via Stainless API ([#848](https://github.com/cloudflare/cloudflare-python/issues/848)) ([15c8441](https://github.com/cloudflare/cloudflare-python/commit/15c844182258ff2f0d010ee11ef6ebc05ce87f72)) +* **api:** OpenAPI spec update via Stainless API ([#849](https://github.com/cloudflare/cloudflare-python/issues/849)) ([9966bb7](https://github.com/cloudflare/cloudflare-python/commit/9966bb71bc61f4aad7565573f640de02e24943df)) +* **api:** OpenAPI spec update via Stainless API ([#850](https://github.com/cloudflare/cloudflare-python/issues/850)) ([3009046](https://github.com/cloudflare/cloudflare-python/commit/3009046a27c7966cb0ce01186c0d8acb7cfe3659)) +* **api:** OpenAPI spec update via Stainless API ([#851](https://github.com/cloudflare/cloudflare-python/issues/851)) ([ce39f6a](https://github.com/cloudflare/cloudflare-python/commit/ce39f6aed053e6e2c771022c56f5f087cbf59f42)) +* **api:** OpenAPI spec update via Stainless API ([#852](https://github.com/cloudflare/cloudflare-python/issues/852)) ([f48bf63](https://github.com/cloudflare/cloudflare-python/commit/f48bf6350d26ea58a9f0122112644ac031c22677)) +* **api:** OpenAPI spec update via Stainless API ([#853](https://github.com/cloudflare/cloudflare-python/issues/853)) ([1c71964](https://github.com/cloudflare/cloudflare-python/commit/1c71964ca439e7d9df66e241bcb0fba0e747b1d2)) +* **api:** OpenAPI spec update via Stainless API ([#854](https://github.com/cloudflare/cloudflare-python/issues/854)) ([8dca457](https://github.com/cloudflare/cloudflare-python/commit/8dca457d3413810a36aac11360f3a8ad1abc97b5)) +* **api:** OpenAPI spec update via Stainless API ([#855](https://github.com/cloudflare/cloudflare-python/issues/855)) ([6048cc2](https://github.com/cloudflare/cloudflare-python/commit/6048cc2ac18e1d180a66ac405e3fd48cf829539a)) +* **api:** OpenAPI spec update via Stainless API ([#856](https://github.com/cloudflare/cloudflare-python/issues/856)) ([0f546f5](https://github.com/cloudflare/cloudflare-python/commit/0f546f597ae97e5b584c526a967fd26dfe8c5e3b)) +* **api:** OpenAPI spec update via Stainless API ([#857](https://github.com/cloudflare/cloudflare-python/issues/857)) ([96236a2](https://github.com/cloudflare/cloudflare-python/commit/96236a2dc34933de8b2c33cb0d2e6c5c49561d08)) +* **api:** OpenAPI spec update via Stainless API ([#858](https://github.com/cloudflare/cloudflare-python/issues/858)) ([7896891](https://github.com/cloudflare/cloudflare-python/commit/789689195f9ca252ad900eead2afd79bcb49dae3)) +* **api:** OpenAPI spec update via Stainless API ([#859](https://github.com/cloudflare/cloudflare-python/issues/859)) ([131db3e](https://github.com/cloudflare/cloudflare-python/commit/131db3e1b0f52edd381ac67dac65c477b867a503)) +* **api:** OpenAPI spec update via Stainless API ([#860](https://github.com/cloudflare/cloudflare-python/issues/860)) ([baf75e2](https://github.com/cloudflare/cloudflare-python/commit/baf75e216f9f996d1ee4a004465cbdc36fa2d724)) +* **api:** OpenAPI spec update via Stainless API ([#861](https://github.com/cloudflare/cloudflare-python/issues/861)) ([b6421e4](https://github.com/cloudflare/cloudflare-python/commit/b6421e4f37ee9f6a3b3f9ad356c4c0a2ebfac0ef)) +* **api:** OpenAPI spec update via Stainless API ([#864](https://github.com/cloudflare/cloudflare-python/issues/864)) ([9c81cda](https://github.com/cloudflare/cloudflare-python/commit/9c81cdaaa7a8d3d2b3e9c0d237a5f777ebeb804a)) +* **api:** OpenAPI spec update via Stainless API ([#865](https://github.com/cloudflare/cloudflare-python/issues/865)) ([eafefcd](https://github.com/cloudflare/cloudflare-python/commit/eafefcd3485bc7c932fa4a30c8cb9d3bb09f5517)) +* **api:** OpenAPI spec update via Stainless API ([#866](https://github.com/cloudflare/cloudflare-python/issues/866)) ([4f83a03](https://github.com/cloudflare/cloudflare-python/commit/4f83a03df2bc9160476e97c98837a6d3cae01f1b)) +* **api:** OpenAPI spec update via Stainless API ([#867](https://github.com/cloudflare/cloudflare-python/issues/867)) ([09f9f1f](https://github.com/cloudflare/cloudflare-python/commit/09f9f1f6f4572b35eb043f85cd2d2edca8e2dd47)) +* **api:** OpenAPI spec update via Stainless API ([#868](https://github.com/cloudflare/cloudflare-python/issues/868)) ([50facab](https://github.com/cloudflare/cloudflare-python/commit/50facab4f812941e1242e652b6789fb02dea0bf6)) +* **api:** OpenAPI spec update via Stainless API ([#869](https://github.com/cloudflare/cloudflare-python/issues/869)) ([db82249](https://github.com/cloudflare/cloudflare-python/commit/db8224984433842bb3d267be303cb2e4f75731ae)) +* **api:** OpenAPI spec update via Stainless API ([#870](https://github.com/cloudflare/cloudflare-python/issues/870)) ([57e73e5](https://github.com/cloudflare/cloudflare-python/commit/57e73e5f475d547bc6c383759d84eef590570265)) +* **api:** OpenAPI spec update via Stainless API ([#871](https://github.com/cloudflare/cloudflare-python/issues/871)) ([0d5f2a9](https://github.com/cloudflare/cloudflare-python/commit/0d5f2a92b0355c0dbfc5e4998936c63034e26fa1)) +* **api:** OpenAPI spec update via Stainless API ([#872](https://github.com/cloudflare/cloudflare-python/issues/872)) ([7a883a3](https://github.com/cloudflare/cloudflare-python/commit/7a883a3af3ae930a5d54192d3659c984b87b0c45)) +* **api:** OpenAPI spec update via Stainless API ([#873](https://github.com/cloudflare/cloudflare-python/issues/873)) ([fd420da](https://github.com/cloudflare/cloudflare-python/commit/fd420dab47712333a017cb157d5d9b02fec4feba)) +* **api:** OpenAPI spec update via Stainless API ([#874](https://github.com/cloudflare/cloudflare-python/issues/874)) ([d05b083](https://github.com/cloudflare/cloudflare-python/commit/d05b083904538968e1d3f40e88b819ea16f1d259)) +* **api:** OpenAPI spec update via Stainless API ([#875](https://github.com/cloudflare/cloudflare-python/issues/875)) ([4944d40](https://github.com/cloudflare/cloudflare-python/commit/4944d404c55c05d059a7b8dbb4ccf90fe4d7c714)) +* **api:** OpenAPI spec update via Stainless API ([#876](https://github.com/cloudflare/cloudflare-python/issues/876)) ([8f28f6c](https://github.com/cloudflare/cloudflare-python/commit/8f28f6cafbaf9cea72e6f2345d4ec861b08b5700)) +* **api:** OpenAPI spec update via Stainless API ([#877](https://github.com/cloudflare/cloudflare-python/issues/877)) ([b0a46c0](https://github.com/cloudflare/cloudflare-python/commit/b0a46c09fe8c80c22b02434b01193a1536321c9f)) +* **api:** OpenAPI spec update via Stainless API ([#878](https://github.com/cloudflare/cloudflare-python/issues/878)) ([306f8a4](https://github.com/cloudflare/cloudflare-python/commit/306f8a4fa860428042d6e144e9f633325836c490)) +* **api:** OpenAPI spec update via Stainless API ([#879](https://github.com/cloudflare/cloudflare-python/issues/879)) ([017c740](https://github.com/cloudflare/cloudflare-python/commit/017c740e7c372cd79590edb64b5434fb2df8aa61)) +* **api:** OpenAPI spec update via Stainless API ([#880](https://github.com/cloudflare/cloudflare-python/issues/880)) ([fdbc41b](https://github.com/cloudflare/cloudflare-python/commit/fdbc41b6f8ed81836e45def67becb4dc17910fc6)) +* **api:** OpenAPI spec update via Stainless API ([#881](https://github.com/cloudflare/cloudflare-python/issues/881)) ([a54ba22](https://github.com/cloudflare/cloudflare-python/commit/a54ba22cbd417bc28ff96635c9a6e673de2f02b6)) +* **api:** OpenAPI spec update via Stainless API ([#882](https://github.com/cloudflare/cloudflare-python/issues/882)) ([be7f95b](https://github.com/cloudflare/cloudflare-python/commit/be7f95b936c4664abf46db13afc5ca13e94baa26)) +* **api:** OpenAPI spec update via Stainless API ([#883](https://github.com/cloudflare/cloudflare-python/issues/883)) ([2f8cee5](https://github.com/cloudflare/cloudflare-python/commit/2f8cee56e4505a5d9d4b258551fd14e559751062)) +* **api:** OpenAPI spec update via Stainless API ([#884](https://github.com/cloudflare/cloudflare-python/issues/884)) ([0a5bff5](https://github.com/cloudflare/cloudflare-python/commit/0a5bff5ef8bb33e91847dc06e27cd64c25a3d366)) +* **api:** OpenAPI spec update via Stainless API ([#885](https://github.com/cloudflare/cloudflare-python/issues/885)) ([142d257](https://github.com/cloudflare/cloudflare-python/commit/142d257f4487a91f424c34b9c06c45efe1dfbcd9)) +* **api:** OpenAPI spec update via Stainless API ([#886](https://github.com/cloudflare/cloudflare-python/issues/886)) ([78c7e25](https://github.com/cloudflare/cloudflare-python/commit/78c7e25e85316d7529d76bed2c75a47476337ebb)) +* **api:** OpenAPI spec update via Stainless API ([#887](https://github.com/cloudflare/cloudflare-python/issues/887)) ([561f2c0](https://github.com/cloudflare/cloudflare-python/commit/561f2c0b649394d493363915c97714e39fc2a011)) +* **api:** OpenAPI spec update via Stainless API ([#888](https://github.com/cloudflare/cloudflare-python/issues/888)) ([21b7830](https://github.com/cloudflare/cloudflare-python/commit/21b7830e1b36b653ba670f7584da0c57dd515704)) +* **api:** OpenAPI spec update via Stainless API ([#889](https://github.com/cloudflare/cloudflare-python/issues/889)) ([77175b0](https://github.com/cloudflare/cloudflare-python/commit/77175b0d230954b2f3cd31d12af45b5f022e3c3f)) +* **api:** OpenAPI spec update via Stainless API ([#890](https://github.com/cloudflare/cloudflare-python/issues/890)) ([1158194](https://github.com/cloudflare/cloudflare-python/commit/11581943445a1858adc8cb003764bdf52b1d8319)) +* **api:** OpenAPI spec update via Stainless API ([#891](https://github.com/cloudflare/cloudflare-python/issues/891)) ([6e2115a](https://github.com/cloudflare/cloudflare-python/commit/6e2115adddba8d6764013bc377e4264e74553c96)) +* **api:** OpenAPI spec update via Stainless API ([#892](https://github.com/cloudflare/cloudflare-python/issues/892)) ([0330dce](https://github.com/cloudflare/cloudflare-python/commit/0330dce9a9dc3ebf88c74e7b1f73dab4cd927550)) +* **api:** OpenAPI spec update via Stainless API ([#893](https://github.com/cloudflare/cloudflare-python/issues/893)) ([b22ba08](https://github.com/cloudflare/cloudflare-python/commit/b22ba085dffb57dc8540e88e250655e23a0e6c4e)) +* **api:** OpenAPI spec update via Stainless API ([#894](https://github.com/cloudflare/cloudflare-python/issues/894)) ([8140735](https://github.com/cloudflare/cloudflare-python/commit/814073556826dcf850c9066b40dbb6a186a55b29)) +* **api:** OpenAPI spec update via Stainless API ([#895](https://github.com/cloudflare/cloudflare-python/issues/895)) ([547a922](https://github.com/cloudflare/cloudflare-python/commit/547a922d645ba30f18fda20308cec11a00605295)) +* **api:** OpenAPI spec update via Stainless API ([#896](https://github.com/cloudflare/cloudflare-python/issues/896)) ([7067513](https://github.com/cloudflare/cloudflare-python/commit/706751326205e3272f1d3e5e2ae60c6555c18b72)) +* **api:** OpenAPI spec update via Stainless API ([#897](https://github.com/cloudflare/cloudflare-python/issues/897)) ([ec1cce1](https://github.com/cloudflare/cloudflare-python/commit/ec1cce1022b73726a50bcd19f518c47a2f7f90d1)) +* **api:** OpenAPI spec update via Stainless API ([#898](https://github.com/cloudflare/cloudflare-python/issues/898)) ([ee63e1e](https://github.com/cloudflare/cloudflare-python/commit/ee63e1eabd0ded4e2b0d66f7be3b4d3fdc73454a)) +* **api:** OpenAPI spec update via Stainless API ([#899](https://github.com/cloudflare/cloudflare-python/issues/899)) ([f7761eb](https://github.com/cloudflare/cloudflare-python/commit/f7761ebf84cf5a60e6c2b1443e34104e3c65b06b)) +* **api:** OpenAPI spec update via Stainless API ([#900](https://github.com/cloudflare/cloudflare-python/issues/900)) ([d61c9a1](https://github.com/cloudflare/cloudflare-python/commit/d61c9a1401a1d200fdaa850a1e4393dd60159bdc)) +* **api:** OpenAPI spec update via Stainless API ([#901](https://github.com/cloudflare/cloudflare-python/issues/901)) ([0c82790](https://github.com/cloudflare/cloudflare-python/commit/0c827900578fa4ca1f790b7dddd1e93090ceaa6a)) +* **api:** OpenAPI spec update via Stainless API ([#902](https://github.com/cloudflare/cloudflare-python/issues/902)) ([36f10ac](https://github.com/cloudflare/cloudflare-python/commit/36f10acb46a80d69906018baaad28c5c07299da0)) +* **api:** OpenAPI spec update via Stainless API ([#903](https://github.com/cloudflare/cloudflare-python/issues/903)) ([a1c451e](https://github.com/cloudflare/cloudflare-python/commit/a1c451e77848fc90c5bcb0cbb7e681d6df8611a6)) +* **api:** OpenAPI spec update via Stainless API ([#904](https://github.com/cloudflare/cloudflare-python/issues/904)) ([73c1c10](https://github.com/cloudflare/cloudflare-python/commit/73c1c103a90c77f85d548d93478a39412f0e7647)) +* **api:** OpenAPI spec update via Stainless API ([#905](https://github.com/cloudflare/cloudflare-python/issues/905)) ([fe3c0e9](https://github.com/cloudflare/cloudflare-python/commit/fe3c0e9aaf50b1376da4159da12f03134b1b1d4d)) +* **api:** OpenAPI spec update via Stainless API ([#906](https://github.com/cloudflare/cloudflare-python/issues/906)) ([637480d](https://github.com/cloudflare/cloudflare-python/commit/637480d143b5f2f77226b84d88a3b283733367bf)) +* **api:** OpenAPI spec update via Stainless API ([#907](https://github.com/cloudflare/cloudflare-python/issues/907)) ([1716baf](https://github.com/cloudflare/cloudflare-python/commit/1716bafadaba2a6fc8511f0cafb000ee33d661ba)) +* **api:** OpenAPI spec update via Stainless API ([#908](https://github.com/cloudflare/cloudflare-python/issues/908)) ([392e54f](https://github.com/cloudflare/cloudflare-python/commit/392e54fb43bf148da0f1686cb8e777135c96d106)) +* **api:** OpenAPI spec update via Stainless API ([#909](https://github.com/cloudflare/cloudflare-python/issues/909)) ([f9ea911](https://github.com/cloudflare/cloudflare-python/commit/f9ea911f67fe67ecdc9dd7cbb9611db3a777cd95)) +* **api:** OpenAPI spec update via Stainless API ([#910](https://github.com/cloudflare/cloudflare-python/issues/910)) ([cef0cea](https://github.com/cloudflare/cloudflare-python/commit/cef0cea6c48a6b3af2c3da8ece583cf5cef347c8)) +* **api:** OpenAPI spec update via Stainless API ([#911](https://github.com/cloudflare/cloudflare-python/issues/911)) ([92b2ce3](https://github.com/cloudflare/cloudflare-python/commit/92b2ce3b9b1800491f3e82e109d0daa3ef8624c1)) +* **api:** OpenAPI spec update via Stainless API ([#913](https://github.com/cloudflare/cloudflare-python/issues/913)) ([7600ef4](https://github.com/cloudflare/cloudflare-python/commit/7600ef4404439ad88e907cfbc906df3f295f92b4)) +* **api:** OpenAPI spec update via Stainless API ([#914](https://github.com/cloudflare/cloudflare-python/issues/914)) ([64e3e72](https://github.com/cloudflare/cloudflare-python/commit/64e3e727948bb198791c83e0eab875729a213ca8)) +* **api:** OpenAPI spec update via Stainless API ([#915](https://github.com/cloudflare/cloudflare-python/issues/915)) ([e94d9f7](https://github.com/cloudflare/cloudflare-python/commit/e94d9f7e8a238b5706f65db4bb7e83cc0db7aedb)) +* **api:** OpenAPI spec update via Stainless API ([#916](https://github.com/cloudflare/cloudflare-python/issues/916)) ([6dc52de](https://github.com/cloudflare/cloudflare-python/commit/6dc52de9b04efdf2f0a09731f7d9fd262a87cdd7)) +* **api:** OpenAPI spec update via Stainless API ([#917](https://github.com/cloudflare/cloudflare-python/issues/917)) ([5d522b4](https://github.com/cloudflare/cloudflare-python/commit/5d522b4a3b7a5b8c1dcc48b7e19bcc86570ad0c1)) +* **api:** OpenAPI spec update via Stainless API ([#918](https://github.com/cloudflare/cloudflare-python/issues/918)) ([598f17d](https://github.com/cloudflare/cloudflare-python/commit/598f17dc09f2bc1eba21732d658aff91092ad38f)) +* **api:** OpenAPI spec update via Stainless API ([#919](https://github.com/cloudflare/cloudflare-python/issues/919)) ([8c02be4](https://github.com/cloudflare/cloudflare-python/commit/8c02be4d02578daa36bb64a06f3ecc5e6d1e93a6)) +* **api:** OpenAPI spec update via Stainless API ([#920](https://github.com/cloudflare/cloudflare-python/issues/920)) ([3f3c410](https://github.com/cloudflare/cloudflare-python/commit/3f3c410cc465de67bf4a353cfe18b3d29fc8524a)) +* **api:** OpenAPI spec update via Stainless API ([#921](https://github.com/cloudflare/cloudflare-python/issues/921)) ([9c78797](https://github.com/cloudflare/cloudflare-python/commit/9c787974347ea014457389007bc6f9f6397306e3)) +* **api:** OpenAPI spec update via Stainless API ([#922](https://github.com/cloudflare/cloudflare-python/issues/922)) ([4f81e3a](https://github.com/cloudflare/cloudflare-python/commit/4f81e3a49b56512c4258c33a5aa9872b8362842b)) +* **api:** OpenAPI spec update via Stainless API ([#924](https://github.com/cloudflare/cloudflare-python/issues/924)) ([a19a006](https://github.com/cloudflare/cloudflare-python/commit/a19a00632f6f635bad9789a9021dc5f006c3d580)) +* **api:** OpenAPI spec update via Stainless API ([#925](https://github.com/cloudflare/cloudflare-python/issues/925)) ([ff97dd5](https://github.com/cloudflare/cloudflare-python/commit/ff97dd5b0cd64672a0a63102396a2fbfc04a3cb8)) +* **api:** OpenAPI spec update via Stainless API ([#926](https://github.com/cloudflare/cloudflare-python/issues/926)) ([02aeaab](https://github.com/cloudflare/cloudflare-python/commit/02aeaabae3c68c8f46570d9dbff8f5c72b271093)) +* **api:** OpenAPI spec update via Stainless API ([#927](https://github.com/cloudflare/cloudflare-python/issues/927)) ([74f9017](https://github.com/cloudflare/cloudflare-python/commit/74f90177e7343e27868c0b6cfef297254cdaa41f)) +* **api:** OpenAPI spec update via Stainless API ([#928](https://github.com/cloudflare/cloudflare-python/issues/928)) ([113cb5b](https://github.com/cloudflare/cloudflare-python/commit/113cb5b2690caf2ec4dc37986ebc1a5849e365d2)) +* **api:** OpenAPI spec update via Stainless API ([#929](https://github.com/cloudflare/cloudflare-python/issues/929)) ([4198b88](https://github.com/cloudflare/cloudflare-python/commit/4198b88ddc5f68bf8a433bc57f70bf4d55e6631e)) +* **api:** OpenAPI spec update via Stainless API ([#930](https://github.com/cloudflare/cloudflare-python/issues/930)) ([5384210](https://github.com/cloudflare/cloudflare-python/commit/53842105e14b0bbed52311da07a5c7396fe09e03)) +* **api:** OpenAPI spec update via Stainless API ([#931](https://github.com/cloudflare/cloudflare-python/issues/931)) ([912276c](https://github.com/cloudflare/cloudflare-python/commit/912276c1fd9a39bd0bba3e79f809af55122488ff)) +* **api:** OpenAPI spec update via Stainless API ([#932](https://github.com/cloudflare/cloudflare-python/issues/932)) ([a1758ad](https://github.com/cloudflare/cloudflare-python/commit/a1758adc9d2920cc77be660f8d2ae15be0a91b68)) +* **api:** OpenAPI spec update via Stainless API ([#933](https://github.com/cloudflare/cloudflare-python/issues/933)) ([02fe287](https://github.com/cloudflare/cloudflare-python/commit/02fe287f003629a048370f66b452b4875f1f593f)) +* **api:** OpenAPI spec update via Stainless API ([#934](https://github.com/cloudflare/cloudflare-python/issues/934)) ([a1af91e](https://github.com/cloudflare/cloudflare-python/commit/a1af91e7e01b6e610d12f64346c5c1335c6e76c5)) +* **api:** OpenAPI spec update via Stainless API ([#935](https://github.com/cloudflare/cloudflare-python/issues/935)) ([3a93f41](https://github.com/cloudflare/cloudflare-python/commit/3a93f412ba0bd69443b91c2e2c4609eb0c1ad82f)) +* **api:** OpenAPI spec update via Stainless API ([#936](https://github.com/cloudflare/cloudflare-python/issues/936)) ([b852f70](https://github.com/cloudflare/cloudflare-python/commit/b852f702de447c36d347fac54b08ee052b4803f5)) +* **api:** OpenAPI spec update via Stainless API ([#937](https://github.com/cloudflare/cloudflare-python/issues/937)) ([e1195ac](https://github.com/cloudflare/cloudflare-python/commit/e1195acc48a21dec20c5e59da1a3ea5263ca9f47)) +* **api:** OpenAPI spec update via Stainless API ([#938](https://github.com/cloudflare/cloudflare-python/issues/938)) ([bd703b4](https://github.com/cloudflare/cloudflare-python/commit/bd703b43af9642113eb06b19934055dc8c00a251)) +* **api:** OpenAPI spec update via Stainless API ([#939](https://github.com/cloudflare/cloudflare-python/issues/939)) ([ef6191f](https://github.com/cloudflare/cloudflare-python/commit/ef6191f69de92028baaa4229db1bc7f6b001f3e5)) +* **api:** OpenAPI spec update via Stainless API ([#940](https://github.com/cloudflare/cloudflare-python/issues/940)) ([14b0f66](https://github.com/cloudflare/cloudflare-python/commit/14b0f6621fde28becf1e808db62fbff4dd5b0d3c)) +* **api:** OpenAPI spec update via Stainless API ([#941](https://github.com/cloudflare/cloudflare-python/issues/941)) ([9da9ede](https://github.com/cloudflare/cloudflare-python/commit/9da9ede896cbed33dab7b6c94be84c8c9669508a)) +* **api:** OpenAPI spec update via Stainless API ([#942](https://github.com/cloudflare/cloudflare-python/issues/942)) ([cb14149](https://github.com/cloudflare/cloudflare-python/commit/cb1414919426a182bdd69c42bf739c2b8ae31295)) +* **api:** OpenAPI spec update via Stainless API ([#943](https://github.com/cloudflare/cloudflare-python/issues/943)) ([72884ce](https://github.com/cloudflare/cloudflare-python/commit/72884ce88dbb895fe462582ea9d949f079569e7e)) +* **api:** OpenAPI spec update via Stainless API ([#944](https://github.com/cloudflare/cloudflare-python/issues/944)) ([d621200](https://github.com/cloudflare/cloudflare-python/commit/d62120038551a25bb438529ea4106aa8b9c9e1ac)) +* **api:** OpenAPI spec update via Stainless API ([#945](https://github.com/cloudflare/cloudflare-python/issues/945)) ([5ba6aa2](https://github.com/cloudflare/cloudflare-python/commit/5ba6aa2fdcdafdef77a6bde34245383093d85e38)) +* **api:** OpenAPI spec update via Stainless API ([#946](https://github.com/cloudflare/cloudflare-python/issues/946)) ([ba3959a](https://github.com/cloudflare/cloudflare-python/commit/ba3959a51ffcb40e2e1a5d34ee96ec1875bea4cd)) +* **api:** OpenAPI spec update via Stainless API ([#947](https://github.com/cloudflare/cloudflare-python/issues/947)) ([efcc9eb](https://github.com/cloudflare/cloudflare-python/commit/efcc9ebccaf23f036ffa5e569aa74042c709fd64)) +* **api:** OpenAPI spec update via Stainless API ([#948](https://github.com/cloudflare/cloudflare-python/issues/948)) ([c90d052](https://github.com/cloudflare/cloudflare-python/commit/c90d052713e311b792f2e8d6c1081aef615e92e8)) +* **api:** OpenAPI spec update via Stainless API ([#949](https://github.com/cloudflare/cloudflare-python/issues/949)) ([7826536](https://github.com/cloudflare/cloudflare-python/commit/78265361b34ab207c70f5c9a6a43d9801a8b96c5)) +* **api:** OpenAPI spec update via Stainless API ([#950](https://github.com/cloudflare/cloudflare-python/issues/950)) ([00bf600](https://github.com/cloudflare/cloudflare-python/commit/00bf60078f7158b263e7be34f56c1dff60fe518c)) +* **api:** OpenAPI spec update via Stainless API ([#951](https://github.com/cloudflare/cloudflare-python/issues/951)) ([39e0aa0](https://github.com/cloudflare/cloudflare-python/commit/39e0aa0787ac55a1e7da6616724cbf4fde261bbe)) +* **api:** OpenAPI spec update via Stainless API ([#952](https://github.com/cloudflare/cloudflare-python/issues/952)) ([7db30f1](https://github.com/cloudflare/cloudflare-python/commit/7db30f1a64bf0564027e0577cf992bef4c752b75)) +* **api:** OpenAPI spec update via Stainless API ([#953](https://github.com/cloudflare/cloudflare-python/issues/953)) ([1b6e7fb](https://github.com/cloudflare/cloudflare-python/commit/1b6e7fb5063b1c13cc11c3f33d34baf62e77a782)) +* **api:** OpenAPI spec update via Stainless API ([#954](https://github.com/cloudflare/cloudflare-python/issues/954)) ([1a54c89](https://github.com/cloudflare/cloudflare-python/commit/1a54c89f03b210722717e09169d4ffd07f6ef461)) +* **api:** OpenAPI spec update via Stainless API ([#955](https://github.com/cloudflare/cloudflare-python/issues/955)) ([3062da9](https://github.com/cloudflare/cloudflare-python/commit/3062da94071e16c97847144b5cbec16b481a0b50)) +* **api:** OpenAPI spec update via Stainless API ([#956](https://github.com/cloudflare/cloudflare-python/issues/956)) ([1755024](https://github.com/cloudflare/cloudflare-python/commit/1755024b6ff5d16c49b801f6b82addecc140ec36)) +* **api:** OpenAPI spec update via Stainless API ([#957](https://github.com/cloudflare/cloudflare-python/issues/957)) ([da57903](https://github.com/cloudflare/cloudflare-python/commit/da5790328894a566ced0878f3b2e6d70ac27cfcd)) +* **api:** OpenAPI spec update via Stainless API ([#958](https://github.com/cloudflare/cloudflare-python/issues/958)) ([578652c](https://github.com/cloudflare/cloudflare-python/commit/578652c4ac86d756a965431bbfac7d9485983a65)) +* **api:** OpenAPI spec update via Stainless API ([#959](https://github.com/cloudflare/cloudflare-python/issues/959)) ([9911e8a](https://github.com/cloudflare/cloudflare-python/commit/9911e8a5ae9c075129174b9a87f057c39ca2dfca)) +* **api:** OpenAPI spec update via Stainless API ([#960](https://github.com/cloudflare/cloudflare-python/issues/960)) ([f3cd3a0](https://github.com/cloudflare/cloudflare-python/commit/f3cd3a0e495e843468505ccdb9716a9cc330b785)) +* **api:** OpenAPI spec update via Stainless API ([#961](https://github.com/cloudflare/cloudflare-python/issues/961)) ([3900806](https://github.com/cloudflare/cloudflare-python/commit/390080678ba70c628de15912eed8b4609436796e)) +* **api:** OpenAPI spec update via Stainless API ([#962](https://github.com/cloudflare/cloudflare-python/issues/962)) ([e272f2d](https://github.com/cloudflare/cloudflare-python/commit/e272f2d2f3f59d61619ccf848085503ccaebfb06)) +* **api:** OpenAPI spec update via Stainless API ([#964](https://github.com/cloudflare/cloudflare-python/issues/964)) ([66380bd](https://github.com/cloudflare/cloudflare-python/commit/66380bd32051b0f2a8ab1a5bcde8fa2973c546d7)) +* **api:** OpenAPI spec update via Stainless API ([#965](https://github.com/cloudflare/cloudflare-python/issues/965)) ([6adbe9a](https://github.com/cloudflare/cloudflare-python/commit/6adbe9ad9f873f7ed67a46b412d310995947810a)) +* **api:** OpenAPI spec update via Stainless API ([#966](https://github.com/cloudflare/cloudflare-python/issues/966)) ([e8189fd](https://github.com/cloudflare/cloudflare-python/commit/e8189fd35144f716a5b55dfe26194abda2f00e13)) +* **api:** OpenAPI spec update via Stainless API ([#967](https://github.com/cloudflare/cloudflare-python/issues/967)) ([a4c88df](https://github.com/cloudflare/cloudflare-python/commit/a4c88dfb7e357ff1a44da1e6d75bfe05911fb577)) +* **api:** OpenAPI spec update via Stainless API ([#968](https://github.com/cloudflare/cloudflare-python/issues/968)) ([cefb09f](https://github.com/cloudflare/cloudflare-python/commit/cefb09fd18869c7a25a6b02c92b489056d510f87)) +* **api:** OpenAPI spec update via Stainless API ([#969](https://github.com/cloudflare/cloudflare-python/issues/969)) ([71e97aa](https://github.com/cloudflare/cloudflare-python/commit/71e97aa998ff64ea105d88198f981fb9ffcfae71)) +* **api:** OpenAPI spec update via Stainless API ([#970](https://github.com/cloudflare/cloudflare-python/issues/970)) ([9ced3bb](https://github.com/cloudflare/cloudflare-python/commit/9ced3bb626f729053d508b37e233fac9df9ed909)) +* **api:** OpenAPI spec update via Stainless API ([#971](https://github.com/cloudflare/cloudflare-python/issues/971)) ([843c4ab](https://github.com/cloudflare/cloudflare-python/commit/843c4ab7b0fbd684d1a90b94a4af5060d308f439)) +* **api:** OpenAPI spec update via Stainless API ([#972](https://github.com/cloudflare/cloudflare-python/issues/972)) ([187d46d](https://github.com/cloudflare/cloudflare-python/commit/187d46db1fc70b7031f3d0c63569f3d49c1ea9de)) +* **api:** OpenAPI spec update via Stainless API ([#973](https://github.com/cloudflare/cloudflare-python/issues/973)) ([568efe9](https://github.com/cloudflare/cloudflare-python/commit/568efe921e631808baa64520df55692e351db1ce)) +* **api:** OpenAPI spec update via Stainless API ([#974](https://github.com/cloudflare/cloudflare-python/issues/974)) ([edccbd6](https://github.com/cloudflare/cloudflare-python/commit/edccbd62ef420f8a3d3fea10006e728fbaa90194)) +* **api:** OpenAPI spec update via Stainless API ([#975](https://github.com/cloudflare/cloudflare-python/issues/975)) ([46f1cc1](https://github.com/cloudflare/cloudflare-python/commit/46f1cc127ba7a692d3fbd9ecabfc469b7c551a41)) +* **api:** OpenAPI spec update via Stainless API ([#976](https://github.com/cloudflare/cloudflare-python/issues/976)) ([b4a7375](https://github.com/cloudflare/cloudflare-python/commit/b4a7375244c24f9635fec7a075567f0bdcd1ca2d)) +* **api:** OpenAPI spec update via Stainless API ([#977](https://github.com/cloudflare/cloudflare-python/issues/977)) ([816c7b3](https://github.com/cloudflare/cloudflare-python/commit/816c7b3eaf99b4bad259a1434a07d51784fa0db7)) +* **api:** OpenAPI spec update via Stainless API ([#978](https://github.com/cloudflare/cloudflare-python/issues/978)) ([2d44575](https://github.com/cloudflare/cloudflare-python/commit/2d44575915b107e5a829a869d1fc589b2d6b231b)) +* **api:** OpenAPI spec update via Stainless API ([#979](https://github.com/cloudflare/cloudflare-python/issues/979)) ([c57c906](https://github.com/cloudflare/cloudflare-python/commit/c57c9060afa88e36970657fc9721c743f9b013d8)) +* **api:** OpenAPI spec update via Stainless API ([#980](https://github.com/cloudflare/cloudflare-python/issues/980)) ([9742593](https://github.com/cloudflare/cloudflare-python/commit/974259348041aee050a3b00ba4f05309dd831280)) +* **api:** OpenAPI spec update via Stainless API ([#981](https://github.com/cloudflare/cloudflare-python/issues/981)) ([8543fae](https://github.com/cloudflare/cloudflare-python/commit/8543fae03e0d0e700c198cf571df5f0441875a42)) +* **api:** OpenAPI spec update via Stainless API ([#982](https://github.com/cloudflare/cloudflare-python/issues/982)) ([04cd78a](https://github.com/cloudflare/cloudflare-python/commit/04cd78a2fb2db9cea0fa2e7481cf88f7e8dacf43)) +* **api:** OpenAPI spec update via Stainless API ([#983](https://github.com/cloudflare/cloudflare-python/issues/983)) ([06307a8](https://github.com/cloudflare/cloudflare-python/commit/06307a82040a4d26f2da6de687f9f9fcef220505)) +* **api:** OpenAPI spec update via Stainless API ([#984](https://github.com/cloudflare/cloudflare-python/issues/984)) ([c702343](https://github.com/cloudflare/cloudflare-python/commit/c7023433bda54769e048b2e9f106d42e9296474e)) +* **api:** OpenAPI spec update via Stainless API ([#985](https://github.com/cloudflare/cloudflare-python/issues/985)) ([6ee5e16](https://github.com/cloudflare/cloudflare-python/commit/6ee5e162f922d90b1006641505edb8284c334bf4)) +* **api:** OpenAPI spec update via Stainless API ([#986](https://github.com/cloudflare/cloudflare-python/issues/986)) ([4f82091](https://github.com/cloudflare/cloudflare-python/commit/4f82091a8bcd193f25ce42b3e505d052425d9b3b)) +* **api:** OpenAPI spec update via Stainless API ([#987](https://github.com/cloudflare/cloudflare-python/issues/987)) ([b1e3549](https://github.com/cloudflare/cloudflare-python/commit/b1e35493ea6456711b912450eb05f2cc28bc2a2e)) +* **api:** OpenAPI spec update via Stainless API ([#988](https://github.com/cloudflare/cloudflare-python/issues/988)) ([1be11e8](https://github.com/cloudflare/cloudflare-python/commit/1be11e847dbb0966c7a2821a5faaea7bcf16f622)) +* **api:** OpenAPI spec update via Stainless API ([#989](https://github.com/cloudflare/cloudflare-python/issues/989)) ([d8131ea](https://github.com/cloudflare/cloudflare-python/commit/d8131eaecc741a1f4b6b8498965bd39b4e6f2abc)) +* **api:** OpenAPI spec update via Stainless API ([#990](https://github.com/cloudflare/cloudflare-python/issues/990)) ([cc76cff](https://github.com/cloudflare/cloudflare-python/commit/cc76cffbc92ab4a7c88108459723b19be60b6fd5)) +* **api:** OpenAPI spec update via Stainless API ([#991](https://github.com/cloudflare/cloudflare-python/issues/991)) ([0d3feac](https://github.com/cloudflare/cloudflare-python/commit/0d3feacc6e64117014242505b3b9d4222b5cc471)) +* **api:** OpenAPI spec update via Stainless API ([#992](https://github.com/cloudflare/cloudflare-python/issues/992)) ([05e0b92](https://github.com/cloudflare/cloudflare-python/commit/05e0b92bd3b15a1a89e6c390046c027cb87fa6fd)) +* **api:** OpenAPI spec update via Stainless API ([#993](https://github.com/cloudflare/cloudflare-python/issues/993)) ([9cb5cd7](https://github.com/cloudflare/cloudflare-python/commit/9cb5cd7d018e59fbc6d2c069932cb222aaa81377)) +* **api:** OpenAPI spec update via Stainless API ([#994](https://github.com/cloudflare/cloudflare-python/issues/994)) ([349941a](https://github.com/cloudflare/cloudflare-python/commit/349941a0f10e78688bec3cac9cab06fa22d13b68)) +* **api:** update via SDK Studio ([#1011](https://github.com/cloudflare/cloudflare-python/issues/1011)) ([6a74ae1](https://github.com/cloudflare/cloudflare-python/commit/6a74ae12a6920b8572d331367774bba1a11d9966)) +* **api:** update via SDK Studio ([#726](https://github.com/cloudflare/cloudflare-python/issues/726)) ([cb61101](https://github.com/cloudflare/cloudflare-python/commit/cb61101d98a02f77a21e538964b193dc33d2e9a3)) +* **api:** update via SDK Studio ([#775](https://github.com/cloudflare/cloudflare-python/issues/775)) ([c8f72ed](https://github.com/cloudflare/cloudflare-python/commit/c8f72ed706ea5af7bade55a7277ce7f7867ec43a)) +* **api:** update via SDK Studio ([#778](https://github.com/cloudflare/cloudflare-python/issues/778)) ([5ffaecc](https://github.com/cloudflare/cloudflare-python/commit/5ffaecc6e0a404a3df2a65d088ab500e46027256)) +* **api:** update via SDK Studio ([#782](https://github.com/cloudflare/cloudflare-python/issues/782)) ([c8dc5e3](https://github.com/cloudflare/cloudflare-python/commit/c8dc5e30a180643fbf269ce5cbb276d91db36373)) +* **api:** update via SDK Studio ([#783](https://github.com/cloudflare/cloudflare-python/issues/783)) ([f30af85](https://github.com/cloudflare/cloudflare-python/commit/f30af8597b0de54d7ca199a713e7e66f7fc16ec5)) +* **api:** update via SDK Studio ([#784](https://github.com/cloudflare/cloudflare-python/issues/784)) ([547f900](https://github.com/cloudflare/cloudflare-python/commit/547f900a651274f74fa778bb26b12b5492179775)) +* **api:** update via SDK Studio ([#809](https://github.com/cloudflare/cloudflare-python/issues/809)) ([9d23770](https://github.com/cloudflare/cloudflare-python/commit/9d23770ed3153efe957cb14a51c6bdf9545a2af7)) +* **api:** update via SDK Studio ([#834](https://github.com/cloudflare/cloudflare-python/issues/834)) ([11bb6dd](https://github.com/cloudflare/cloudflare-python/commit/11bb6dd69fb5b3e8f872056580da76f62b2a2852)) +* **api:** update via SDK Studio ([#835](https://github.com/cloudflare/cloudflare-python/issues/835)) ([df5ef97](https://github.com/cloudflare/cloudflare-python/commit/df5ef97507b50a14aefafd0d908ce703ae7ca075)) +* **api:** update via SDK Studio ([#862](https://github.com/cloudflare/cloudflare-python/issues/862)) ([8c548f7](https://github.com/cloudflare/cloudflare-python/commit/8c548f7bb0b4447f013db23642bfaff5357d5244)) +* **api:** update via SDK Studio ([#863](https://github.com/cloudflare/cloudflare-python/issues/863)) ([992e3d6](https://github.com/cloudflare/cloudflare-python/commit/992e3d68e7e40ae34819190a7deb9ef9b63d97ac)) +* **api:** update via SDK Studio ([#912](https://github.com/cloudflare/cloudflare-python/issues/912)) ([03507c5](https://github.com/cloudflare/cloudflare-python/commit/03507c5c9172bb669b25ba6ba81737b8c5f8da17)) +* **api:** update via SDK Studio ([#923](https://github.com/cloudflare/cloudflare-python/issues/923)) ([980ac6d](https://github.com/cloudflare/cloudflare-python/commit/980ac6dd9ed7bc345c36fd112f2be169870680ec)) +* **api:** update via SDK Studio ([#963](https://github.com/cloudflare/cloudflare-python/issues/963)) ([e51ae76](https://github.com/cloudflare/cloudflare-python/commit/e51ae76cb5230e3c28f24e47ab3fa7139dc6f23c)) +* **api:** update via SDK Studio ([#995](https://github.com/cloudflare/cloudflare-python/issues/995)) ([3de5454](https://github.com/cloudflare/cloudflare-python/commit/3de54540a0c98b9069eb2d61e7a2aafd76270223)) +* **api:** update via SDK Studio ([#996](https://github.com/cloudflare/cloudflare-python/issues/996)) ([04b79fa](https://github.com/cloudflare/cloudflare-python/commit/04b79faf413cf05f4e73d99250d19648b3238a45)) +* **api:** update via SDK Studio ([#997](https://github.com/cloudflare/cloudflare-python/issues/997)) ([f583ec8](https://github.com/cloudflare/cloudflare-python/commit/f583ec8acf38b39270a15d4eaa6ab5c24646e4ee)) +* **api:** update via SDK Studio ([#998](https://github.com/cloudflare/cloudflare-python/issues/998)) ([7e2cd67](https://github.com/cloudflare/cloudflare-python/commit/7e2cd67996f60b19b131fb6dcadc99ebc7900ef4)) +* **api:** update via SDK Studio ([#999](https://github.com/cloudflare/cloudflare-python/issues/999)) ([e0269bb](https://github.com/cloudflare/cloudflare-python/commit/e0269bba241cfdc1ff1ffad4f5c5ff01d79f3951)) + ## 3.0.0-beta.9 (2024-05-08) Full Changelog: [v3.0.0-beta.8...v3.0.0-beta.9](https://github.com/cloudflare/cloudflare-python/compare/v3.0.0-beta.8...v3.0.0-beta.9) diff --git a/pyproject.toml b/pyproject.toml index 3a86f27f65f..02bcdae2a23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "cloudflare" -version = "3.0.0-beta.9" +version = "3.0.0-beta.10" description = "The official Python library for the cloudflare API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/cloudflare/_version.py b/src/cloudflare/_version.py index 0e7c52ee3d0..92e51bde907 100644 --- a/src/cloudflare/_version.py +++ b/src/cloudflare/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "cloudflare" -__version__ = "3.0.0-beta.9" # x-release-please-version +__version__ = "3.0.0-beta.10" # x-release-please-version